« lib/Module/Provision/TraitFor/EnvControl.pm
↑ Summary
lib/Module/Provision/TraitFor/Rendering.pm »
| 1 | package Module::Provision::TraitFor::PrereqDifferences; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Class::Usul::Constants qw( FALSE NUL OK TRUE ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Class::Usul::Functions qw( classfile ensure_class_loaded | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | is_member emit io ); | |||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Config::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Module::Metadata; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Perl::Version; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | requires qw( appldir builder chdir debug libdir load_meta | |||||||||||||||||||||||||||||||||||||||||
| 15 | manifest_paths next_argv output project_file run_cmd ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # Private functions | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my $_dist_from_module = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $module = CPAN::Shell->expand( 'Module', $_[ 0 ] ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return $module ? $module->distribution : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $_draw_line = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return emit '-' x ($_[ 0 ] // 60); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0] // 60
MC/DC0%0/1
$_[0] // 60
$_[0]
Truth table0%0/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $_extract_statements_from = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $line = shift; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | return grep { length } | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | map { s{ \A \s+ }{}mx; s{ \s+ \z }{}mx; $_ } split m{ ; }mx, $line; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $_looks_like_version = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $ver = shift; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return defined $ver && $ver =~ m{ \A v? \d+ (?: \.[\d_]+ )? \z }mx; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $ver && $ver =~ / \A v? \d+ (?: \.[\d_]+ )? \z /mx
MC/DC0%0/2
defined $ver && $ver =~ / \A v? \d+ (?: \.[\d_]+ )? \z /mx
defined $ver
$ver =~ / \A v? \d+ (?: \.[\d_]+ )? \z /mx
Truth table0%0/3
A && B
A= defined $verB= $ver =~ / \A v? \d+ (?: \.[\d_]+ )? \z /mx
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $_parse_list = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $string =~ s{ \A q w* [\(/] \s* }{}mx; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $string =~ s{ \s* [\)/] \z }{}mx; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $string =~ s{ [\'\"] }{}gmx; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $string =~ s{ , }{ }gmx; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | return grep { length && !m{ [^\.:\w] }mx } split m{ \s+ }mx, $string; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
length $_ && !/ [^\.:\w] /mx
MC/DC0%0/2
length $_ && !/ [^\.:\w] /mx
length $_
!/ [^\.:\w] /mx
Truth table0%0/3
A && not(B)
A= length $_B= !/ [^\.:\w] /mx
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my $_read_non_pod_lines = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $path = shift; my $p = Pod::Eventual::Simple->read_file( $path ); | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return join "\n", map { $_->{content} } | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | grep { $_->{type} eq 'nonpod' } @{ $p }; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $_recover_module_name = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $id = shift; my @parts = split m{ [\-] }mx, $id; my $ver = pop @parts; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return join '::', @parts; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $_version_diff = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my ($prereq, $depend) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $prereq =~ s{ (\. [0-9]+?) 0+ \z }{$1}mx; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $depend =~ s{ (\. [0-9]+?) 0+ \z }{$1}mx; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $oldver = Perl::Version->new( $prereq ); $oldver->components( 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $newver = Perl::Version->new( $depend ); $newver->components( 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | return $oldver != $newver ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $_emit_diffs = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $diffs = shift; $_draw_line->(); | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | for my $table (sort keys %{ $diffs }) { | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | emit $table; $_draw_line->(); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | for (sort keys %{ $diffs->{ $table } }) { | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | emit "${_} = ".$diffs->{ $table }->{ $_ }; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $_draw_line->(); | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $_parse_depends_line = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $line = shift; my $modules = []; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | for my $stmt ($_extract_statements_from->( $line )) { | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($stmt =~ m{ \A (?: use | require ) \s+ }mx) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my (undef, $module, $rest) = split m{ \s+ }mx, $stmt, 3; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # Skip common pragma and things that don't look like module names | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $module =~ m{ \A (?: lib | strict | warnings ) \z }mx and next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $module =~ m{ [^\.:\w] }mx and next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | push @{ $modules }, $module eq 'base' || $module eq 'parent' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$module eq "base" or $module eq "parent"
MC/DC0%0/2
$module eq "base" or $module eq "parent"
$module eq "base"
$module eq "parent"
Truth table0%0/3
A or B
A= $module eq "base"B= $module eq "parent"
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | ? ($module, $_parse_list->( $rest )) : $module; | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | elsif ($stmt =~ m{ \A (?: with | extends ) \s+ (.+) }mx) { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | push @{ $modules }, $_parse_list->( $1 ); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | elsif ($stmt =~ m{ ensure_class_loaded [\(]? \s* (.+?) \s* [\)]? }mx) { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $module = $1; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $module = $module =~ m{ \A [q\'\"] }mx ? eval $module : $module; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | push @{ $modules }, $module; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return $modules; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | # Private methods | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $_is_perl_source = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $path =~ m{ (?: \.pm | \.t | \.pl ) \z }imx and return TRUE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $line = io( $path )->getline; $line or return FALSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return $line =~ m{ \A \#! (?: .* ) perl (?: \s | \z ) }mx ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $_prereq_data = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $self = shift; $self->chdir( $self->appldir ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ($self->builder eq 'DZ') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $cfg = Config::Tiny->read( 'dist.ini' ); | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | return { build_requires => $cfg->{ 'Prereqs / BuildRequires' }, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | configure_requires => $cfg->{ 'Prereqs / ConfigureRequires' }, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | recommends => $cfg->{ 'Prereqs / Recommends' }, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | requires => $cfg->{ 'Prereqs' }, }; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | elsif ($self->builder eq 'MB') { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $cmd = "${EXECUTABLE_NAME} Build.PL; ./Build prereq_data"; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return eval $self->run_cmd( $cmd )->stdout; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $_source_paths = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return [ grep { $_[ 0 ]->$_is_perl_source( $_ ) } | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | @{ $_[ 0 ]->manifest_paths } ]; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $_version_from_module = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my ($self, $module) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $inc = [ $self->libdir, @INC ]; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $info = Module::Metadata->new_from_module( $module, inc => $inc ); | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my $ver; $info and $info->version and $ver = $info->version; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info and $info->version
MC/DC0%0/2
$info and $info->version
$info
$info->version
Truth table0%0/3
A and B
A= $infoB= $info->version
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | return $ver ? Perl::Version->new( $ver ) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my $_compare_prereqs_with_used = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ($self, $field, $depends) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $file = $self->project_file; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $prereqs = $self->$_prereq_data->{ $field }; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $add_key = "Would add these to the ${field} in ${file}"; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $remove_key = "Would remove these from the ${field} in ${file}"; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $update_key = "Would update these in the ${field} in ${file}"; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $result = {}; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | for (grep { defined $depends->{ $_ } } keys %{ $depends }) { | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if (exists $prereqs->{ $_ }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ($_version_diff->( $prereqs->{ $_ }, $depends->{ $_ } )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | $result->{ $update_key }->{ $_ } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | = $prereqs->{ $_ }.' => '.$depends->{ $_ }; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | else { $result->{ $add_key }->{ $_ } = $depends->{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | for (grep { not exists $depends->{ $_ } } keys %{ $prereqs }) { | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $ver = $self->$_version_from_module( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $vdiff = $_version_diff->( $prereqs->{ $_ }, $ver ); | |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | $result->{ $remove_key }->{ $_ } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | = $prereqs->{ $_ }.($vdiff ? " => ${ver}" : NUL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $_consolidate = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my ($self, $used) = @_; my (%dists, %result); | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | for my $used_key (keys %{ $used }) { | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my ($curr_dist, $module, $used_dist); my $try_module = $used_key; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | while ($curr_dist = $_dist_from_module->( $try_module ) and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$curr_dist = &$_dist_from_module($try_module) and !$used_dist || $curr_dist->base_id eq $used_dist->base_id
not $used_dist or $curr_dist->base_id eq $used_dist->base_id
MC/DC0%0/3
$curr_dist = &$_dist_from_module($try_module) and !$used_dist || $curr_dist->base_id eq $used_dist->base_id
$curr_dist = &$_dist_from_module($try_module)
not $used_dist
$curr_dist->base_id eq $used_dist->base_id
Truth table0%0/4
A and not(B) or C
A= $curr_dist = &$_dist_from_module($try_module)B= not $used_distC= $curr_dist->base_id eq $used_dist->base_id
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | (not $used_dist or $curr_dist->base_id eq $used_dist->base_id)) { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $module = $try_module; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $used_dist or $used_dist = $curr_dist; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $try_module =~ m{ :: }mx or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $try_module =~ s{ :: [^:]+ \z }{}mx; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ($used_dist | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$used_dist and !$curr_dist || $used_dist->base_id ne $curr_dist->base_id
not $curr_dist or $used_dist->base_id ne $curr_dist->base_id
MC/DC0%0/3
$used_dist and !$curr_dist || $used_dist->base_id ne $curr_dist->base_id
$used_dist
not $curr_dist
$used_dist->base_id ne $curr_dist->base_id
Truth table0%0/4
A and not(B) or C
A= $used_distB= not $curr_distC= $used_dist->base_id ne $curr_dist->base_id
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | and (not $curr_dist or $used_dist->base_id ne $curr_dist->base_id)) { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $was = $module; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $module = $_recover_module_name->( $used_dist->base_id ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | $self->debug and $self->output( "Recovered ${module} from ${was}" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ($module) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | not exists $dists{ $module } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | and $dists{ $module } = $self->$_version_from_module( $module ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | else { $result{ $used_key } = $used->{ $used_key } } | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $result{ $_ } = $dists{ $_ } for (keys %dists); | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | return \%result; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | my $_dependencies = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my ($self, $paths) = @_; my $used = {}; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | for my $path (@{ $paths }) { | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $lines = $_read_non_pod_lines->( $path ); | |||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | for my $line (split m{ \n }mx, $lines) { | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $modules = $_parse_depends_line->( $line ); $modules->[ 0 ] or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | for (@{ $modules }) { | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $_looks_like_version->( $_ ) and $used->{perl} = $_ and next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&$_looks_like_version($_) and $used->{"perl"} = $_
MC/DC0%0/2
&$_looks_like_version($_) and $used->{"perl"} = $_
&$_looks_like_version($_)
$used->{"perl"} = $_
Truth table0%0/3
A and B
A= &$_looks_like_version($_)B= $used->{"perl"} = $_
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | not exists $used->{ $_ } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | and $used->{ $_ } = $self->$_version_from_module( $_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return $used; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | my $_filter_dependents = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my ($self, $used) = @_; my $excludes = 't::boilerplate'; | |||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my $perl_version = $used->{perl} // 5.008_008; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$used->{"perl"} // "5.008008"
MC/DC0%0/1
$used->{"perl"} // "5.008008"
$used->{"perl"}
Truth table0%0/2
A
A= $used->{"perl"}
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $core_modules = $Module::CoreList::version{ $perl_version }; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $provides = $self->load_meta->provides; | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return $self->$_consolidate( { map { $_ => $used->{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | grep { not exists $core_modules->{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | grep { not exists $provides->{ $_ } } | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | grep { not m{ \A $excludes \z }mx } | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | keys %{ $used } } ); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub _filter_build_requires_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_build_requires_paths: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | return [ grep { m{ (?: \.pm | \.t ) \z }mx } | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | grep { m{ \A t \b }mx } @{ $_[ 1 ] } ]; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | sub _filter_configure_requires_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_configure_requires_paths: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $file = $_[ 0 ]->project_file; | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return [ grep { m{ \A inc }mx || $_ eq $file } @{ $_[ 1 ] } ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
/ \A inc /mx || $_ eq $file
MC/DC0%0/2
/ \A inc /mx || $_ eq $file
/ \A inc /mx
$_ eq $file
Truth table0%0/3
A || B
A= / \A inc /mxB= $_ eq $file
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | sub _filter_requires_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_requires_paths: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $file = $_[ 0 ]->project_file; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | my $pattern = $file eq 'dist.ini' ? '(?: Build.PL | Makefile.PL )' : $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return [ grep { not m{ \A (?: inc | t ) \b }mx | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
/ \A (?: inc | t ) \b /mx || / \A $pattern \z /mx
MC/DC0%0/2
/ \A (?: inc | t ) \b /mx || / \A $pattern \z /mx
/ \A (?: inc | t ) \b /mx
/ \A $pattern \z /mx
Truth table0%0/3
A || B
A= / \A (?: inc | t ) \b /mxB= / \A $pattern \z /mx
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | and not m{ \A $pattern \z }mx } @{ $_[ 1 ] } ]; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | # Public methods | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub prereq_diffs : method { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prereq_diffs: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ensure_class_loaded 'CPAN'; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ensure_class_loaded 'Module::CoreList'; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ensure_class_loaded 'Pod::Eventual::Simple'; | |||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | my $field = $self->next_argv // 'requires'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->next_argv // "requires"
MC/DC0%0/1
$self->next_argv // "requires"
$self->next_argv
Truth table0%0/2
A
A= $self->next_argv
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $filter = "_filter_${field}_paths"; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $sources = $self->$filter( $self->$_source_paths ); | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $depends = $self->$_filter_dependents( $self->$_dependencies( $sources )); | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $_emit_diffs->( $self->$_compare_prereqs_with_used( $field, $depends ) ); | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return OK; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | __END__ | ||||||||||||||||||||||||||||||||||||||||||