| 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
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%6/6
$content =~ /\n__DATA__\n/gps and !$end_pos || pos $content < $end_pos
not $end_pos or pos $content < $end_pos
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||