File Coverage

blib/lib/Dist/Zilla/Plugin/SurgicalPkgVersion.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 10 100.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::SurgicalPkgVersion;
2             BEGIN {
3 1     1   731 $Dist::Zilla::Plugin::SurgicalPkgVersion::VERSION = '0.0019';
4             }
5             # ABSTRACT: Surgically apply PkgVersion
6              
7              
8 1     1   8 use Moose;
  1         2  
  1         7  
9             extends qw/ Dist::Zilla::Plugin::PkgVersion /;
10              
11             require Dist::Zilla::PluginBundle::ROKR;
12              
13             around munge_perl => sub {
14             my $inner = shift;
15             my ( $self, $file ) = @_;
16              
17             my $content = $file->content;
18              
19             my $yes = 0;
20             if ( my $hint = Dist::Zilla::PluginBundle::ROKR->parse_hint( $content ) ) {
21             if ( exists $hint->{PkgVersion} ) {
22             return unless $hint->{PkgVersion};
23             $yes = 1;
24             }
25             }
26              
27             if ( $yes || $content =~ m/^\s*#+\s*(?:ABSTRACT):\s*(.+)$/m ) { }
28             else { return }
29              
30             return $inner->( @_ )
31             };
32              
33             __PACKAGE__->meta->make_immutable;
34 1     1   6025 no Moose;
  1         2  
  1         6  
35             1;
36              
37             __END__
38             =pod
39              
40             =head1 NAME
41              
42             Dist::Zilla::Plugin::SurgicalPkgVersion - Surgically apply PkgVersion
43              
44             =head1 VERSION
45              
46             version 0.0019
47              
48             =head1 SYNOPSIS
49              
50             In your L<Dist::Zilla> C<dist.ini>:
51              
52             [SurgicalPkgVersion]
53              
54             To hint that you want to apply PkgVersion:
55              
56             package Xyzzy;
57             # Dist::Zilla: +PkgVersion
58              
59             ...
60              
61             =head1 DESCRIPTION
62              
63             Dist::Zilla::Plugin::SurgicalPkgVersion will only PkgVersion a .pm if:
64              
65             1. There exists an # ABSTRACT: ...
66             2. The +PkgVersion hint is present
67              
68             You can forcefully disable PkgVersion on a .pm by using the C<-PkgVersion> hint
69              
70             =head1 AUTHOR
71              
72             Robert Krimen <robertkrimen@gmail.com>
73              
74             =head1 COPYRIGHT AND LICENSE
75              
76             This software is copyright (c) 2011 by Robert Krimen.
77              
78             This is free software; you can redistribute it and/or modify it under
79             the same terms as the Perl 5 programming language system itself.
80              
81             =cut
82