File Coverage

lib/Dist/Zilla/Plugin/AbstractFromPOD.pm
Criterion Covered Total %
statement 18 34 52.9
branch 0 8 0.0
condition 0 3 0.0
subroutine 6 7 85.7
pod 1 1 100.0
total 25 53 47.1


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::AbstractFromPOD;
2              
3 1     1   615 use 5.008;
  1         2  
  1         43  
4 1     1   6 use version; our $VERSION = qv( sprintf '0.3.%d', q$Rev: 1 $ =~ /\d+/gmx );
  1         1  
  1         7  
5              
6 1     1   732 use Moose;
  1         409882  
  1         10  
7 1     1   6968 use English qw( -no_match_vars );
  1         1705  
  1         6  
8 1     1   367 use File::Spec::Functions qw( catfile );
  1         2  
  1         280  
9              
10             with 'Dist::Zilla::Role::BeforeBuild';
11              
12             sub before_build {
13 0     0 1   my $self = shift;
14 0           my $name = $self->zilla->name;
15 0           my $class = $name; $class =~ s{ [\-] }{::}gmx;
  0            
16 0   0       my $file = $self->zilla->_main_module_override
17             || catfile( 'lib', split m{ [\-] }mx, "${name}.pm" );
18              
19 0 0         $file or die 'No main module specified';
20 0 0         -f $file or die "Path ${file} does not exist or not a file";
21 0 0         open my $fh, '<', $file or die "File ${file} cannot open: ${OS_ERROR}";
22              
23 0           my $content = do { local $RS; <$fh> }; $fh->close;
  0            
  0            
  0            
24 0           my ($abstract) = $content
25             =~ m{ =head1 \s+ Name \s* [\n] \s* $class \s* [\-] \s* ([^\n]+) }imsx;
26              
27 0 0         $abstract or die "File ${file} contains no abstract";
28 0           $self->zilla->abstract( $abstract );
29 0           return;
30             }
31              
32             __PACKAGE__->meta->make_immutable;
33              
34 1     1   6 no Moose;
  1         1  
  1         6  
35              
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding utf8
43              
44             =begin html
45              
46             <a href="http://badge.fury.io/pl/Dist-Zilla-Plugin-AbstractFromPOD"><img src="https://badge.fury.io/pl/Dist-Zilla-Plugin-AbstractFromPOD.svg" alt="CPAN Badge"></a>
47             <a href="http://cpants.cpanauthors.org/dist/Dist-Zilla-Plugin-AbstractFromPOD"><img src="http://cpants.cpanauthors.org/dist/Dist-Zilla-Plugin-AbstractFromPOD.png" alt="Kwalitee Badge"></a>
48              
49             =end html
50              
51             =head1 Name
52              
53             Dist::Zilla::Plugin::AbstractFromPOD - Case insensitive head1 POD matching for the Name attribute
54              
55             =head1 Synopsis
56              
57             # In dist.ini
58             [AbstractFromPOD]
59              
60             =head1 Version
61              
62             This documents version v0.3.$Rev: 1 $ of L<Dist::Zilla::Plugin::AbstractFromPOD>
63              
64             =head1 Description
65              
66             Case insensitive head1 POD matching for the Name attribute
67              
68             L<Dist::Zilla> should do this by default but unfortunately it's pattern
69             matching is case sensitive so this instead
70              
71             =head1 Configuration and Environment
72              
73             Defines no attributes
74              
75             =head1 Subroutines/Methods
76              
77             =head2 before_build
78              
79             Read the main module and extract the abstract (case insensitive matching on
80             the head1 Name POD directive)
81              
82             =head1 Diagnostics
83              
84             None
85              
86             =head1 Dependencies
87              
88             =over 3
89              
90             =item L<Dist::Zilla::Role::BeforeBuild>
91              
92             =back
93              
94             =head1 Incompatibilities
95              
96             There are no known incompatibilities in this module
97              
98             =head1 Bugs and Limitations
99              
100             There are no known bugs in this module. Please report problems to
101             http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dist-Zilla-Plugin-AbstractFromPOD.
102             Patches are welcome
103              
104             =head1 Acknowledgements
105              
106             Larry Wall - For the Perl programming language
107              
108             =head1 Author
109              
110             Peter Flanigan, C<< <pjfl@cpan.org> >>
111              
112             =head1 License and Copyright
113              
114             Copyright (c) 2015 Peter Flanigan. All rights reserved
115              
116             This program is free software; you can redistribute it and/or modify it
117             under the same terms as Perl itself. See L<perlartistic>
118              
119             This program is distributed in the hope that it will be useful,
120             but WITHOUT WARRANTY; without even the implied warranty of
121             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
122              
123             =cut
124              
125             # Local Variables:
126             # mode: perl
127             # tab-width: 3
128             # End: