CPAN/Maker/Bootstrapper/Role/Filter.pm

filter: Statementstmt 35.5% 16 / 45 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 1 totaltotal 27.2% 21 / 77 CC 13 SCAR 37.8
CC
13
Cov
24%
cmd_filter
72.0
_fetch_requires
42.0
BEGIN
1.0
CRAP 43.8
« CPAN/Maker/Bootstrapper/Role/DarkPANRequires.pm ↑ Summary Git/ReleaseDiffs.pm »
1 package CPAN::Maker::Bootstrapper::Role::Filter;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use CLI::Simple::Constants qw(:booleans);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 ########################################################################
12 0 ▶sub cmd_filter {
Subroutine cmd_filter: not called CC=8 SCAR=42.8
Pod undocumented
13 ########################################################################
14 0 my ($self) = @_;
15  
16 0 my ( $requires_new, $skip_file, $requires_old ) = $self->get_args;
17  
18 0 my %files = (
19 skip => $self->_fetch_requires($skip_file),
20 new => $self->_fetch_requires($requires_new),
21 old => $self->_fetch_requires($requires_old),
22 );
23  
24 0 my %new_requires;
25  
26 # copy preserved modules (ones preceded with '+')
27 0 foreach my $m ( keys %{ $files{old} } ) {
28 0 ▶ next if $m !~ /^\+/xsm;
Branch: 1 branch
BranchTrueFalseTotal
unless $m =~ /^\+/msx 0 0 0
29 0 $new_requires{$m} = $files{old}->{$m};
30 }
31  
32 0 foreach my $m ( keys %{ $files{new} } ) {
33 # skip modules on skip list
34 0 ▶ next if exists $files{skip}->{$m};
Branch: 1 branch
BranchTrueFalseTotal
if exists $files{"skip"}{$m} 0 0 0
35 0 ▶ next if exists $files{old}->{"+$m"};
Branch: 1 branch
BranchTrueFalseTotal
if exists $files{"old"}{"+$m"} 0 0 0
36  
37 # keep modules from preserved list if versions differ (user must have specified specific version)
38 0 ▶ if ( exists $files{old}->{$m} && $files{old}->{$m} ne $files{new}->{$m} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $files{'old'}{$m} and $files{'old'}{$m} ne $files{'new'}{$m}) { } 0 0 0
Condition0%0/3
exists $files{"old"}{$m} and $files{"old"}{$m} ne $files{"new"}{$m}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $files{"old"}{$m} and $files{"old"}{$m} ne $files{"new"}{$m}
exists $files{"old"}{$m} $files{"old"}{$m} ne $files{"new"}{$m}
Truth table0%0/3
A and B
A= exists $files{"old"}{$m}B= $files{"old"}{$m} ne $files{"new"}{$m}
ABresult
0X0
100
111
39 0 $new_requires{$m} = $files{old}->{$m};
40 }
41 else {
42 0 $new_requires{$m} = $files{new}->{$m};
43 }
44 }
45  
46 0 print join q{}, map {"$_ $new_requires{$_}\n"} sort keys %new_requires;
47  
48 0 return $SUCCESS;
49 }
50  
51 ########################################################################
52 0 ▶sub _fetch_requires {
Subroutine _fetch_requires: not called CC=6 SCAR=37.4
53 ########################################################################
54 0 my ( $self, $infile ) = @_;
55  
56 return {}
57 0 ▶ if !-s $infile;
Branch: 1 branch
BranchTrueFalseTotal
unless -s $infile 0 0 0
58  
59 0 my %requires;
60  
61 0 ▶ open my $fh, '<', $infile
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $infile or die "ERROR: could not open $infile for reading\n" 0 0 0
62 or die "ERROR: could not open $infile for reading\n";
63  
64 0 ▶ while ( my $line = <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 0 0 0
65 0 chomp $line;
66 0 ▶ next if !$line;
Branch: 1 branch
BranchTrueFalseTotal
unless $line 0 0 0
67 0 my ( $m, $v ) = split q{ }, $line;
68 0 ▶ $requires{$m} = $v // 0;
Condition0%0/2
$v // 0
l!l
00
MC/DC0%0/1
$v // 0
$v
Truth table0%0/2
A
A= $v
Aresult
11
00
69 }
70  
71 0 close $fh;
72  
73 0 return \%requires;
74 }
75  
76 2 1;
« CPAN/Maker/Bootstrapper/Role/DarkPANRequires.pm ↑ Summary Git/ReleaseDiffs.pm »