| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | next if exists $files{old}->{"+$m"}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
exists $files{"old"}{$m} and $files{"old"}{$m} ne $files{"new"}{$m}
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}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | my %requires; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | open my $fh, '<', $infile | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | or die "ERROR: could not open $infile for reading\n"; | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | chomp $line; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | next if !$line; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | my ( $m, $v ) = split q{ }, $line; | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | $requires{$m} = $v // 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$v // 0
MC/DC0%0/1
$v // 0
$v
Truth table0%0/2
A
A= $v
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | close $fh; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | return \%requires; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2 | 1; | |||||||||||||||||||||||||||