File Coverage

lib/DBIx/Schema/Changelog/Command/Base.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 26 26 100.0


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::Command::Base;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::Command::Base - Abstract file class.
6              
7             =head1 VERSION
8              
9             Version 0.7.2
10              
11             =cut
12              
13             our $VERSION = '0.7.2';
14              
15 4     4   3606 use strict;
  4         7  
  4         116  
16 4     4   13 use warnings FATAL => 'all';
  4         5  
  4         119  
17 4     4   1670 use Time::Piece;
  4         27015  
  4         15  
18 4     4   1175 use Moose::Role;
  4         297816  
  4         20  
19              
20             has year => (
21             isa => 'Int',
22             is => 'ro',
23             default => sub {
24             my $t = Time::Piece->new();
25             return $t->year;
26             }
27             );
28              
29             has makefile => (
30             isa => 'Str',
31             is => 'ro',
32             default => q~use strict;
33             use warnings FATAL => 'all';
34             use ExtUtils::MakeMaker;
35              
36             WriteMakefile(
37             NAME => 'DBIx::Schema::Changelog::{0}::{1}',
38             AUTHOR => q{{2} <{3}>},
39             VERSION_FROM => 'lib/DBIx/Schema/Changelog/{0}/{1}.pm',
40             ABSTRACT_FROM => 'lib/DBIx/Schema/Changelog/{0}/{1}.pm',
41             LICENSE => 'Artistic_2_0',
42             PL_FILES => {},
43             MIN_PERL_VERSION => 5.10.0,
44             CONFIGURE_REQUIRES => {
45             'ExtUtils::MakeMaker' => 0,
46             },
47             BUILD_REQUIRES => {
48             'strict' => 1.08,
49             'Moose' => 2.1403,
50             'warnings' => 1.23,
51             'DBIx::Schema::Changelog' => 'v{4}',
52             },
53             PREREQ_PM => {
54             #'ABC' => 1.6,
55             #'Foo::Bar::module' => 5.0401,
56             },
57             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
58             clean => { FILES => 'DBIx-Schema-Changelog-{0}-{1}-*' }
59             );~,
60             );
61              
62             has manifest => (
63             isa => 'Str',
64             is => 'ro',
65             default => q~Changes
66             Makefile.PL
67             MANIFEST
68             README.md
69             lib/DBIx/Schema/Changelog/{0}/{1}.pm
70             t/00-load.t
71             t/boilerplate.t
72             t/manifest.t
73             t/pod-coverage.t
74             t/pod.t
75             ~,
76             );
77              
78             has readme => (
79             isa => 'Str',
80             is => 'ro',
81             default =>
82             q~DBIx-Schema-Changelog-{0}-{1} - A new {0} module for DBIx-Schema-Changelog
83              
84             MOTIVATION
85              
86             Its a missing module which one has needed.
87              
88             INSTALLATION
89              
90             To install this module, run the following commands:
91              
92             perl Makefile.PL
93             make
94             make test
95             make install
96              
97             SUPPORT AND DOCUMENTATION
98              
99             After installing, you can find documentation for this module with the
100             perldoc command.
101              
102             perldoc DBIx::Schema::Changelog::{0}::{1}
103              
104             You can also look for information at:
105              
106             RT, CPAN's request tracker (report bugs here)
107             http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Schema-Changelog-{0}-{1}
108              
109             AnnoCPAN, Annotated CPAN documentation
110             http://annocpan.org/dist/DBIx-Schema-Changelog-{0}-{1}
111              
112             CPAN Ratings
113             http://cpanratings.perl.org/d/DBIx-Schema-Changelog-{0}-{1}
114              
115             Search CPAN
116             http://search.cpan.org/dist/DBIx-Schema-Changelog-{0}-{1}/
117             ~,
118             );
119              
120             has license => (
121             isa => 'Str',
122             is => 'ro',
123             default => q~
124             LICENSE AND COPYRIGHT
125              
126             Copyright (C) {0} {1}
127              
128             This program is free software; you can redistribute it and/or modify it
129             under the terms of the the Artistic License (2.0). You may obtain a
130             copy of the full license at:
131              
132             L<http://www.perlfoundation.org/artistic_license_2_0>
133              
134             Any use, modification, and distribution of the Standard or Modified
135             Versions is governed by this Artistic License. By using, modifying or
136             distributing the Package, you accept this license. Do not use, modify,
137             or distribute the Package, if you do not accept this license.
138              
139             If your Modified Version has been derived from a Modified Version made
140             by someone other than you, you are nevertheless required to ensure that
141             your Modified Version complies with the requirements of this license.
142              
143             This license does not grant you the right to use any trademark, service
144             mark, trade name, or logo of the Copyright Holder.
145              
146             This license includes the non-exclusive, worldwide, free-of-charge
147             patent license to make, have made, use, offer to sell, sell, import and
148             otherwise transfer the Package with respect to any patent claims
149             licensable by the Copyright Holder that are necessarily infringed by the
150             Package. If you institute patent litigation (including a cross-claim or
151             counterclaim) against any party alleging that the Package constitutes
152             direct or contributory patent infringement, then this Artistic License
153             to you shall terminate on the date that such litigation is filed.
154              
155             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
156             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
157             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
158             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
159             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
160             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
161             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
162             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
163              
164             ~,
165             );
166              
167             has changes => (
168             isa => 'Str',
169             is => 'ro',
170             default => q~Revision history for DBIx-Schema-Changelog-{0}-{1}
171              
172             #========================================================================
173             # Version {2} Date: {3} ({4})
174             #========================================================================
175              
176             * First version, released on an unsuspecting world.
177             ~,
178             );
179              
180             has t_load => (
181             isa => 'Str',
182             is => 'ro',
183             default => q~use Test::More tests => 2;
184              
185             use FindBin;
186             use lib File::Spec->catfile( $FindBin::Bin, '..', 'lib' );
187             use strict;
188             use warnings;
189              
190             require_ok( 'DBIx::Schema::Changelog::{0}::{1}' );
191             use_ok 'DBIx::Schema::Changelog::{0}::{1}';~,
192             );
193              
194             has t_boilerplate => (
195             isa => 'Str',
196             is => 'ro',
197             default => q/#!perl -T
198             use strict;
199             use warnings FATAL => 'all';
200             use Test::More;
201              
202             plan tests => 3;
203              
204             sub not_in_file_ok {
205             my ($filename, %regex) = @_;
206             open( my $fh, '<', $filename )
207             or die "couldn't open $filename for reading: $!";
208              
209             my %violated;
210              
211             while (my $line = <$fh>) {
212             while (my ($desc, $regex) = each %regex) {
213             if ($line =~ $regex) {
214             push @{$violated{$desc}||=[]}, $.;
215             }
216             }
217             }
218              
219             if (%violated) {
220             fail("$filename contains boilerplate text");
221             diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
222             } else {
223             pass("$filename contains no boilerplate text");
224             }
225             }
226              
227             sub module_boilerplate_ok {
228             my ($module) = @_;
229             not_in_file_ok($module =>
230             '$moduleNAME' => qr~ - A new {0} for DBIx::Schema::Changelog ~,
231             'boilerplate description' => qr~Quick summary of what the module~,
232             'stub function definition' => qr~function[12]~,
233             );
234             }
235              
236             TODO: {
237             local $TODO = "Need to replace the boilerplate text";
238              
239             not_in_file_ok('README.md' =>
240             "The README is used..." => qr~The README is used~,
241             "'version information here'" => qr~to provide version information~,
242             );
243              
244             not_in_file_ok(Changes =>
245             "placeholder date\/time" => qr(Date\/time)
246             );
247              
248             module_boilerplate_ok('lib\/DBIx\/Schema\/Changelog\/{0}\/{1}.pm');
249              
250              
251             }/,
252             );
253              
254             has t_manifest => (
255             isa => 'Str',
256             is => 'ro',
257             default => q~#!perl -T
258             use strict;
259             use warnings FATAL => 'all';
260             use Test::More;
261              
262             unless ( $ENV{RELEASE_TESTING} ) {
263             plan( skip_all => "Author tests not required for installation" );
264             }
265              
266             my $min_tcm = 0.9;
267             eval "use Test::CheckManifest $min_tcm";
268             plan skip_all => "Test::CheckManifest $min_tcm required" if $@;
269              
270             ok_manifest();~,
271             );
272              
273             has t_pod_coverage => (
274             isa => 'Str',
275             is => 'ro',
276             default => q~#!perl -T
277             use strict;
278             use warnings FATAL => 'all';
279             use Test::More;
280              
281             use Test::Pod::Coverage 1.08;
282             use Pod::Coverage::TrustPod;
283              
284             unless ( $ENV{RELEASE_TESTING} ) {
285             plan( skip_all => "Author tests not required for installation" );
286             }
287              
288             all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });
289              
290             # Ensure a recent version of Test::Pod::Coverage
291             my $min_tpc = 1.08;
292             eval "use Test::Pod::Coverage $min_tpc";
293             plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
294             if $@;
295              
296             # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
297             # but older versions don't recognize some common documentation styles
298             my $min_pc = 0.18;
299             eval "use Pod::Coverage $min_pc";
300             plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@;
301             ~,
302             );
303              
304             has t_pod => (
305             isa => 'Str',
306             is => 'ro',
307             default => q~#!perl -T
308             use strict;
309             use warnings FATAL => 'all';
310             use Test::More;
311              
312             unless ( $ENV{RELEASE_TESTING} ) {
313             plan( skip_all => "Author tests not required for installation" );
314             }
315            
316             # Ensure a recent version of Test::Pod
317             my $min_tp = 1.22;
318             eval "use Test::Pod $min_tp";
319             plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
320            
321             all_pod_files_ok();~,
322             );
323              
324             =head1 SUBROUTINES/METHODS
325              
326             =head2 replace_spare
327              
328             =cut
329              
330             sub _replace_spare {
331 26     26   29 my ( $string, $options ) = @_;
332 26         231 $string =~ s/\{(\d+)\}/$options->[$1]/g;
333 26         79 return $string;
334             }
335              
336             =head2 write_file
337              
338             =cut
339              
340             sub _write_file {
341 28     28   57 my ( $file, $text ) = @_;
342 28         2366 print " + $file\n";
343 28         1571 open( my $fh, '>>', $file );
344 28         119 print $fh $text;
345 28         733 close $fh;
346             }
347              
348             1; # End of DBIx::Schema::Changelog::File
349              
350             __END__
351              
352             =head1 AUTHOR
353              
354             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
355              
356             =head1 LICENSE AND COPYRIGHT
357              
358             Copyright 2015 Mario Zieschang.
359              
360             This program is free software; you can redistribute it and/or modify it
361             under the terms of the the Artistic License (2.0). You may obtain a
362             copy of the full license at:
363              
364             L<http://www.perlfoundation.org/artistic_license_2_0>
365              
366             Any use, modification, and distribution of the Standard or Modified
367             Versions is governed by this Artistic License. By using, modifying or
368             distributing the Package, you accept this license. Do not use, modify,
369             or distribute the Package, if you do not accept this license.
370              
371             If your Modified Version has been derived from a Modified Version made
372             by someone other than you, you are nevertheless required to ensure that
373             your Modified Version complies with the requirements of this license.
374              
375             This license does not grant you the right to use any trademark, service
376             mark, trade name, or logo of the Copyright Holder.
377              
378             This license includes the non-exclusive, worldwide, free-of-charge
379             patent license to make, have made, use, offer to sell, sell, import and
380             otherwise transfer the Package with respect to any patent claims
381             licensable by the Copyright Holder that are necessarily infringed by the
382             Package. If you institute patent litigation (including a cross-claim or
383             counterclaim) against any party alleging that the Package constitutes
384             direct or contributory patent infringement, then this Artistic License
385             to you shall terminate on the date that such litigation is filed.
386              
387             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
388             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
389             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
390             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
391             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
392             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
393             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
394             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
395              
396              
397             =cut