| 1 | package App::PDRUtils::DistIniCmd::add_prereq; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | our $DATE = '2021-05-25'; # DATE | |||||||||||||||||||||||||||
| 4 | 3 | our $VERSION = '0.122'; # VERSION | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Log::ger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use App::PDRUtils::Cmd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use App::PDRUtils::DistIniCmd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 | our %SPEC; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | $SPEC{handle_cmd} = { | ||||||||||||||||||||||||||||
| 17 | 3 | v => 1.1, | |||||||||||||||||||||||||||
| 18 | summary => 'Add a prereq', | ||||||||||||||||||||||||||||
| 19 | args => { | ||||||||||||||||||||||||||||
| 20 | %App::PDRUtils::DistIniCmd::common_args, | ||||||||||||||||||||||||||||
| 21 | %App::PDRUtils::Cmd::mod_args, | ||||||||||||||||||||||||||||
| 22 | %App::PDRUtils::Cmd::opt_mod_ver_args, | ||||||||||||||||||||||||||||
| 23 | phase => { | ||||||||||||||||||||||||||||
| 24 | summary => 'Select prereq phase', | ||||||||||||||||||||||||||||
| 25 | schema => ['str*', match=>qr/\A(build|configure|develop|runtime|test|x_\w+)\z/], | ||||||||||||||||||||||||||||
| 26 | default => 'runtime', | ||||||||||||||||||||||||||||
| 27 | }, | ||||||||||||||||||||||||||||
| 28 | rel => { | ||||||||||||||||||||||||||||
| 29 | summary => 'Select prereq relationship', | ||||||||||||||||||||||||||||
| 30 | schema => ['str*', match=>qr/\A(requires|suggests|recommends|x_\w+)\z/], | ||||||||||||||||||||||||||||
| 31 | default => 'requires', | ||||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||
| 33 | # TODO: replace option | ||||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||
| 35 | }; | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub handle_cmd { | ||||||||||||||||||||||||||
|
Subroutine
handle_cmd: not called CC=22 SCAR=62.3
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my $iod = $args{parsed_dist_ini}; | |||||||||||||||||||||||||||
| 40 | 0 | my $mod = $args{module}; | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $ver = $args{module_version} // 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"module_version"} // 0
MC/DC0%0/1
$args{"module_version"} // 0
$args{"module_version"}
Truth table0%0/2
A
A= $args{"module_version"}
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $phase = $args{phase} // 'runtime'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"phase"} // "runtime"
MC/DC0%0/1
$args{"phase"} // "runtime"
$args{"phase"}
Truth table0%0/2
A
A= $args{"phase"}
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $rel = $args{rel} // 'requires'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"rel"} // "requires"
MC/DC0%0/1
$args{"rel"} // "requires"
$args{"rel"}
Truth table0%0/2
A
A= $args{"rel"}
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (App::PDRUtils::Cmd::_has_prereq($iod, $mod)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 0 | return [304, "Already has prereq to '$mod'"]; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my $section; | |||||||||||||||||||||||||||
| 50 | 0 | for my $s ($iod->list_sections) { | |||||||||||||||||||||||||||
| 51 | 0 | ▶ | next unless $s =~ m!\Aprereqs(?:\s*/\s*(\w+))?\z!ix; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($phase eq 'runtime' && $rel eq 'requires') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$phase eq "runtime" and $rel eq "requires"
MC/DC0%0/2
$phase eq "runtime" and $rel eq "requires"
$phase eq "runtime"
$rel eq "requires"
Truth table0%0/3
A and B
A= $phase eq "runtime"B= $rel eq "requires"
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | next unless !$1 || lc($1) eq 'runtimerequires'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $1 or lc $1 eq "runtimerequires"
MC/DC0%0/2
not $1 or lc $1 eq "runtimerequires"
not $1
lc $1 eq "runtimerequires"
Truth table0%0/3
not(A) or B
A= not $1B= lc $1 eq "runtimerequires"
| |||||||||||||||||||||||||||||
| 54 | } else { | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | next unless $1 && lc($1) eq $phase.$rel; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$1 and lc $1 eq $phase . $rel
MC/DC0%0/2
$1 and lc $1 eq $phase . $rel
$1
lc $1 eq $phase . $rel
Truth table0%0/3
A and B
A= $1B= lc $1 eq $phase . $rel
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 0 | $section = $s; | |||||||||||||||||||||||||||
| 58 | 0 | last; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | unless ($section) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($phase eq 'runtime' && $rel eq 'requires') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$phase eq "runtime" and $rel eq "requires"
MC/DC0%0/2
$phase eq "runtime" and $rel eq "requires"
$phase eq "runtime"
$rel eq "requires"
Truth table0%0/3
A and B
A= $phase eq "runtime"B= $rel eq "requires"
| |||||||||||||||||||||||||||||
| 62 | 0 | $section = 'Prereqs'; | |||||||||||||||||||||||||||
| 63 | } else { | ||||||||||||||||||||||||||||
| 64 | 0 | $section = 'Prereqs / '.ucfirst($phase).ucfirst($rel); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my ($modified, $linum); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($phase =~ /\Ax_/ || $rel =~ /\Ax_/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$phase =~ /\Ax_/ or $rel =~ /\Ax_/
MC/DC0%0/2
$phase =~ /\Ax_/ or $rel =~ /\Ax_/
$phase =~ /\Ax_/
$rel =~ /\Ax_/
Truth table0%0/3
A or B
A= $phase =~ /\Ax_/B= $rel =~ /\Ax_/
| |||||||||||||||||||||||||||||
| 71 | 0 | $linum = $iod->insert_key( | |||||||||||||||||||||||||||
| 72 | {create_section=>1, ignore=>1}, $section, "-phase", $phase); | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $modified = 1 if defined $linum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | $linum = $iod->insert_key( | |||||||||||||||||||||||||||
| 75 | {create_section=>1, ignore=>1}, $section, "-relationship", $rel); | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $modified = 1 if defined $linum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | $linum = $iod->insert_key( | |||||||||||||||||||||||||||
| 80 | {create_section=>1, ignore=>1}, $section, $mod, $ver); | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $modified = 1 if defined $linum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ($modified) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | return [200, "Added prereq '$mod=$ver' to section [$section]", $iod]; | |||||||||||||||||||||||||||
| 85 | } else { | ||||||||||||||||||||||||||||
| 86 | 0 | return [304, "Not modified"]; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 3 | 1; | |||||||||||||||||||||||||||
| 91 | # ABSTRACT: Add a prereq | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||