blib/lib/Dist/Zilla/Plugin/Author/Plicease/MakeMaker.pm

filter: Statementstmt 68.8% 115 / 167 Branchbran 48.1% 26 / 54 Conditioncond 44.4% 8 / 18 MC/DCmcdc 20.0% 2 / 10 Subroutinesub 95.2% 20 / 21 Podpod 0.0% 0 / 1 totaltotal 63.1% 171 / 271 CC 36 SCAR 45.5
CC
36
Cov
62%
__ANON__
160.3
__ANON__
3.0
metadata
2.0
CRAP 95.0
↑ Summary blib/lib/Dist/Zilla/PluginBundle/Author/Plicease.pm »
1 3 package Dist::Zilla::Plugin::Author::Plicease::MakeMaker 2.81 {
2  
3 3 ▶ use 5.022;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶ use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶ use Perl::Tidy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶ use Dist::Zilla::Plugin::Author::Plicease ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶ use List::Util qw( first );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶ use experimental qw( postderef );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: munge the AUTHOR section
12  
13  
14 3 extends 'Dist::Zilla::Plugin::MakeMaker';
15  
16 3 with 'Dist::Zilla::Role::MetaProvider';
17  
18 2 ▶ around write_makefile_args => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
19 2 my($orig, $self, @args) = @_;
20 2 my $h = $self->$orig(@args);
21  
22 # to prevent any non .pm/.pod files from being installed in lib
23 # because shit like this is stuff we ought to have to customize.
24 2 my %PM = map {; "lib/$_" => "\$(INST_LIB)/$_" }
25 2 map { s/^lib\///r }
26 grep /^lib\/.*\.p(od|m)$/,
27 2 map { $_->name }
28 $self->zilla->files->@*;
29 2 $h->{PM} = \%PM;
30  
31 2 $h;
32 3 };
33  
34 2 ▶ around setup_installer => sub {
Subroutine __ANON__: called CC=33 SCAR=50.8
35 2 my($orig, $self, @args) = @_;
36  
37 2 $self->$orig(@args);
38  
39 2 ▶ my $file = first { $_->name eq 'Makefile.PL' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
40 2 ▶ my $mod = first { $_->name eq 'inc/mymm.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
41 2 ▶ my $config = first { $_->name eq 'inc/mymm-config.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
42 2 ▶ my $build = first { $_->name eq 'inc/mymm-build.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
43 2 ▶ my $test = first { $_->name eq 'inc/mymm-test.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
44 2 ▶ my $clean = first { $_->name eq 'inc/mymm-clean.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
45  
46 2 my @content = do {
47 2 my $in = $file->content;
48 2 my $out = '';
49 2 my $err = '';
50 2 local @ARGV = ();
51 2 my $error = Perl::Tidy::perltidy(
52 source => \$in,
53 destination => \$out,
54 stderr => \$err,
55 perltidyrc => Dist::Zilla::Plugin::Author::Plicease->dist_dir->child('perltidyrc')->stringify,
56 );
57 2 $self->log("perltidy: $_") for split /\n/, $err;
58 2 ▶ $self->log_fatal("perltidy failed!") if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 2 2
59 2 split /\n/, $out;
60 };
61  
62 # pet-peve1: remove blank lines between use
63 {
64 2 my $i = 0;
65 2 ▶ while($i<$#content)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#content) 14 0 14
66 {
67 14 ▶ if($content[$i] =~ /^(use|#)/)
Branch: 2 branches
BranchTrueFalseTotal
if ($content[$i] =~ /^(use|#)/u) { } 8 6 14
elsif ($content[$i] =~ /^\s*$/u) { } 4 2 6
68 8 { $i++ }
69 elsif($content[$i] =~ /^\s*$/)
70 4 { @content = @content[0..($i-1),($i+1)..$#content] }
71 else
72 {
73 2 my @extra = ('');
74  
75 2 ▶ if($mod)
Branch: 1 branch
BranchTrueFalseTotal
if ($mod) 1 1 2
76 {
77 1 unshift @extra, 'require "./inc/mymm.pl";';
78 }
79  
80 @content = (
81 2 @content[0..($i-1)],
82 @extra,
83 @content[($i)..$#content]
84 );
85 2 last;
86 }
87 }
88 }
89  
90 # pet-peve2: squeeze multiple blank lines
91 {
92 2 my @new;
93 2 my $last_empty = 0;
94 2 foreach my $line (@content)
95 {
96 73 ▶ if($line =~ /^\s*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*$/u) { } 10 63 73
97 {
98 10 ▶ if($last_empty)
Branch: 1 branch
BranchTrueFalseTotal
if ($last_empty) { } 0 10 10
99 0 { next }
100 else
101 {
102 10 $last_empty = 1;
103 }
104 }
105 else
106 {
107 63 $last_empty = 0;
108 }
109  
110 73 push @new, $line;
111 }
112 2 @content = @new;
113 }
114  
115 2 ▶ if($mod || $test)
Branch: 1 branch
BranchTrueFalseTotal
if ($mod or $test) 1 1 2
Condition66%2/3
$mod or $test
l!l&&r!l&&!r
101
MC/DC50%1/2
$mod or $test
$mod $test
Truth table66%2/3
A or B
A= $modB= $test
ABresult
1X1
011
000
116 {
117 1 my @extra;
118  
119 # This is cray-cray.
120 1 ▶ while(defined $content[-1] && $content[-1] !~ /^WriteMakefile\(/)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $content[-1] and not $content[-1] =~ /^WriteMakefile\(/u) 0 1 1
Condition33%1/3
defined $content[-1] and not $content[-1] =~ /^WriteMakefile\(/u
!ll&&!rl&&r
010
MC/DC0%0/2
defined $content[-1] and not $content[-1] =~ /^WriteMakefile\(/u
defined $content[-1] not $content[-1] =~ /^WriteMakefile\(/u
Truth table33%1/3
A and not(B)
A= defined $content[-1]B= not $content[-1] =~ /^WriteMakefile\(/u
ABresult
0X0
100
111
121 {
122 0 unshift @extra, pop @content;
123 }
124  
125 1 my $last = pop @content;
126  
127 1 ▶ if($last =~ /^WriteMakefile\(/)
Branch: 1 branch
BranchTrueFalseTotal
if ($last =~ /^WriteMakefile\(/u) { } 1 0 1
128 {
129 1 my @new;
130 1 ▶ while(defined $content[0] && $content[0] !~ /\%FallbackPrereqs/)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $content[0] and not $content[0] =~ /\%FallbackPrereqs/u) 25 1 26
Condition66%2/3
defined $content[0] and not $content[0] =~ /\%FallbackPrereqs/u
!ll&&!rl&&r
0125
MC/DC50%1/2
defined $content[0] and not $content[0] =~ /\%FallbackPrereqs/u
defined $content[0] not $content[0] =~ /\%FallbackPrereqs/u
Truth table66%2/3
A and not(B)
A= defined $content[0]B= not $content[0] =~ /\%FallbackPrereqs/u
ABresult
0X0
100
111
131 {
132 25 my $line = shift @content;
133  
134 25 ▶ if($test)
Branch: 1 branch
BranchTrueFalseTotal
if ($test) { } 0 25 25
135 {
136 # TODO: not exactly sure when the test order was fixed in EUMM.
137 # research and correct.
138 0 $line =~ s/use ExtUtils::MakeMaker;/use ExtUtils::MakeMaker 7.1001;/;
139 }
140 else
141 {
142 25 $line =~ s/use ExtUtils::MakeMaker;/use ExtUtils::MakeMaker 6.64;/;
143 }
144  
145 25 push @new, $line;
146 }
147  
148 1 ▶ eval $mod->content; ## no critic (BuiltinFunctions::ProhibitStringyEval)
Subroutine myWriteMakefile: not called CC=1 SCAR=0.0
149 1 ▶ $self->log_fatal("unable to eval inc/mymm.pl: $@") if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
150  
151 1 ▶ if(mymm->can('myWriteMakefile'))
Branch: 1 branch
BranchTrueFalseTotal
if ("mymm"->can("myWriteMakefile")) 1 0 1
152 {
153 1 $last = "mymm::my$last";
154 }
155  
156 1 @content = ( @new, $last, @extra );
157 }
158 else
159 {
160 0 $self->log_fatal("unable to find WriteMakefile in Makefile.PL");
161 }
162 }
163  
164  
165 2 ▶ if($config || $build || $test || $clean)
Branch: 1 branch
BranchTrueFalseTotal
if ($config or $build or $test or $clean) 0 2 2
Condition33%3/9
$config or $build or $test or $clean
l!l&&r!l&&!r
002
$config or $build or $test
l!l&&r!l&&!r
002
$config or $build
l!l&&r!l&&!r
002
MC/DC0%0/4
$config or $build or $test or $clean
$config $build $test $clean
Truth table20%1/5
A or B or C or D
A= $configB= $buildC= $testD= $clean
ABCDresult
1XXX1
01XX1
001X1
00011
00000
166 {
167 0 push @content, "{ package";
168 0 push @content, " MY;";
169 0 push @content, " sub postamble {";
170 0 push @content, " my \$postamble = '';";
171 0 push @content, '';
172 0 ▶ if($config)
Branch: 1 branch
BranchTrueFalseTotal
if ($config) 0 0 0
173 {
174 0 push @content, " \$postamble .=";
175 0 push @content, " \"config :: _mm/config\\n\" .";
176 0 push @content, " \"mymm-config _mm/config:\\n\" .";
177 0 push @content, " \"\\t\\\$(FULLPERL) inc/mymm-config.pl\\n\" .";
178 0 push @content, " \"\\t\\\$(NOECHO)\\\$(MKPATH) _mm\\n\" .";
179 0 push @content, " \"\\t\\\$(NOECHO)\\\$(TOUCH) _mm/config\\n\\n\";";
180 0 push @content, '';
181 }
182 0 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) 0 0 0
183 {
184 0 push @content, " \$postamble .=";
185 0 push @content, " \"pure_all :: mymm-build\\n\" .";
186 0 ▶ push @content, " \"mymm-build :@{[ $config ? ' _mm/config' : '' ]}\\n\" .";
Branch: 1 branch
BranchTrueFalseTotal
$config ? : 0 0 0
187 0 push @content, " \"\\t\\\$(FULLPERL) inc/mymm-build.pl\\n\\n\";";
188 0 push @content, '';
189 }
190 0 ▶ if($test)
Branch: 1 branch
BranchTrueFalseTotal
if ($test) 0 0 0
191 {
192 0 push @content, " \$postamble .=";
193 0 push @content, " \"subdirs-test_dynamic subdirs-test_static subdirs-test :: mymm-test\\n\" .";
194 0 push @content, " \"mymm-test :\\n\" .";
195 0 push @content, " \"\\t\\\$(FULLPERL) inc/mymm-test.pl\\n\\n\";";
196 0 push @content, '';
197 }
198 0 ▶ if($clean)
Branch: 1 branch
BranchTrueFalseTotal
if ($clean) 0 0 0
199 {
200 0 push @content, " \$postamble .=";
201 0 push @content, " \"clean :: mymm-clean\\n\" .";
202 0 push @content, " \"mymm-clean :\\n\" .";
203 0 push @content, " \"\\t\\\$(FULLPERL) inc/mymm-clean.pl\\n\" .";
204 0 push @content, " \"\\t\\\$(RM_RF) _mm\\n\\n\";";
205 0 push @content, '';
206 }
207 0 push @content, " \$postamble;";
208 0 push @content, " }";
209  
210 0 push @content, " sub special_targets {";
211 0 push @content, " my(\$self, \@therest) = \@_;";
212 0 push @content, " my \$st = \$self->SUPER::special_targets(\@therest);";
213 0 push @content, " \$st .= \"\\n.PHONY:";
214 0 ▶ $content[-1] .= " mymm-config" if $config;
Branch: 1 branch
BranchTrueFalseTotal
if $config 0 0 0
215 0 ▶ $content[-1] .= " mymm-build" if $build;
Branch: 1 branch
BranchTrueFalseTotal
if $build 0 0 0
216 0 ▶ $content[-1] .= " mymm-test" if $test;
Branch: 1 branch
BranchTrueFalseTotal
if $test 0 0 0
217 0 ▶ $content[-1] .= " mymm-clean" if $clean;
Branch: 1 branch
BranchTrueFalseTotal
if $clean 0 0 0
218 0 $content[-1] .= "\\n\";";
219 0 push @content, " \$st;";
220 0 push @content, " }";
221 0 push @content, "}";
222 }
223  
224 2 $file->content(join "\n", @content);
225  
226 2 return;
227 3 };
228  
229 2 ▶ around register_prereqs => sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
230 2 my($orig, $self, @args) = @_;
231 2 my $h = $self->$orig(@args);
232  
233 2 ▶ my $mod = first { $_->name eq 'inc/mymm.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
234 2 ▶ if($mod)
Branch: 1 branch
BranchTrueFalseTotal
if ($mod) 1 1 2
235 {
236 1 $self->zilla->register_prereqs(
237 { phase => 'configure' },
238 'ExtUtils::MakeMaker' => '6.64'
239 );
240 }
241  
242 2 ▶ my $test = first { $_->name eq 'inc/mymm-test.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
243 2 ▶ if($test)
Branch: 1 branch
BranchTrueFalseTotal
if ($test) 0 2 2
244 {
245 0 $self->zilla->register_prereqs(
246 { phase => 'configure' },
247 'ExtUtils::MakeMaker' => '7.1001'
248 );
249 }
250  
251 2 return;
252 3 };
253  
254 sub metadata
255 2 ▶ {
Subroutine metadata: called CC=2 SCAR=6.9
Pod undocumented
256 2 my($self) = @_;
257  
258 2 my %meta;
259  
260 2 ▶ my $mod = first { $_->name eq 'inc/mymm.pl' } $self->zilla->files->@*;
Subroutine __ANON__: called CC=1 SCAR=0.0
261  
262 2 ▶ $meta{dynamic_config} = 1 if $mod;
Branch: 1 branch
BranchTrueFalseTotal
if $mod 1 1 2
263  
264 2 \%meta;
265 }
266  
267 3 __PACKAGE__->meta->make_immutable;
268 }
269  
270 3 1;
271  
272 __END__
↑ Summary blib/lib/Dist/Zilla/PluginBundle/Author/Plicease.pm »