Admin/Util.pm

filter: Statementstmt 28.5% 12 / 42 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 22.8% 16 / 70 CC 13 SCAR 32.4
CC
13
Cov
20%
triage_read
42.0
prompt
30.0
triage_write
20.0
CRAP 25.6
↑ Summary Admin/Command/Publish.pm »
1 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use builtin qw( trim );
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶no warnings qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
4 experimental::for_list
5 experimental::builtin
6 1 );
7  
8 1 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 package CPANSEC::Admin::Util {
11  
12 0 ▶ sub triage_read ($filepath) {
Subroutine triage_read: not called CC=6 SCAR=37.4
Pod undocumented
13 0 ▶ $filepath = Path::Tiny::path($filepath) if !ref $filepath;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $filepath 0 0 0
14 0 my @content;
15 0 foreach my $line ($filepath->lines({chomp => 1})) {
16 0 ▶ if ($line =~ s/\A\s*\-\s+//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/\A\s*\-\s+//u) 0 0 0
17 0 push $content[-1]->@*, $line;
18 0 next;
19 }
20  
21 0 my ($k, @v) = split /\s*:\s*/ => $line;
22 0 my $v = join(':', @v);
23 0 ▶ undef $v if $v =~ /\A\s*~\s*\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /\A\s*~\s*\z/u 0 0 0
24 0 ▶ if ($k =~ /\Areferences/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /\Areferences/u) 0 0 0
25 0 $v = [];
26 }
27  
28 0 push @content, $k, $v;
29 }
30 0 return \@content;
31 }
32  
33 0 ▶ sub triage_write ($filepath, $data) {
Subroutine triage_write: not called CC=4 SCAR=30.0
Pod undocumented
34 0 ▶ $filepath = Path::Tiny::path($filepath) if !ref $filepath;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $filepath 0 0 0
35 0 my @content;
36 0 foreach my ($k, $v) (@$data) {
37 0 ▶ if (ref $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v) 0 0 0
38 0 $v = "\n- " . join("\n- ", @$v);
39 }
40 0 push @content, join ': ', $k, $v;
41 }
42 0 $filepath->spew_utf8(join "\n" => @content);
43 0 return;
44 }
45  
46 0 ▶ sub prompt ($msg, @options) {
Subroutine prompt: not called CC=5 SCAR=34.0
Pod undocumented
47 0 say $msg;
48 0 my $answer;
49 0 ▶ PROMPT: while ($answer = <STDIN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($answer = readline STDIN)) 0 0 0
50 0 $answer = trim($answer);
51 0 ▶ last PROMPT if !@options;
Branch: 1 branch
BranchTrueFalseTotal
unless @options 0 0 0
52 0 foreach my $opt (@options) {
53 0 ▶ last PROMPT if $answer eq $opt;
Branch: 1 branch
BranchTrueFalseTotal
if $answer eq $opt 0 0 0
54 }
55 0 say 'please pick one of: ' . join ', ' => @options;
56 }
57 0 return $answer;
58 }
59 }
↑ Summary Admin/Command/Publish.pm »