File Coverage

lib/DBIx/Schema/Changelog/File/Yaml.pm
Criterion Covered Total %
statement 20 20 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 28 29 96.5


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::File::Yaml;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::File::Yaml - module for DBIx::Schema::Changelog::File to load changeset from YAML files.
6              
7             =head1 VERSION
8              
9             Version 0.7.2
10              
11             =cut
12              
13             our $VERSION = '0.7.2';
14              
15 3     3   1943 use strict;
  3         3  
  3         109  
16 3     3   12 use warnings FATAL => 'all';
  3         3  
  3         116  
17 3     3   394 use Moose;
  3         285936  
  3         23  
18 3     3   17514 use YAML::XS qw/LoadFile/;
  3         6365  
  3         554  
19              
20             with 'DBIx::Schema::Changelog::File';
21              
22             has tpl_main => (
23             isa => 'Str',
24             is => 'ro',
25             default => q~
26             ---
27             templates:
28             - name: tpl_std
29             columns:
30             - name: id
31             type: integer
32             notnull: 1
33             primarykey: 1
34             default: inc
35              
36             changelogs:
37             - "01"~,
38             );
39              
40             has tpl_sub => (
41             isa => 'Str',
42             is => 'ro',
43             default => q~- id: 001.01-maz
44             author: "Mario Zieschang"
45             entries:
46             - type: createtable
47             name: 'client'
48             columns:
49             - tpl: 'tpl_std'
50             ~,
51             );
52              
53             has ending => (
54             is => 'ro',
55             isa => 'Str',
56             default => '.yml',
57             );
58              
59             =head1 SUBROUTINES/METHODS
60              
61             =over 4
62              
63             =item load
64              
65             Called to load defined Yaml files
66              
67             =cut
68              
69             sub load {
70 6     6 1 263 my ( $self, $file ) = @_;
71              
72 6         184 $file = $file . $self->ending();
73              
74 6 50       327 open my $rfh, '<', $file or die "can't open config file: $file $!";
75 6         385 print STDERR __PACKAGE__, ". Read changelog file '$file'. \n";
76              
77 6         30 return LoadFile($file);
78             }
79              
80 3     3   19 no Moose;
  3         4  
  3         20  
81             __PACKAGE__->meta->make_immutable;
82              
83             1; # End of DBIx::Schema::Changelog::File
84              
85             __END__
86              
87             =back
88              
89             =head1 AUTHOR
90              
91             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
92              
93             =head1 LICENSE AND COPYRIGHT
94              
95             Copyright 2015 Mario Zieschang.
96              
97             This program is free software; you can redistribute it and/or modify it
98             under the terms of the the Artistic License (2.0). You may obtain a
99             copy of the full license at:
100              
101             L<http://www.perlfoundation.org/artistic_license_2_0>
102              
103             Any use, modification, and distribution of the Standard or Modified
104             Versions is governed by this Artistic License. By using, modifying or
105             distributing the Package, you accept this license. Do not use, modify,
106             or distribute the Package, if you do not accept this license.
107              
108             If your Modified Version has been derived from a Modified Version made
109             by someone other than you, you are nevertheless required to ensure that
110             your Modified Version complies with the requirements of this license.
111              
112             This license does not grant you the right to use any trademark, service
113             mark, trade name, or logo of the Copyright Holder.
114              
115             This license includes the non-exclusive, worldwide, free-of-charge
116             patent license to make, have made, use, offer to sell, sell, import and
117             otherwise transfer the Package with respect to any patent claims
118             licensable by the Copyright Holder that are necessarily infringed by the
119             Package. If you institute patent litigation (including a cross-claim or
120             counterclaim) against any party alleging that the Package constitutes
121             direct or contributory patent infringement, then this Artistic License
122             to you shall terminate on the date that such litigation is filed.
123              
124             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
125             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
126             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
127             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
128             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
129             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
130             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
131             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
132              
133             =cut