blib/lib/Dist/Zilla/Plugin/Prereqs/MatchInstalled/All.pm

filter: Statementstmt 93.2% 55 / 59 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 15 / 15 Podpod n/a totaltotal 87.0% 74 / 85 CC 5 SCAR 7.7
CC
5
Cov
87%
_user_wants_upgrade_on
6.0
__ANON__
2.0
_build__exclude_hash
1.0
CRAP 2.2
↑ Summary
1 2 ▶use 5.008; # 08 => utf, 06 => pragmas, our, 04 => arrow coderef, __PACKAGE__
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Dist::Zilla::Plugin::Prereqs::MatchInstalled::All;
7  
8 2 our $VERSION = '1.001001';
9  
10 # ABSTRACT: Upgrade ALL your dependencies to the ones you have installed.
11  
12 2 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13  
14 2 ▶use Moose qw( has around extends );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Dist::Zilla::Plugin::Prereqs::MatchInstalled 1.000000;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use MooseX::Types::Moose qw( ArrayRef HashRef Str Bool );
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30 2 extends 'Dist::Zilla::Plugin::Prereqs::MatchInstalled';
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44 has exclude => (
45 is => ro =>,
46 isa => ArrayRef [Str],
47 lazy => 1,
48 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
49 2 );
50  
51  
52  
53  
54  
55 2 has _exclude_hash => (
56 is => ro =>,
57 isa => HashRef [Str],
58 lazy => 1,
59 builder => '_build__exclude_hash',
60 );
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77 has upgrade_perl => (
78 is => ro =>,
79 isa => Bool,
80 lazy => 1,
81 1 ▶ default => sub { undef },
Subroutine __ANON__: called CC=1 SCAR=0.0
82 2 );
83  
84 1 ▶around mvp_multivalue_args => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
85 1 my ( $orig, $self, @args ) = @_;
86 1 return ( 'exclude', $orig->( $self, @args ) );
87 2 };
88  
89 1 ▶around dump_config => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
90 1 my ( $orig, $self, @args ) = @_;
91 1 my $config = $self->$orig(@args);
92 1 my $localconf = $config->{ +__PACKAGE__ } = {};
93  
94 1 $localconf->{exclude} = $self->exclude;
95 1 $localconf->{upgrade_perl} = $self->upgrade_perl;
96  
97 1 ▶ $localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION
Branch: 1 branch
BranchTrueFalseTotal
unless __PACKAGE__ eq ref $self 0 1 1
98 unless __PACKAGE__ eq ref $self;
99  
100 1 return $config;
101 2 };
102  
103  
104  
105  
106  
107 1 ▶sub _build__exclude_hash {
Subroutine _build__exclude_hash: called CC=1 SCAR=0.2
108 1 my ($self) = @_;
109 0 return { map { ( $_, 1 ) } @{ $self->exclude } };
110 }
111  
112  
113  
114  
115  
116 1 ▶sub _user_wants_excluded {
Subroutine _user_wants_excluded: called CC=1 SCAR=0.0
117 1 my ( $self, $module ) = @_;
118 1 return exists $self->_exclude_hash->{$module};
119 }
120  
121  
122  
123  
124  
125 2 my $u_upgrade = q[perl is a dependency, but we won't automatically ];
126 2 $u_upgrade .= q[upgrade that without upgrade_perl = 1];
127  
128 1 ▶sub _user_wants_upgrade_on {
Subroutine _user_wants_upgrade_on: called CC=4 SCAR=17.9
129 1 my ( $self, $module ) = @_;
130 1 ▶ if ( 'perl' eq $module and not $self->upgrade_perl ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("perl" eq $module and not $self->upgrade_perl) 0 1 1
Condition33%1/3
"perl" eq $module and not $self->upgrade_perl
!ll&&!rl&&r
100
MC/DC0%0/2
"perl" eq $module and not $self->upgrade_perl
"perl" eq $module not $self->upgrade_perl
Truth table33%1/3
A and not(B)
A= "perl" eq $moduleB= not $self->upgrade_perl
ABresult
0X0
100
111
131 0 $self->log_debug($u_upgrade);
132 0 return;
133 }
134 1 ▶ if ( $self->_user_wants_excluded($module) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_user_wants_excluded($module)) 0 1 1
135 0 return;
136 }
137 1 return 1;
138 }
139  
140 2 __PACKAGE__->meta->make_immutable;
141 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
142  
143 2 1;
144  
145 __END__
↑ Summary