blib/lib/ADAMK/Release.pm

filter: Statementstmt 17.7% 62 / 349 Branchbran 0.0% 0 / 138 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 25.9% 20 / 77 Podpod 0.0% 0 / 57 totaltotal 12.4% 82 / 661 CC 82 SCAR 54.1
CC
82
Cov
12%
assemble
1056.0
sudo
42.0
shell
42.0
CRAP 224.1
↑ Summary
1 package ADAMK::Release;
2  
3 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use CPAN::Uploader 0.103003 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Devel::PPPort 3.21 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Spec::Functions 0.80 ':ALL';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Slurp 9999.19 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::Find::Rule 0.32 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::Flat 1.04 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use File::ShareDir 1.03 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use File::LocalizeNewlines 1.12 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use GitHub::Extract 0.02 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use IO::Prompt::Tiny 0.002 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Module::Extract::VERSION 1.01 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Params::Util 1.00 ':ALL';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Term::ReadKey 2.14 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use YAML::Tiny 1.51 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 our $VERSION = '0.02';
23  
24 1 ▶use constant TOOLS => qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
25 cat
26 chmod
27 make
28 touch
29 sudo
30 bash
31 1 };
32  
33 1 ▶use Object::Tiny 1.01 qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
34 module
35 github
36 verbose
37 release
38 no_rt
39 no_changes
40 no_copyright
41 no_test
42 1 }, map { "bin_$_" } TOOLS;
43  
44  
45  
46  
47  
48  
49 ######################################################################
50 # Constructor
51  
52 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
53 0 my $self = shift->SUPER::new(@_);
54  
55 # Check module
56 0 ▶ unless ( _CLASS($self->module) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_CLASS(scalar $self->module)) 0 0 0
57 0 $self->error("Missing or invalid module");
58 }
59  
60 # Inflate and check the github object
61 0 ▶ if ( Params::Util::_HASH($self->github) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&Params::Util::_HASH(scalar $self->github)) 0 0 0
62 0 $self->{github} = GitHub::Extract->new( %{$self->github} );
63 }
64 0 ▶ unless ( Params::Util::_INSTANCE($self->github, 'GitHub::Extract')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&Params::Util::_INSTANCE(scalar $self->github, "GitHub::Extract")) 0 0 0
65 0 $self->error("Missing or invalid GitHub specification");
66 }
67  
68 # Release options
69 0 $self->{release} = !!$self->{release};
70  
71 # Find all of the command line tools
72 0 foreach my $tool ( TOOLS ) {
73 0 $self->{ "bin_" . $tool } = $self->which($tool);
74 }
75  
76 0 return $self;
77 }
78  
79  
80  
81  
82  
83 ######################################################################
84 # Command Methods
85  
86 0 ▶sub run {
Subroutine run: not called CC=3 SCAR=24.8
Pod undocumented
87 0 my $self = shift;
88  
89 # Export from GitHub and change to the directory
90 0 my $pushd = $self->github->pushd;
91 0 ▶ unless ( $pushd ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pushd) 0 0 0
92 0 $self->error(
93 "Failed to download and extract %s: %s",
94 $self->github->url,
95 $self->github->error,
96 );
97 }
98  
99 # This is total bulldozer coding, there is no reason whatsoever why
100 # this stuff should be in seperate methods except that it provides
101 # a little cleaner logical breakup, and maybe I want to subclass this
102 # someday or something.
103 0 $self->validate;
104 0 $self->assemble;
105 0 $self->build;
106  
107 # Release the distribution
108 0 ▶ $self->upload if $self->release;
Branch: 1 branch
BranchTrueFalseTotal
if $self->release 0 0 0
109  
110 0 return;
111 }
112  
113 0 ▶sub validate {
Subroutine validate: not called CC=4 SCAR=30.0
Pod undocumented
114 0 my $self = shift;
115  
116 0 ▶ unless ( $self->dist_version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dist_version) 0 0 0
117 0 $self->error("Failed to find version number in main module");
118 }
119 0 ▶ unless ( $self->makefile_pl or $self->build_pl ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->makefile_pl or $self->build_pl) 0 0 0
Condition0%0/3
$self->makefile_pl or $self->build_pl
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->makefile_pl or $self->build_pl
$self->makefile_pl $self->build_pl
Truth table0%0/3
A or B
A= $self->makefile_plB= $self->build_pl
ABresult
1X1
011
000
120 0 $self->error("Failed to find Makefile.PL or Build.PL");
121 }
122  
123 0 return;
124 }
125  
126 0 ▶sub assemble {
Subroutine assemble: not called CC=32 SCAR=69.6
Pod undocumented
127 0 my $self = shift;
128  
129 # Create MANIFEST.SKIP
130 0 ▶ if ( -f $self->dist_manifest_add ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $self->dist_manifest_add) { } 0 0 0
elsif (not -f $self->dist_manifest) { } 0 0 0
131 0 $self->shell(
132 $self->bin_cat,
133 $self->shared_manifest_skip,
134 $self->dist_manifest_add,
135 '>',
136 $self->dist_manifest_skip,
137 "Failed to merge common MANIFEST.SKIP with extra one",
138 );
139  
140 } elsif ( not -f $self->dist_manifest ) {
141 0 $self->copy( $self->shared_manifest_skip => $self->dist_manifest_skip );
142 }
143  
144 # Apply a default LICENSE file
145 0 ▶ unless ( -f $self->dist_license ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->dist_license) 0 0 0
146 0 $self->copy( $self->shared_license => $self->dist_license );
147 }
148  
149 # Add ppport.h if any XS files use it
150 0 ▶ if ( $self->find_ppport->in( $self->dist_dir ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->find_ppport->in($self->dist_dir)) 0 0 0
151 0 Devel::PPPort::WriteFile( $self->dist_ppport );
152 }
153  
154 # Copy in author tests as needed
155 0 ▶ unless ( -f $self->dist_99_author ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->dist_99_author) 0 0 0
156 0 foreach my $xt ( qw{ pod.t pmv.t } ) {
157 0 ▶ next if -f catfile( $self->dist_xt, $xt );
Branch: 1 branch
BranchTrueFalseTotal
if -f catfile($self->dist_xt, $xt) 0 0 0
158 0 $self->copy(
159 catfile( $self->shared_dir, $xt ),
160 catfile( $self->dist_xt, $xt ),
161 );
162 }
163 }
164  
165 # Create the README file
166 0 ▶ unless ( -f $self->dist_readme ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->dist_readme) 0 0 0
167 0 my $dist_readme = $self->dist_readme;
168 0 ▶ my $module_pod = -f $self->module_pod ? $self->module_pod : $self->module_pm;
Branch: 1 branch
BranchTrueFalseTotal
-f $self->module_pod ? : 0 0 0
169 0 $self->shell(
170 $self->bin_cat,
171 $module_pod,
172 "| pod2text >",
173 $dist_readme,
174 "Error while generating README file '$dist_readme'",
175 )
176 }
177  
178 # Localise all newlines in text files
179 0 $self->file_localize->localize( $self->dist_dir );
180
181 # Check for various unsafe things in Makefile.PL
182 0 ▶ if ( $self->makefile_pl ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->makefile_pl) 0 0 0
183 0 ▶ if ( $self->makefile_pl =~ /use inc::Module::Install/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->makefile_pl =~ /use inc::Module::Install/) { } 0 0 0
184 0 ▶ if ( $self->makefile_pl =~ /\bauto_install\b/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->makefile_pl =~ /\bauto_install\b/) 0 0 0
185 0 $self->error("Makefile.PL contains dangerous auto_install");
186 }
187 } else {
188 0 ▶ unless ( $self->makefile_pl =~ /use strict/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->makefile_pl =~ /use strict/) 0 0 0
189 0 $self->error("Makefile.PL does not use strict");
190 }
191 0 ▶ unless ( $self->makefile_pl =~ /(?:use|require) \d/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->makefile_pl =~ /(?:use|require) \d/) 0 0 0
192 0 $self->error("Makefile.PL does not declare a minimum Perl version");
193 }
194 }
195 }
196  
197 # Check file permissions
198 0 foreach my $file ( sort $self->find_0644->in( $self->dist_dir ) ) {
199 0 my $mode = (stat($file))[2] & 07777;
200 0 ▶ next if $mode == 0644;
Branch: 1 branch
BranchTrueFalseTotal
if $mode == 420 0 0 0
201 0 $self->shell(
202 $self->bin_chmod,
203 '0644',
204 $file,
205 "Error setting $file to 0644 permissions",
206 );
207 }
208  
209 # Make sure exe files are marked with executable permissions
210 0 ▶ if ( $self->find_executable->in( $self->dist_dir ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->find_executable->in($self->dist_dir)) 0 0 0
211 0 $self->error("Found at least one .exe file without -x unix permissions");
212 }
213  
214 # Check the Changes file
215 0 ▶ unless ( $self->no_changes ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->no_changes) 0 0 0
216 # Read in the Changes file
217 0 ▶ unless ( -f $self->dist_changes ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->dist_changes) 0 0 0
218 0 $self->error("Distribution does not have a Changes file");
219 }
220 0 ▶ unless ( open( CHANGES, $self->dist_changes ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open CHANGES, $self->dist_changes) 0 0 0
221 0 $self->error("Failed to open Changes file");
222 }
223 0 my @lines = <CHANGES>;
224 0 close CHANGES;
225 0 ▶ unless ( @lines >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@lines >= 3) 0 0 0
226 0 $self->error("Changes file is empty or too small");
227 }
228  
229 # The Changes version should be the first thing on the third line
230 0 my $current = $lines[2];
231 0 my ($version) = split /\s+/, $current;
232 0 ▶ unless ( $version =~ /[\d\._]{3}/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($version =~ /[\d\._]{3}/) 0 0 0
233 0 $self->error(
234 "Failed to find current version, or too short, in '%2'",
235 $current,
236 );
237 }
238  
239 # Does it match the version in the main module
240 0 ▶ unless ( $version eq $self->dist_version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($version eq $self->dist_version) 0 0 0
241 0 $self->error(
242 "Version in Changes file (%s) does not match module version (%s)",
243 $version,
244 $self->dist_version,
245 );
246 }
247 }
248  
249 # Check that the main module documentation Copyright is the current year
250 0 ▶ unless ( $self->no_copyright ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->no_copyright) 0 0 0
251 # Read the file
252 0 ▶ unless ( open( MODULE, $self->module_doc ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open MODULE, $self->module_doc) 0 0 0
253 0 $self->error(
254 "Failed to open '%s'",
255 $self->module_doc,
256 );
257 }
258 0 my @lines = <MODULE>;
259 0 close MODULE;
260  
261 # Look for the current year
262 0 my $year = 1900 + (localtime time)[5];
263 0 ▶ unless ( grep { /copyright/i and /$year/ } @lines ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {/copyright/i and /$year/;} @lines) 0 0 0
Condition0%0/3
/copyright/i && /$year/
!ll&&!rl&&r
000
MC/DC0%0/2
/copyright/i && /$year/
/copyright/i /$year/
Truth table0%0/3
A && B
A= /copyright/iB= /$year/
ABresult
0X0
100
111
264 0 $self->error("Missing Copyright, or does not refer to current year");
265 }
266  
267 # Merge the module to a single string
268 0 my $merged = join "\n", @lines;
269 0 ▶ unless ( $self->no_rt ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->no_rt) 0 0 0
270 0 my $dist_name = $self->dist;
271 0 ▶ unless ( $merged =~ /L\<http\:\/\/rt\.cpan\.org\/.+?=([\w-]+)\>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($merged =~ m[L\<http\://rt\.cpan\.org/.+?=([\w-]+)\>]) 0 0 0
272 0 $self->error("Failed to find a link to the public RT queue");
273 }
274 0 ▶ unless ( $dist_name eq $1 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist_name eq $1) 0 0 0
275 0 $self->error("Expected a public link to $dist_name RT queue, but found a link to the $1 queue");
276 }
277 }
278 }
279  
280 # Touch all files to correct any potential time skews
281 0 foreach my $file ( $self->find_files->in( $self->dist_dir ) ) {
282 0 $self->shell(
283 $self->bin_touch,
284 $file,
285 "Error while touching $file to prevent clock skew",
286 );
287 }
288  
289 0 return;
290 }
291  
292 0 ▶sub build {
Subroutine build: not called CC=4 SCAR=30.0
Pod undocumented
293 0 my $self = shift;
294  
295 # Prevent environment variables from outside this script
296 # infecting the way we build things inside here.
297 0 local $ENV{AUTOMATED_TESTING} = '';
298 0 local $ENV{RELEASE_TESTING} = '';
299  
300 # Run either of the build protocols
301 0 ▶ if ( $self->makefile_pl ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->makefile_pl) { } 0 0 0
elsif ($self->build_pl) { } 0 0 0
302 0 $self->build_make;
303  
304 } elsif ( $self->build_pl ) {
305 0 $self->build_perl;
306  
307 } else {
308 0 $self->error("Module does not have a Makefile.PL or Build.PL");
309 }
310  
311 # Double check that the build produced a tarball where we expect it to be
312 0 ▶ unless ( -f $self->dist_tardist ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->dist_tardist) 0 0 0
313 0 $self->error(
314 "Failed to create tardist at '%s'",
315 $self->dist_tardist,
316 );
317 }
318  
319 0 return;
320 }
321  
322 0 ▶sub build_make {
Subroutine build_make: not called CC=2 SCAR=17.9
Pod undocumented
323 0 my $self = shift;
324  
325 # Create the Makefile and MANIFEST
326 0 $self->build_makefile;
327 0 $self->build_makefile_manifest;
328  
329 0 ▶ unless ( $self->no_test ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->no_test) 0 0 0
330 # Test the distribution normally
331 0 $self->shell(
332 $self->bin_make,
333 'disttest',
334 'disttest failed',
335 );
336  
337 # Test with AUTOMATED_TESTING on
338 SCOPE: {
339 0 local $ENV{AUTOMATED_TESTING} = 1;
340 0 $self->build_makefile;
341 0 $self->shell(
342 $self->bin_make,
343 "disttest",
344 'disttest failed',
345 );
346 }
347  
348 # Test with RELEASE_TESTING on
349 SCOPE: {
350 0 local $ENV{RELEASE_TESTING} = 1;
351 0 $self->build_makefile;
352 0 $self->shell(
353 $self->bin_make,
354 "disttest",
355 'disttest failed',
356 );
357 }
358  
359 # Test with RELEASE_TESTING and root permissions.
360 # This catches bad test script assumptions in modules related
361 # to files and permissions (File::Remove, File::Flat etc).
362 SCOPE: {
363 0 local $ENV{RELEASE_TESTING} = 1;
364 0 $self->sudo(
365 qw{ perl Makefile.PL },
366 'Error while creating Makefile',
367 );
368 0 $self->sudo(
369 $self->bin_make,
370 "disttest",
371 'disttest failed',
372 );
373  
374 # Clean up leftover root files and rebuild from scratch
375 0 $self->build_realclean;
376 0 $self->build_makefile;
377 0 $self->build_makefile_manifest;
378  
379 # Run the test suite one last time to make sure we
380 # didn't break anything.
381 0 $self->sudo(
382 $self->bin_make,
383 "disttest",
384 'disttest failed',
385 );
386  
387 # Clean up the leftover root files again
388 0 $self->build_realclean;
389 }
390 }
391  
392 # Create the Makefile and MANIFEST
393 0 $self->build_makefile;
394 0 $self->build_makefile_manifest;
395  
396 # Build the tardist
397 0 $self->shell(
398 $self->bin_make,
399 "tardist",
400 'Error making distribution tarball',
401 );
402  
403 0 return;
404 }
405  
406 0 ▶sub build_makefile {
Subroutine build_makefile: not called CC=5 SCAR=34.0
Pod undocumented
407 0 my $self = shift;
408  
409 # Execute Makefile.PL with the current environment's perl
410 0 $self->shell(
411 qw{ perl Makefile.PL },
412 'Error while creating Makefile',
413 );
414  
415 # Add the build-system-specific elements to the META.yml
416 0 my $meta = YAML::Tiny->read( $self->dist_meta_yml );
417 0 ▶ return unless defined $meta;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $meta 0 0 0
418  
419 # Add the resources
420 0 my $save = 0;
421 0 ▶ unless ( $meta->[0]->{resources} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($meta->[0]{"resources"}) 0 0 0
422 0 $meta->[0]->{resources} = {};
423 0 $save = 1;
424 }
425 0 ▶ unless ( $meta->[0]->{resources}->{repository} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($meta->[0]{"resources"}{"repository"}) 0 0 0
426 0 $meta->[0]->{resources}->{repository} = $self->dist_resource_repository;
427 0 $save = 1;
428 }
429 0 ▶ if ( $save ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($save) 0 0 0
430 0 $meta->write( $self->dist_meta_yml );
431 }
432  
433 0 return;
434 }
435  
436 0 ▶sub build_makefile_manifest {
Subroutine build_makefile_manifest: not called CC=1 SCAR=6.9
Pod undocumented
437 0 my $self = shift;
438  
439 0 $self->shell(
440 $self->bin_make,
441 "manifest",
442 "Error while creating the MANIFEST",
443 );
444 }
445  
446 0 ▶sub build_realclean {
Subroutine build_realclean: not called CC=1 SCAR=6.9
Pod undocumented
447 0 my $self = shift;
448  
449 # Clean up the distribution (always with root)
450 0 $self->sudo(
451 $self->bin_make,
452 "realclean",
453 'sudo make clean failed',
454 );
455 0 $self->remove( $self->dist_manifest );
456 }
457  
458 0 ▶sub build_perl {
Subroutine build_perl: not called CC=2 SCAR=17.9
Pod undocumented
459 0 my $self = shift;
460  
461 # Create the Build file
462 0 $self->shell(
463 qw{ perl Build.PL },
464 'Error while creating Makefile',
465 );
466  
467 # Create the MANIFEST file
468 0 $self->shell(
469 "./Build",
470 "manifest",
471 'Error while creating the MANIFEST',
472 );
473  
474 0 ▶ unless ( $self->no_test ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->no_test) 0 0 0
475 # Test the distribution normally
476 0 $self->shell(
477 qw{ ./Build disttest },
478 'disttest failed',
479 );
480 }
481  
482 # Build the tardist
483 $self->shell(
484 0 qw{ ./Build dist },
485 'Error making distribution tarball',
486 );
487  
488 0 return;
489 }
490  
491 0 ▶sub upload {
Subroutine upload: not called CC=5 SCAR=34.0
Pod undocumented
492 0 my $self = shift;
493  
494 0 my $pauseid = $self->prompt("PAUSEID:");
495 0 ▶ unless (_STRING($pauseid) and $pauseid =~ /^[A-Z]{3,}$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_STRING($pauseid) and $pauseid =~ /^[A-Z]{3,}$/) 0 0 0
Condition0%0/3
&_STRING($pauseid) and $pauseid =~ /^[A-Z]{3,}$/
!ll&&!rl&&r
000
MC/DC0%0/2
&_STRING($pauseid) and $pauseid =~ /^[A-Z]{3,}$/
&_STRING($pauseid) $pauseid =~ /^[A-Z]{3,}$/
Truth table0%0/3
A and B
A= &_STRING($pauseid)B= $pauseid =~ /^[A-Z]{3,}$/
ABresult
0X0
100
111
496 0 $self->error("Missing or invalid PAUSEID");
497 }
498  
499 0 my $password = $self->password("Password:");
500 0 ▶ unless (_STRING($password) and $password =~ /^\S{5,}$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_STRING($password) and $password =~ /^\S{5,}$/) 0 0 0
Condition0%0/3
&_STRING($password) and $password =~ /^\S{5,}$/
!ll&&!rl&&r
000
MC/DC0%0/2
&_STRING($password) and $password =~ /^\S{5,}$/
&_STRING($password) $password =~ /^\S{5,}$/
Truth table0%0/3
A and B
A= &_STRING($password)B= $password =~ /^\S{5,}$/
ABresult
0X0
100
111
501 0 $self->error("Missing or invalid CPAN password");
502 }
503  
504 # Execute the upload to CPAN
505 0 CPAN::Uploader->upload_file( $self->dist_tardist, {
506 user => $pauseid,
507 password => $password,
508 });
509 }
510  
511  
512  
513  
514  
515 ######################################################################
516 # Content and Scanning Methods
517  
518 # Get the main github repository url for this release
519 0 ▶sub dist_resource_repository {
Subroutine dist_resource_repository: not called CC=1 SCAR=6.9
Pod undocumented
520 0 my $self = shift;
521  
522 0 return join( '',
523 "https://github.com/",
524 $self->github->username,
525 $self->github->repository,
526 '.git',
527 );
528 }
529  
530 0 ▶sub makefile_pl {
Subroutine makefile_pl: not called CC=3 SCAR=24.8
Pod undocumented
531 0 my $self = shift;
532 0 ▶ unless ( defined $self->{makefile_pl} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"makefile_pl"}) 0 0 0
533 0 my $file = $self->dist_makefile_pl;
534 0 ▶ return undef unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 0 0 0
535 0 $self->{makefile_pl} = File::Slurp::read_file($file);
536 }
537 0 return $self->{makefile_pl};
538 }
539  
540 0 ▶sub build_pl {
Subroutine build_pl: not called CC=3 SCAR=24.8
Pod undocumented
541 0 my $self = shift;
542 0 ▶ unless ( defined $self->{build_pl} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"build_pl"}) 0 0 0
543 0 my $file = $self->dist_build_pl;
544 0 ▶ return undef unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 0 0 0
545 0 $self->{build_pl} = File::Slurp::read_file($file);
546 }
547 0 return $self->{build_pl};
548 }
549  
550 0 ▶sub module_doc {
Subroutine module_doc: not called CC=3 SCAR=24.8
Pod undocumented
551 0 my $self = shift;
552 0 ▶ unless ( exists $self->{module_doc} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"module_doc"}) 0 0 0
553 0 ▶ if ( -f $self->module_pod ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $self->module_pod) { } 0 0 0
554 0 $self->{module_doc} = $self->module_pod;
555 } else {
556 0 $self->{module_doc} = $self->module_pm;
557 }
558 }
559 0 return $self->{module_doc};
560 }
561  
562 0 ▶sub module_version {
Subroutine module_version: not called CC=4 SCAR=30.0
Pod undocumented
563 0 my $self = shift;
564 0 ▶ unless ( $self->{module_version} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"module_version"}) 0 0 0
565 0 my $file = $self->module_pm;
566 0 my $version = Module::Extract::VERSION->parse_version_safely($file);
567 0 ▶ unless ( $version and $version ne 'undef' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($version and $version ne "undef") 0 0 0
Condition0%0/3
$version and $version ne "undef"
!ll&&!rl&&r
000
MC/DC0%0/2
$version and $version ne "undef"
$version $version ne "undef"
Truth table0%0/3
A and B
A= $versionB= $version ne "undef"
ABresult
0X0
100
111
568 0 return undef;
569 }
570 0 $self->{module_version} = $version;
571 }
572 0 return $self->{module_version};
573 }
574  
575 0 ▶sub find_ppport {
Subroutine find_ppport: not called CC=1 SCAR=6.9
Pod undocumented
576 0 File::Find::Rule->name('*.xs')->file->grep(qr/\bppport\.h\b/);
577 }
578  
579 0 ▶sub find_files {
Subroutine find_files: not called CC=1 SCAR=6.9
Pod undocumented
580 0 File::Find::Rule->file;
581 }
582  
583 0 ▶sub find_0644 {
Subroutine find_0644: not called CC=1 SCAR=6.9
Pod undocumented
584 0 File::Find::Rule->name(qw{
585 Changes
586 Makefile.PL
587 META.yml
588 *.t
589 *.pm
590 *.pod
591 } )->file;
592 }
593  
594 0 ▶sub find_executable {
Subroutine find_executable: not called CC=1 SCAR=6.9
Pod undocumented
595 0 File::Find::Rule->name('*.exe')->not_executable->file;
596 }
597  
598 0 ▶sub find_localize {
Subroutine find_localize: not called CC=1 SCAR=6.9
Pod undocumented
599 0 File::Find::Rule->file->not_binary->writable;
600 }
601  
602 0 ▶sub file_localize {
Subroutine file_localize: not called CC=1 SCAR=6.9
Pod undocumented
603 0 File::LocalizeNewlines->new(
604 filter => $_[0]->find_localize,
605 verbose => 1,
606 );
607 }
608  
609  
610  
611  
612  
613 ######################################################################
614 # Paths and Files
615  
616 0 ▶sub dist {
Subroutine dist: not called CC=1 SCAR=6.9
Pod undocumented
617 0 my $self = shift;
618 0 my $dist = $self->module;
619 0 $dist =~ s/::/-/g;
620 0 return $dist;
621 }
622  
623 0 ▶sub dist_dir {
Subroutine dist_dir: not called CC=1 SCAR=6.9
Pod undocumented
624 0 curdir();
625 }
626  
627 0 ▶sub dist_tardist {
Subroutine dist_tardist: not called CC=1 SCAR=6.9
Pod undocumented
628 0 $_[0]->dist_file;
629 }
630  
631 0 ▶sub dist_file {
Subroutine dist_file: not called CC=1 SCAR=6.9
Pod undocumented
632 0 $_[0]->dist . '-' . $_[0]->dist_version . '.tar.gz';
633 }
634  
635 0 ▶sub dist_version {
Subroutine dist_version: not called CC=1 SCAR=6.9
Pod undocumented
636 0 $_[0]->module_version;
637 }
638  
639 0 ▶sub dist_makefile_pl {
Subroutine dist_makefile_pl: not called CC=1 SCAR=6.9
Pod undocumented
640 0 'Makefile.PL';
641 }
642  
643 0 ▶sub dist_build_pl {
Subroutine dist_build_pl: not called CC=1 SCAR=6.9
Pod undocumented
644 0 'Build.PL';
645 }
646  
647 0 ▶sub dist_changes {
Subroutine dist_changes: not called CC=1 SCAR=6.9
Pod undocumented
648 0 'Changes';
649 }
650  
651 0 ▶sub dist_license {
Subroutine dist_license: not called CC=1 SCAR=6.9
Pod undocumented
652 0 'LICENSE';
653 }
654  
655 0 ▶sub dist_readme {
Subroutine dist_readme: not called CC=1 SCAR=6.9
Pod undocumented
656 0 'README';
657 }
658  
659 0 ▶sub dist_meta_yml {
Subroutine dist_meta_yml: not called CC=1 SCAR=6.9
Pod undocumented
660 0 'META.yml';
661 }
662  
663 0 ▶sub dist_manifest {
Subroutine dist_manifest: not called CC=1 SCAR=6.9
Pod undocumented
664 0 'MANIFEST';
665 }
666  
667 0 ▶sub dist_manifest_skip {
Subroutine dist_manifest_skip: not called CC=1 SCAR=6.9
Pod undocumented
668 0 'MANIFEST.SKIP';
669 }
670  
671 0 ▶sub dist_manifest_add {
Subroutine dist_manifest_add: not called CC=1 SCAR=6.9
Pod undocumented
672 0 'MANIFEST.SKIP.add';
673 }
674  
675 0 ▶sub dist_ppport {
Subroutine dist_ppport: not called CC=1 SCAR=6.9
Pod undocumented
676 0 'ppport.h';
677 }
678  
679 0 ▶sub dist_t {
Subroutine dist_t: not called CC=1 SCAR=6.9
Pod undocumented
680 0 't';
681 }
682  
683 0 ▶sub dist_data {
Subroutine dist_data: not called CC=1 SCAR=6.9
Pod undocumented
684 0 catdir('t', 'data');
685 }
686  
687 0 ▶sub dist_99_author {
Subroutine dist_99_author: not called CC=1 SCAR=6.9
Pod undocumented
688 0 catfile('t', '99_author.t');
689 }
690  
691 0 ▶sub dist_xt {
Subroutine dist_xt: not called CC=1 SCAR=6.9
Pod undocumented
692 0 'xt';
693 }
694  
695 0 ▶sub module_pm {
Subroutine module_pm: not called CC=1 SCAR=6.9
Pod undocumented
696 0 catfile( 'lib', $_[0]->module_subpath ) . '.pm';
697 }
698  
699 0 ▶sub module_pod {
Subroutine module_pod: not called CC=1 SCAR=6.9
Pod undocumented
700 0 catfile( 'lib', $_[0]->module_subpath ) . '.pod';
701 }
702  
703 0 ▶sub module_subpath {
Subroutine module_subpath: not called CC=1 SCAR=6.9
Pod undocumented
704 0 catdir( split /::/, $_[0]->module );
705 }
706  
707 0 ▶sub shared_manifest_skip {
Subroutine shared_manifest_skip: not called CC=1 SCAR=6.9
Pod undocumented
708 0 catfile( $_[0]->shared_dir, 'MANIFEST.SKIP' );
709 }
710  
711 0 ▶sub shared_license {
Subroutine shared_license: not called CC=1 SCAR=6.9
Pod undocumented
712 0 catfile( $_[0]->shared_dir, 'LICENSE' );
713 }
714  
715 0 ▶sub shared_dir {
Subroutine shared_dir: not called CC=2 SCAR=17.9
Pod undocumented
716 0 ▶ File::ShareDir::dist_dir('ADAMK-Release')
Branch: 1 branch
BranchTrueFalseTotal
File::ShareDir::dist_dir("ADAMK-Release") or $_[0]->error("Failed to find share directory") 0 0 0
717 or $_[0]->error("Failed to find share directory");
718 }
719  
720  
721  
722  
723 ######################################################################
724 # Support Methods
725  
726 # Is a particular program installed, and where
727 0 ▶sub which {
Subroutine which: not called CC=4 SCAR=30.0
Pod undocumented
728 0 my $self = shift;
729 0 my $program = shift;
730 0 my ($location) = (`which $program`);
731 0 chomp $location;
732 0 ▶ unless ( $location ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($location) 0 0 0
733 0 $self->error("Can't find the required program '$program'. Please install it");
734 }
735 0 ▶ unless ( -r $location and -x $location ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-r $location and -x $location) 0 0 0
Condition0%0/3
-r $location and -x $location
!ll&&!rl&&r
000
MC/DC0%0/2
-r $location and -x $location
-r $location -x $location
Truth table0%0/3
A and B
A= -r $locationB= -x $location
ABresult
0X0
100
111
736 0 $self->error("The required program '$program' is installed, but I do not have permission to read or execute it");
737 }
738 0 return $location;
739 }
740  
741 0 ▶sub copy {
Subroutine copy: not called CC=2 SCAR=17.9
Pod undocumented
742 0 my $self = shift;
743 0 my $from = shift;
744 0 my $to = shift;
745 0 ▶ File::Flat->copy( $from => $to ) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
"File::Flat"->copy($from, $to) and return 1 0 0 0
746 0 $self->error("Failed to copy '$from' to '$to'");
747 }
748  
749 0 ▶sub move {
Subroutine move: not called CC=2 SCAR=17.9
Pod undocumented
750 0 my $self = shift;
751 0 my $from = shift;
752 0 my $to = shift;
753 0 ▶ File::Flat->copy( $from => $to ) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
"File::Flat"->copy($from, $to) and return 1 0 0 0
754 0 $self->error("Failed to move '$from' to '$to'");
755 }
756  
757 0 ▶sub remove {
Subroutine remove: not called CC=2 SCAR=17.9
Pod undocumented
758 0 my $self = shift;
759 0 my $path = shift;
760 0 ▶ if ( -e $path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $path) 0 0 0
761 0 $self->sudo(
762 "rm -rf $path",
763 "Failed to remove '$path'"
764 );
765 }
766 0 return 1;
767 }
768  
769 0 ▶sub sudo {
Subroutine sudo: not called CC=6 SCAR=37.4
Pod undocumented
770 0 my $self = shift;
771 0 my $message = pop @_;
772 0 my $cmd = join ' ', @_;
773 my $env = $self->env(
774 ADAMK_RELEASE => 1,
775 RELEASE_TESTING => $ENV{RELEASE_TESTING} ? 1 : 0,
776 0 ▶ AUTOMATED_TESTING => $ENV{AUTOMATED_TESTING} ? 1 : 0,
Branch: 2 branches
BranchTrueFalseTotal
$ENV{'RELEASE_TESTING'} ? : 0 0 0
$ENV{'AUTOMATED_TESTING'} ? : 0 0 0
777 );
778 0 ▶ print "> (sudo) $cmd\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 0 0
779 0 my $sudo = $self->bin_sudo;
780 0 my $rv = ! system( "$sudo bash -c '$env $cmd'" );
781 0 ▶ if ( $rv or ! @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv or not @_) 0 0 0
Condition0%0/3
$rv or not @_
l!l&&r!l&&!r
000
MC/DC0%0/2
$rv or not @_
$rv not @_
Truth table0%0/3
A or not(B)
A= $rvB= not @_
ABresult
1X1
011
000
782 0 return $rv;
783 }
784 0 $self->error($message);
785 }
786  
787 0 ▶sub shell {
Subroutine shell: not called CC=6 SCAR=37.4
Pod undocumented
788 0 my $self = shift;
789 0 my $message = pop @_;
790 0 my $cmd = join ' ', @_;
791 my $env = $self->env(
792 ADAMK_RELEASE => 1,
793 RELEASE_TESTING => $ENV{RELEASE_TESTING} ? 1 : 0,
794 0 ▶ AUTOMATED_TESTING => $ENV{AUTOMATED_TESTING} ? 1 : 0,
Branch: 2 branches
BranchTrueFalseTotal
$ENV{'RELEASE_TESTING'} ? : 0 0 0
$ENV{'AUTOMATED_TESTING'} ? : 0 0 0
795 );
796 0 ▶ print "> $cmd\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 0 0
797 0 my $rv = ! system( "$env $cmd" );
798 0 ▶ if ( $rv or ! @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv or not @_) 0 0 0
Condition0%0/3
$rv or not @_
l!l&&r!l&&!r
000
MC/DC0%0/2
$rv or not @_
$rv not @_
Truth table0%0/3
A or not(B)
A= $rvB= not @_
ABresult
1X1
011
000
799 0 return $rv;
800 }
801 0 $self->error($message);
802 }
803  
804 0 ▶sub env {
Subroutine env: not called CC=1 SCAR=6.9
Pod undocumented
805 0 my $self = shift;
806 0 my %env = @_;
807 0 join ' ', map { "$_=$env{$_}" } sort keys %env;
808 }
809  
810 0 ▶sub error {
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
811 0 my $self = shift;
812 0 my $message = sprintf(shift, @_);
813 0 Carp::croak($message);
814 }
815  
816 0 ▶sub prompt {
Subroutine prompt: not called CC=1 SCAR=6.9
Pod undocumented
817 0 my $self = shift;
818 0 return IO::Prompt::Tiny::prompt(@_);
819 }
820  
821 0 ▶sub password {
Subroutine password: not called CC=3 SCAR=24.8
Pod undocumented
822 0 my $self = shift;
823 0 my $password = undef;
824 0 ▶ if ( defined $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
825 0 print "$_[0] ";
826 }
827 0 eval {
828 0 Term::ReadKey::ReadMode('noecho');
829 0 $password = <STDIN>;
830 };
831 0 Term::ReadKey::ReadMode(0);
832 0 ▶ return undef if not defined $password;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $password 0 0 0
833 0 chomp($password);
834 0 return $password;
835 }
836  
837 1 1;
838  
839 __END__
↑ Summary