blib/lib/Dist/Zilla/Plugin/LatestPrereqs.pm

filter: Statementstmt 37.7% 17 / 45 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 32.3% 23 / 71 CC 11 SCAR 44.5
CC
11
Cov
28%
register_prereqs
132.0
_startup_cpan
2.0
BEGIN
1.0
CRAP 85.8
↑ Summary
1 package Dist::Zilla::Plugin::LatestPrereqs;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Dist::Zilla::Plugin::LatestPrereqs::VERSION = '0.4';
4 }
5  
6 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use CPAN;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Module::CoreList;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 with 'Dist::Zilla::Role::PrereqSource';
10  
11 1 has 'skip_core_modules' => (
12 is => 'ro',
13 isa => 'Bool',
14 default => 0,
15 );
16  
17  
18 0 ▶sub register_prereqs {
Subroutine register_prereqs: not called CC=11 SCAR=48.8
Pod documented
19 0 my ($self) = @_;
20 0 my $zilla = $self->zilla;
21 0 my $skip_core = $self->skip_core_modules;
22  
23 0 my $prereqs = $zilla->prereqs;
24 0 my $cpan = _startup_cpan();
25  
26 0 ▶ my $guts = $prereqs->cpan_meta_prereqs->{prereqs} || {};
Condition0%0/2
$prereqs->cpan_meta_prereqs->{'prereqs'} || {}
l!l
00
MC/DC0%0/1
$prereqs->cpan_meta_prereqs->{'prereqs'} || {}
$prereqs->cpan_meta_prereqs->{'prereqs'}
Truth table0%0/2
A
A= $prereqs->cpan_meta_prereqs->{'prereqs'}
Aresult
11
00
27  
28 0 for my $phase (keys %$guts) {
29 0 for my $type (keys %{$guts->{$phase}}) {
30 0 my $prereqs = $guts->{$phase}{$type}->as_string_hash;
31  
32 0 for my $module (keys %$prereqs) {
33 0 $self->log_debug("Check '$module', type '$type' phase '$phase'");
34 ## allow for user defined required version
35 0 ▶ next if $prereqs->{$module};
Branch: 1 branch
BranchTrueFalseTotal
if $prereqs->{$module} 0 0 0
36  
37 0 ▶ if ($skip_core) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip_core) 0 0 0
38 0 my $rel = Module::CoreList->first_release($module);
39 0 ▶ if ($rel && $rel <= $]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rel and $rel <= $]) 0 0 0
Condition0%0/3
$rel and $rel <= $]
!ll&&!rl&&r
000
MC/DC0%0/2
$rel and $rel <= $]
$rel $rel <= $]
Truth table0%0/3
A and B
A= $relB= $rel <= $]
ABresult
0X0
100
111
40 0 $self->log_debug("Skipping core module $module ($rel <= $])");
41 0 next;
42 }
43 }
44  
45 ## fetch latest version
46 0 $self->log_debug("Fetch latest version for '$module' from CPAN");
47 0 my $info = $cpan->expand('Module', $module);
48 0 ▶ unless ($info) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info) 0 0 0
49 0 $self->log("Could not find info on Module '$module'");
50 0 next;
51 }
52 0 ▶ next unless my $version = $info->cpan_version;
Branch: 1 branch
BranchTrueFalseTotal
unless my $version = $info->cpan_version 0 0 0
53  
54 ## register the latest version
55 0 $self->log_debug("Update version of '$module' to '$version'");
56 0 $zilla->register_prereqs(
57 { type => $type,
58 phase => $phase,
59 },
60 $module => $version,
61 );
62 }
63 }
64 }
65 }
66  
67 0 ▶sub _startup_cpan {
Subroutine _startup_cpan: not called CC=1 SCAR=6.9
68 ## Hide output of CPAN
69 0 $CPAN::Be_Silent++;
70  
71 0 return 'CPAN::Shell';
72 }
73  
74 1 __PACKAGE__->meta->make_immutable;
75 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 1 1;
77  
78 __END__
↑ Summary