PDRUtils/DistIniCmd/list_prereqs.pm

filter: Statementstmt 40.0% 22 / 55 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 30.2% 29 / 96 CC 18 SCAR 55.5
CC
18
Cov
26%
handle_cmd
342.0
BEGIN
1.0
BEGIN
1.0
CRAP 256.8
« PDRUtils/DistIniCmd/_modify_prereq_version.pm ↑ Summary PDRUtils/SingleCmd.pm »
1 package App::PDRUtils::DistIniCmd::list_prereqs;
2  
3 2 our $DATE = '2021-05-25'; # DATE
4 2 our $VERSION = '0.122'; # VERSION
5  
6 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use App::PDRUtils::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use App::PDRUtils::DistIniCmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 our %SPEC;
15  
16 $SPEC{handle_cmd} = {
17 2 v => 1.1,
18 summary => 'List prereqs from `[Prereqs/*]` sections',
19 description => <<'_',
20  
21 This command list prerequisites found in `[Prereqs/*]` sections in your
22 `dist.ini`.
23  
24 _
25 args => {
26 %App::PDRUtils::DistIniCmd::common_args,
27 module => {
28 summary => 'Module name',
29 schema => ['perl::modname*'],
30 tags => ['category:filtering'],
31 },
32 phase => {
33 schema => ['str*', in=>[qw/configure build test runtime develop/]],
34 tags => ['category:filtering'],
35 },
36 rel => {
37 schema => ['str*', in=>[qw/requires recommends suggests conflicts/]],
38 tags => ['category:filtering'],
39 },
40 detail => {
41 schema => 'bool',
42 cmdline_aliases => {l=>{}},
43 },
44 },
45 };
46 0 ▶sub handle_cmd {
Subroutine handle_cmd: not called CC=18 SCAR=58.3
Pod documented
47 0 my %fargs = @_;
48  
49 0 my $iod = $fargs{parsed_dist_ini};
50 0 my $hoh = $iod->dump;
51  
52 0 my @res;
53 0 for my $sect (sort keys %$hoh) {
54 0 ▶ next unless $sect =~ m!\A
Branch: 1 branch
BranchTrueFalseTotal
unless $sect =~ m[\A Prereqs (?:\s*/\s*(.+))? \z]x 0 0 0
55 Prereqs
56 (?:\s*/\s*(.+))?
57 \z!x;
58 0 my $plugin_name = $1;
59 0 my ($phase, $rel);
60 0 ▶ if ($plugin_name &&
Branch: 1 branch
BranchTrueFalseTotal
if ($plugin_name and $plugin_name =~ /\A(Configure|Build|Test|Runtime|Develop) (Requires|Recommends|Suggests|Conflicts)\z/x) 0 0 0
Condition0%0/3
$plugin_name and $plugin_name =~ /\A(Configure|Build|Test|Runtime|Develop) (Requires|Recommends|Suggests|Conflicts)\z/x
!ll&&!rl&&r
000
MC/DC0%0/2
$plugin_name and $plugin_name =~ /\A(Configure|Build|Test|Runtime|Develop) (Requires|Recommends|Suggests|Conflicts)\z/x
$plugin_name $plugin_name =~ /\A(Configure|Build|Test|Runtime|Develop) (Requires|Recommends|Suggests|Conflicts)\z/x
Truth table0%0/3
A and B
A= $plugin_nameB= $plugin_name =~ /\A(Configure|Build|Test|Runtime|Develop) (Requires|Recommends|Suggests|Conflicts)\z/x
ABresult
0X0
100
111
61 $plugin_name =~ /\A(Configure|Build|Test|Runtime|Develop)
62 (Requires|Recommends|Suggests|Conflicts)\z/x) {
63 0 $phase = $1;
64 0 $rel = $2;
65 }
66  
67 0 my $prereqs = $hoh->{$sect};
68 0 for (keys %$prereqs) {
69 0 ▶ if (/^-phase$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^-phase$/) 0 0 0
70 0 $phase = delete $prereqs->{$_};
71 }
72 0 ▶ if (/^-(relationship|type)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^-(relationship|type)$/) 0 0 0
73 0 $rel = delete $prereqs->{$_};
74 }
75 }
76  
77 0 ▶ $phase //= "runtime";
Condition0%0/2
$phase //= "runtime"
l!l
00
MC/DC0%0/1
$phase //= "runtime"
$phase
Truth table0%0/2
A
A= $phase
Aresult
11
00
78 0 ▶ $rel //= "requires";
Condition0%0/2
$rel //= "requires"
l!l
00
MC/DC0%0/1
$rel //= "requires"
$rel
Truth table0%0/2
A
A= $rel
Aresult
11
00
79  
80 0 ▶ if (defined $fargs{phase}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fargs{"phase"}) 0 0 0
81 0 ▶ next unless lc($fargs{phase}) eq lc($phase);
Branch: 1 branch
BranchTrueFalseTotal
unless lc $fargs{"phase"} eq lc $phase 0 0 0
82 }
83 0 ▶ if (defined $fargs{rel}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fargs{"rel"}) 0 0 0
84 0 ▶ next unless lc($fargs{rel}) eq lc($rel);
Branch: 1 branch
BranchTrueFalseTotal
unless lc $fargs{"rel"} eq lc $rel 0 0 0
85 }
86  
87 0 for my $mod (sort keys %$prereqs) {
88 0 my $version = $prereqs->{$mod};
89 0 ▶ if (defined $fargs{module}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fargs{"module"}) 0 0 0
90 0 ▶ next unless $fargs{module} eq $mod;
Branch: 1 branch
BranchTrueFalseTotal
unless $fargs{"module"} eq $mod 0 0 0
91 }
92 0 push @res, {
93 module => $mod,
94 version => $version,
95 phase => lc $phase,
96 rel => lc $rel,
97 };
98 }
99 }
100  
101 0 ▶ if ($fargs{detail}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fargs{'detail'}) { } 0 0 0
102 0 return [304, "Not modified", $iod, {
103 'func.result' => \@res,
104 'table.fields' => [qw/module version phase rel/],
105 }];
106 } else {
107 0 @res = map { $_->{module} } @res;
108 0 return [304, "Not modified", $iod, {
109 'func.result' => \@res,
110 }];
111 }
112 }
113  
114 2 1;
115 # ABSTRACT: List prereqs from `[Prereqs/*]` sections
116  
117 __END__
« PDRUtils/DistIniCmd/_modify_prereq_version.pm ↑ Summary PDRUtils/SingleCmd.pm »