WithDataSection.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond 88.8% 8 / 9 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 95.6% 44 / 46 CC 5 SCAR 11.7
CC
5
Cov
97%
munge_file
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
↑ Summary WithData.pm »
1 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Dist::Zilla::Plugin::MungeFile::WithDataSection; # git description: last-commit-with-mungefile-3-g0f25313
4 # ABSTRACT: Modify files in the build, with templates and DATA section
5 # KEYWORDS: plugin file content injection modification template DATA __DATA__ section
6 # vim: set ts=8 sts=4 sw=4 tw=115 et :
7  
8 5 our $VERSION = '0.009';
9  
10 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 extends 'Dist::Zilla::Plugin::MungeFile';
12 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # around dump_config => sub ... no additional configs to add
15  
16 sub munge_file
17 5 ▶{
Subroutine munge_file: called CC=5 SCAR=16.1
Pod documented
18 5 my ($self, $file) = @_;
19  
20 5 my $content = $file->content;
21  
22 5 ▶ my $end_pos = $content =~ m/\n__END__\n/g && pos($content);
Condition66%2/3
$content =~ /\n__END__\n/g && pos $content
!ll&&!rl&&r
203
MC/DC50%1/2
$content =~ /\n__END__\n/g && pos $content
$content =~ /\n__END__\n/g pos $content
Truth table66%2/3
A && B
A= $content =~ /\n__END__\n/gB= pos $content
ABresult
0X0
100
111
23 5 pos($content) = undef;
24  
25 5 my $data;
26 5 ▶ if ($content =~ m/\n__DATA__\n/spg and (not $end_pos or pos($content) < $end_pos))
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ /\n__DATA__\n/gps and !$end_pos || pos $content < $end_pos) 3 2 5
Condition100%6/6
$content =~ /\n__DATA__\n/gps and !$end_pos || pos $content < $end_pos
!ll&&!rl&&r
113
not $end_pos or pos $content < $end_pos
l!l&&r!l&&!r
121
MC/DC100%3/3
$content =~ /\n__DATA__\n/gps and !$end_pos || pos $content < $end_pos
$content =~ /\n__DATA__\n/gps not $end_pos pos $content < $end_pos
Truth table100%4/4
A and not(B) or C
A= $content =~ /\n__DATA__\n/gpsB= not $end_posC= pos $content < $end_pos
ABCresult
0XX0
1000
11X1
1011
27 {
28 3 $data = ${^POSTMATCH};
29 3 $data =~ s/\n__END__\n.*$/\n/s;
30 }
31  
32 $self->next::method(
33 5 $file,
34 { DATA => \$data },
35 );
36 }
37  
38 5 __PACKAGE__->meta->make_immutable;
39  
40 __END__
↑ Summary WithData.pm »