| 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 || {}
MC/DC100%1/1
$args || {}
$args
Truth table100%2/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: $@")
eval {
do {
require JSON;
'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical
}
} || die("Could not load JSON: $@")
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
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: $@")
eval {
do {
require JSON;
'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty
}
} || die("Could not load JSON: $@")
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
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
}
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
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
defined $config::config && 'HASH' eq ref $config::config && $config::config
defined $config::config and "HASH" eq ref $config::config
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | $c ||= %config::config ? \%config::config : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$c ||= %config::config ? \%config::config : undef
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | "HASH" eq ref $c or $c = { failed_load => ($@ || "missing config::config hash") }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ || 'missing config::config hash'
MC/DC0%0/1
$@ || 'missing config::config hash'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/11
$name ||= (my $n = $self->base_class || ref $self || $self || "") =~ /(\w+)$/ ? lc $1 : ""
$self->base_class || ref $self || $self || ''
$self->base_class or ref $self or $self
$self->base_class or ref $self
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
ref $$c{"${name}_service"} and exists $$c{"${name}_service"}{$key}
ref $c->{$name} and exists $c->{$name}{$key}
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}
Truth table0%0/3
A and B
A= ref $c->{$name}B= exists $c->{$name}{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | : ref($def) eq 'CODE' ? $def->($self) : $def; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||