File Coverage

lib/Dist/Zilla/Plugin/AbstractFromPOD.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


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