P5U/Command.pm

filter: Statementstmt 52.9% 27 / 51 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 16 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 52.9% 9 / 17 Podpod 0.0% 0 / 6 totaltotal 35.2% 36 / 102 CC 8 SCAR 18.8
CC
8
Cov
39%
get_config
20.0
save_config
12.0
_get_distdatadir
6.0
CRAP 6.5
« P5U/Command/Reprove.pm ↑ Summary P5U/Lib/DebianRelease.pm »
1 package P5U::Command;
2  
3 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 $P5U::Command::AUTHORITY = 'cpan:TOBYINK';
5 1 $P5U::Command::VERSION = '0.100';
6 };
7  
8 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use App::Cmd::Setup-command;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use File::HomeDir qw<>;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use File::Temp qw<>;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use JSON qw<>;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Path::Tiny qw<>;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Object::AUTHORITY;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 my %config;
19  
20 sub get_tempdir
21 0 ▶{
Subroutine get_tempdir: not called CC=1 SCAR=6.9
Pod undocumented
22 0 Path::Tiny::->tempdir;
23 }
24  
25 sub _get_distdatadir
26 0 ▶{
Subroutine _get_distdatadir: not called CC=2 SCAR=17.9
27 0 ▶ File::HomeDir::->my_dist_data('P5U') //
Condition0%0/3
"File::HomeDir"->my_dist_data("P5U") // "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "data"))->stringify
l!l&&r!l&&!r
000
MC/DC0%0/2
"File::HomeDir"->my_dist_data("P5U") // "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "data"))->stringify
"File::HomeDir"->my_dist_data("P5U") "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "data"))->stringify
Truth table0%0/3
A // B
A= "File::HomeDir"->my_dist_data("P5U")B= "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "data"))->stringify
ABresult
1X1
011
000
28 Path::Tiny::->new(File::HomeDir::->my_home => qw(perl5 utils data))->stringify
29 }
30  
31 sub _get_distconfigdir
32 0 ▶{
Subroutine _get_distconfigdir: not called CC=2 SCAR=17.9
33 0 ▶ File::HomeDir::->my_dist_data('P5U') //
Condition0%0/3
"File::HomeDir"->my_dist_data("P5U") // "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "etc"))->stringify
l!l&&r!l&&!r
000
MC/DC0%0/2
"File::HomeDir"->my_dist_data("P5U") // "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "etc"))->stringify
"File::HomeDir"->my_dist_data("P5U") "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "etc"))->stringify
Truth table0%0/3
A // B
A= "File::HomeDir"->my_dist_data("P5U")B= "Path::Tiny"->new("File::HomeDir"->my_home, ("perl5", "utils", "etc"))->stringify
ABresult
1X1
011
000
34 Path::Tiny::->new(File::HomeDir::->my_home => qw(perl5 utils etc))->stringify
35 }
36  
37 sub get_cachedir
38 0 ▶{
Subroutine get_cachedir: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my $self = shift;
40 0 my $d = Path::Tiny::->new(
41 $self->_get_distdatadir,
42 (($self->command_names)[0]),
43 'cache',
44 );
45 0 $d->mkpath;
46 0 return $d;
47 }
48  
49 sub get_datadir
50 0 ▶{
Subroutine get_datadir: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my $self = shift;
52 0 my $d = Path::Tiny::->new(
53 $self->_get_distdatadir,
54 (($self->command_names)[0]),
55 'store',
56 );
57 0 $d->mkpath;
58 0 return $d;
59 }
60  
61 sub get_configfile
62 0 ▶{
Subroutine get_configfile: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my $self = shift;
64 0 my $f = Path::Tiny::->new(
65 $self->_get_distconfigdir,
66 (($self->command_names)[0]),
67 'config.json',
68 );
69 }
70  
71 sub get_config
72 0 ▶{
Subroutine get_config: not called CC=4 SCAR=30.0
Pod undocumented
73 0 my $proto = shift;
74 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
75
76 0 ▶ unless ($config{$class})
Branch: 1 branch
BranchTrueFalseTotal
unless ($config{$class}) 0 0 0
77 {
78 $config{$class} =
79 0 ▶ eval { JSON::->new->decode(scalar $proto->get_configfile->slurp) }
Condition0%0/2
eval { do { 'JSON'->new->decode(scalar $proto->get_configfile->slurp) } } || {}
l!l
00
MC/DC0%0/1
eval { do { 'JSON'->new->decode(scalar $proto->get_configfile->slurp) } } || {}
eval { do { 'JSON'->new->decode(scalar $proto->get_configfile->slurp) } }
Truth table0%0/2
A
A= eval { do { 'JSON'->new->decode(scalar $proto->get_configfile->slurp) } }
Aresult
11
00
80 || +{};
81 }
82
83 0 $config{$class};
84 }
85  
86 sub save_config
87 0 ▶{
Subroutine save_config: not called CC=3 SCAR=24.8
Pod undocumented
88 0 my $proto = shift;
89 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
90 0 ▶ my $config = $config{$class} || +{};
Condition0%0/2
$config{$class} || {}
l!l
00
MC/DC0%0/1
$config{$class} || {}
$config{$class}
Truth table0%0/2
A
A= $config{$class}
Aresult
11
00
91
92 0 my $fh = $proto->get_configfile->openw;
93 0 print $fh $config;
94 }
95  
96 1 1;
97  
« P5U/Command/Reprove.pm ↑ Summary P5U/Lib/DebianRelease.pm »