Respite/Common.pm

filter: Statementstmt 78.7% 26 / 33 Branchbran 5.5% 1 / 18 Conditioncond 19.5% 9 / 46 MC/DCmcdc 4.5% 1 / 22 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 4 totaltotal 32.3% 42 / 130 CC 27 SCAR 45.7
CC
27
Cov
37%
config
210.0
_configs
20.1
jsop
12.0
CRAP 96.1
« Respite/Base.pm ↑ Summary Respite/Client.pm »
1 package Respite::Common;
2  
3 =pod
4  
5 =head1 NAME
6  
7 Respite::Common - Common methods used internally
8  
9 =head1 SYNOPSIS
10  
11 package CustomModule;
12 use base 'Respite::Common';
13  
14 sub xkey1 { return shift->_configs->{xxx_key} || "unknown" }
15  
16 sub parse1 { return shift->json->decode(shift) }
17  
18 =cut
19  
20 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 21 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
24 21 my ($class, $args) = @_;
25 21 ▶ return bless {%{$args || {}}}, $class;
Condition100%2/2
$args || {}
l!l
192
MC/DC100%1/1
$args || {}
$args
Truth table100%2/2
A
A= $args
Aresult
11
00
26 }
27  
28 5 our $js;
29 14 ▶sub json { $js ||= eval { require JSON; JSON->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } || die "Could not load JSON: $@" }
Subroutine json: called CC=3 SCAR=11.4
Pod undocumented
Condition60%3/5
$Respite::Common::js ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } } || die("Could not load JSON: $@")
l!l&&r!l&&!r
1130
eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } } || die("Could not load JSON: $@")
l!l
30
MC/DC0%0/2
$Respite::Common::js ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } } || die("Could not load JSON: $@")
$Respite::Common::js eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } }
Truth table66%2/3
A ||= B
A= $Respite::Common::jsB= eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } }
ABresult
1X1
011
000
30 5 our $jp;
31 0 ▶sub jsop { $jp ||= eval { require JSON; JSON->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } || die "Could not load JSON: $@" }
Subroutine jsop: not called CC=3 SCAR=24.8
Pod undocumented
Condition0%0/5
$Respite::Common::jp ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } } || die("Could not load JSON: $@")
l!l&&r!l&&!r
000
eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } } || die("Could not load JSON: $@")
l!l
00
MC/DC0%0/2
$Respite::Common::jp ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } } || die("Could not load JSON: $@")
$Respite::Common::jp eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } }
Truth table0%0/3
A ||= B
A= $Respite::Common::jpB= eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } }
ABresult
1X1
011
000
32  
33 5 our $config;
34 143 ▶sub _configs {
Subroutine _configs: called CC=9 SCAR=30.0
35 143 ▶ return $config ||= do {
Condition66%2/3
$Respite::Common::config ||= do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
l!l&&r!l&&!r
14030
MC/DC0%0/2
$Respite::Common::config ||= do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
$Respite::Common::config do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
Truth table66%2/3
A ||= B
A= $Respite::Common::configB= do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
ABresult
1X1
011
000
36 3 my $c = undef;
37 3 eval {
38 3 require config;
39 3 eval { $c = config->load };
40 3 ▶ $c ||= defined($config::config) && "HASH" eq ref $config::config && $config::config;
Condition11%1/9
$c ||= defined $config::config && "HASH" eq ref $config::config && $config::config
l!l&&r!l&&!r
300
defined $config::config && 'HASH' eq ref $config::config && $config::config
!ll&&!rl&&r
000
defined $config::config and "HASH" eq ref $config::config
!ll&&!rl&&r
000
MC/DC0%0/4
$c ||= defined $config::config && "HASH" eq ref $config::config && $config::config
$c defined $config::config "HASH" eq ref $config::config $config::config
Truth table0%0/5
A ||= B and C && D
A= $cB= defined $config::configC= "HASH" eq ref $config::configD= $config::config
ABCDresult
1XXX1
01111
00XX0
010X0
01100
41 3 ▶ $c ||= %config::config ? \%config::config : undef;
Branch: 1 branch
BranchTrueFalseTotal
%config::config ? : 0 0 0
Condition33%1/3
$c ||= %config::config ? \%config::config : undef
l!l&&r!l&&!r
300
MC/DC0%0/2
$c ||= %config::config ? \%config::config : undef
$c %config::config ? \%config::config : undef
Truth table33%1/3
A ||= B
A= $cB= %config::config ? \%config::config : undef
ABresult
1X1
011
000
42 };
43 3 ▶ "HASH" eq ref $c or $c = { failed_load => ($@ || "missing config::config hash") };
Branch: 1 branch
BranchTrueFalseTotal
"HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"} 3 0 3
Condition0%0/2
$@ || 'missing config::config hash'
l!l
00
MC/DC0%0/1
$@ || 'missing config::config hash'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
44 3 $c;
45 };
46 }
47  
48 0 ▶sub config {
Subroutine config: not called CC=14 SCAR=53.5
Pod undocumented
49 0 my ($self, $key, $def, $name) = @_;
50 0 ▶ $name ||= (my $n = $self->base_class || ref($self) || $self || '') =~ /(\w+)$/ ? lc $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
(my $n = $self->base_class || ref $self || $self || '') =~ /(\w+)$/ ? : 0 0 0
Condition0%0/11
$name ||= (my $n = $self->base_class || ref $self || $self || "") =~ /(\w+)$/ ? lc $1 : ""
l!l&&r!l&&!r
000
$self->base_class || ref $self || $self || ''
l!l
00
$self->base_class or ref $self or $self
l!l&&r!l&&!r
000
$self->base_class or ref $self
l!l&&r!l&&!r
000
MC/DC0%0/4
$name ||= (my $n = $self->base_class || ref $self || $self || "") =~ /(\w+)$/ ? lc $1 : ""
$name $self->base_class ref $self $self
Truth table0%0/5
A ||= B or C or D
A= $nameB= $self->base_classC= ref $selfD= $self
ABCDresult
1XXX1
01XX1
001X1
00011
00000
51 0 my $c = $self->_configs($name);
52 return exists($self->{$key}) ? $self->{$key}
53 : exists($c->{"${name}_service_${key}"}) ? $c->{"${name}_service_${key}"}
54 : (ref($c->{"${name}_service"}) && exists $c->{"${name}_service"}->{$key}) ? $c->{"${name}_service"}->{$key}
55 : exists($c->{"${name}_${key}"}) ? $c->{"${name}_${key}"}
56 0 ▶ : (ref($c->{$name}) && exists $c->{$name}->{$key}) ? $c->{$name}->{$key}
Branch: 6 branches
BranchTrueFalseTotal
exists $self->{$key} ? : 0 0 0
exists $$c{"${name}_service_$key"} ? : 0 0 0
ref $$c{"${name}_service"} && exists $$c{"${name}_service"}{$key} ? : 0 0 0
exists $$c{"${name}_$key"} ? : 0 0 0
ref $c->{$name} && exists $c->{$name}{$key} ? : 0 0 0
ref $def eq 'CODE' ? : 0 0 0
Condition0%0/6
ref $$c{"${name}_service"} and exists $$c{"${name}_service"}{$key}
!ll&&!rl&&r
000
ref $c->{$name} and exists $c->{$name}{$key}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $$c{"${name}_service"} and exists $$c{"${name}_service"}{$key}
ref $$c{"${name}_service"} exists $$c{"${name}_service"}{$key}
MC/DC0%0/2
ref $c->{$name} and exists $c->{$name}{$key}
ref $c->{$name} exists $c->{$name}{$key}
Truth table0%0/3
A and B
A= ref $$c{"${name}_service"}B= exists $$c{"${name}_service"}{$key}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $c->{$name}B= exists $c->{$name}{$key}
ABresult
0X0
100
111
57 : ref($def) eq 'CODE' ? $def->($self) : $def;
58 }
59  
60 5 1;
« Respite/Base.pm ↑ Summary Respite/Client.pm »