Plugin/Web/PkgVersion.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 42 CC 3 SCAR 19.5
CC
3
Cov
0%
munge_files
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 7.0
1 package Dist::Zilla::Plugin::Web::PkgVersion;
2 $Dist::Zilla::Plugin::Web::PkgVersion::VERSION = '0.0.10';
3 # ABSTRACT: Embedd module version to sources
4  
5 use Moose;
6  
7 use Path::Class;
8  
9 with 'Dist::Zilla::Role::FileMunger';
10 with 'Dist::Zilla::Plugin::Web::Role::FileMatcher';
11  
12  
13  
14 sub munge_files {
15 my ($self) = @_;
16
17 $self->for_each_matched_file(sub {
18 my ($file) = @_;
19  
20 my $content = $file->content;
21 my $content_copy = $content;
22
23 pos $content = 0;
24
25
26 while ($content =~ m!
27 ( (\s*) /\* VERSION (?'comma',)? \*/)
28 !msxg) {
29
30 my $overall = $1;
31 my $overall_quoted = quotemeta $overall;
32
33 my $comma = $3 || '';
34 my $whitespace = $2;
35
36 my $version = $self->zilla->version;
37
38 $version = "'$version'" if $version !~ m/^\d+(\.\d+)?$/;
39
40 $content_copy =~ s!$overall_quoted!${whitespace}/*PKGVERSION*/VERSION : ${version}${comma}!;
41 }
42
43 $file->content($content_copy) if $content_copy ne $content;
44 });
45 }
46  
47  
48 no Moose;
49 __PACKAGE__->meta->make_immutable();
50  
51  
52 1;
53  
54 __END__