File Coverage

lib/DBIx/Schema/Changelog/Command/File.pm
Criterion Covered Total %
statement 39 39 100.0
branch 3 6 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 49 52 94.2


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::Command::File;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::Command::File - Create a new file reader module from template for DBIx::Schema::Changelog!
6              
7             =head1 VERSION
8              
9             Version 0.7.1
10              
11             =cut
12              
13             our $VERSION = '0.7.1';
14              
15 1     1   5114 use strict;
  1         3  
  1         53  
16 1     1   5 use warnings FATAL => 'all';
  1         1  
  1         53  
17 1     1   680 use Moose;
  1         519708  
  1         10  
18 1     1   8109 use File::Path qw( mkpath );
  1         3  
  1         749  
19              
20             with 'DBIx::Schema::Changelog::Command::Base';
21             ############# End of encapsulated class data. ########################
22              
23             has file => (
24             isa => 'Str',
25             is => 'ro',
26             default => q~package DBIx::Schema::Changelog::File::{0};
27              
28             =head1 NAME
29              
30             DBIx::Schema::Changelog::File::{0} - module for DBIx::Schema::Changelog::File to load changeset from {0} files.
31              
32             =head1 VERSION
33              
34             =over 4
35              
36             Version 0.1.0
37              
38             =cut
39              
40             our $VERSION = '0.1.0';
41              
42             use {4};
43             use strict;
44             use warnings FATAL => 'all';
45             use Moose;
46              
47             with 'DBIx::Schema::Changelog::File';
48              
49             has tpl_main => (
50             isa => 'Str',
51             is => 'ro',
52             default => '',
53             );
54              
55             has tpl_sub => (
56             isa => 'Str',
57             is => 'ro',
58             default => '',
59             );
60              
61             has ending => (
62             is => 'ro',
63             isa => 'Str',
64             default => '.',
65             );
66              
67             =back
68              
69             =head1 SUBROUTINES/METHODS
70              
71             =over 4
72              
73             =item load
74              
75             Called to load defined Yaml files
76              
77             =cut
78              
79             sub load{}
80              
81             no Moose;
82             __PACKAGE__->meta->make_immutable;
83              
84             1; # End of DBIx::Schema::Changelog::File::{0}
85              
86             __END__
87              
88             =back
89              
90             =head1 BUGS
91              
92             Please report any bugs or feature requests to C<bug-dbix-schema-changelog-driver-{0} at rt.cpan.org>, or through
93             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Schema-Changelog-File-{0}>. I will be notified, and then you'll
94             automatically be notified of progress on your bug as I make changes.
95              
96              
97             =head1 SUPPORT
98              
99             You can find documentation for this module with the perldoc command.
100              
101             perldoc DBIx::Schema::Changelog::File::{0}
102              
103              
104             You can also look for information at:
105              
106             =over 4
107              
108             =item * RT: CPAN's request tracker (report bugs here)
109              
110             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Schema-Changelog-File-{0}>
111              
112             =item * AnnoCPAN: Annotated CPAN documentation
113              
114             L<http://annocpan.org/dist/DBIx-Schema-Changelog-File-{0}>
115              
116             =item * CPAN Ratings
117              
118             L<http://cpanratings.perl.org/d/DBIx-Schema-Changelog-File-{0}>
119              
120             =item * Search CPAN
121              
122             L<http://search.cpan.org/dist/DBIx-Schema-Changelog-File-{0}/>
123              
124             =back
125              
126             =head1 ACKNOWLEDGEMENTS
127              
128             =head1 AUTHOR
129              
130             {1}, C<< <{2}> >>
131              
132             ~,
133             );
134              
135             =head1 SUBROUTINES/METHODS
136              
137             =head2 make
138              
139             =cut
140              
141             sub make {
142 1     1 1 2 my ( $self, $config ) = @_;
143 1 50       4 die "No author defined!" unless $config->{author};
144 1 50       13 die "No mail address defined!" unless $config->{email};
145 1 50       4 die "No new type defined!" unless $config->{type};
146 1         54 my $dir = File::Spec->catfile( $config->{dir},
147             "DBIx-Schema-Changelog-File-$config->{type}" );
148 1         11 my $path =
149             File::Spec->catfile( $dir, 'lib', 'DBIx', 'Schema', 'Changelog', 'File' );
150 1         1974 mkpath( $path, 0755 );
151 1         16 $path = File::Spec->catfile( $dir, 't' );
152 1         302 mkpath( $path, 0755 );
153              
154             #module
155 1         15 $path =
156             File::Spec->catfile( $dir, 'lib', 'DBIx', 'Schema', 'Changelog', 'File',
157             "$config->{type}.pm" );
158 1         58 _write_file(
159             $path,
160             _replace_spare(
161             $self->file(),
162             [
163             $config->{type}, $config->{author},
164             $config->{email}, $self->year(),
165             '5.10.0'
166             ]
167             )
168             );
169 1         65 _write_file(
170             $path,
171             _replace_spare(
172             $self->license(), [ $self->year(), $config->{author} ]
173             )
174             );
175 1         6 _write_file( $path, qq~\n=cut\n~ );
176              
177             #AUXILIARY
178 1         18 $path = File::Spec->catfile( $dir, 'README.md' );
179 1         57 _write_file(
180             $path,
181             _replace_spare(
182             $self->readme(),
183             [ 'File', $config->{type}, $config->{author}, $config->{email} ]
184             )
185             );
186 1         56 _write_file(
187             $path,
188             _replace_spare(
189             $self->license(), [ $self->year(), $config->{author} ]
190             )
191             );
192              
193 1         87 _write_file( "$dir/MANIFEST",
194             _replace_spare( $self->manifest(), [ 'File', $config->{type} ] ) );
195              
196 1         48 _write_file(
197             "$dir/Makefile.PL",
198             _replace_spare(
199             $self->makefile(),
200             [
201             'File', $config->{type}, $config->{author},
202             $config->{email}, $VERSION
203             ]
204             )
205             );
206 1         48 _write_file(
207             "$dir/Changes",
208             _replace_spare(
209             $self->changes(),
210             [
211             'File', $config->{type},
212             '0.1.0', '1970/01/01',
213             $config->{author}
214             ]
215             )
216             );
217              
218             #tests
219 1         48 _write_file( "$dir/t/00-load.t",
220             _replace_spare( $self->t_load(), [ 'File', $config->{type} ] ) );
221 1         48 _write_file( "$dir/t/boilerplate.t",
222             _replace_spare( $self->t_boilerplate(), [ 'File', $config->{type} ] ) );
223 1         48 _write_file( "$dir/t/manifest.t",
224             _replace_spare( $self->t_manifest(), [] ) );
225 1         53 _write_file( "$dir/t/pod-coverage.t",
226             _replace_spare( $self->t_pod_coverage(), [] ) );
227 1         45 _write_file( "$dir/t/pod.t", _replace_spare( $self->t_pod(), [] ) );
228             }
229              
230 1     1   16 no Moose;
  1         2  
  1         6  
231             __PACKAGE__->meta->make_immutable;
232              
233             __END__
234              
235             1;
236              
237             =head1 AUTHOR
238              
239             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
240              
241             =head1 LICENSE AND COPYRIGHT
242              
243             Copyright 2015 Mario Zieschang.
244              
245             This program is free software; you can redistribute it and/or modify it
246             under the terms of the the Artistic License (2.0). You may obtain a
247             copy of the full license at:
248              
249             L<http://www.perlfoundation.org/artistic_license_2_0>
250              
251             Any use, modification, and distribution of the Standard or Modified
252             Versions is governed by this Artistic License. By using, modifying or
253             distributing the Package, you accept this license. Do not use, modify,
254             or distribute the Package, if you do not accept this license.
255              
256             If your Modified Version has been derived from a Modified Version made
257             by someone other than you, you are nevertheless required to ensure that
258             your Modified Version complies with the requirements of this license.
259              
260             This license does not grant you the right to use any trademark, service
261             mark, trade name, or logo of the Copyright Holder.
262              
263             This license includes the non-exclusive, worldwide, free-of-charge
264             patent license to make, have made, use, offer to sell, sell, import and
265             otherwise transfer the Package with respect to any patent claims
266             licensable by the Copyright Holder that are necessarily infringed by the
267             Package. If you institute patent litigation (including a cross-claim or
268             counterclaim) against any party alleging that the Package constitutes
269             direct or contributory patent infringement, then this Artistic License
270             to you shall terminate on the date that such litigation is filed.
271              
272             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
273             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
274             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
275             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
276             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
277             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
278             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
279             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
280              
281             =cut