| 1 | package Net::Respite::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Net::Respite::Base - base class for Respite related modules that can be used from a server or commandline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use base 'Net::Respite::Common'; # Default _configs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use autouse 'Net::Respite::Validate' => qw(validate); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Scalar::Util qw(blessed weaken); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Throw qw(throw); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | our $max_recurse = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 13 | ▶ | sub SHARE {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SHARE: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my ($self, $key, $def, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $c = $self->_configs($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | return exists($self->{$key}) ? $self->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | : exists($c->{"${name}_service_${key}"}) ? $c->{"${name}_service_${key}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | : (ref($c->{"${name}_service"}) && exists $c->{"${name}_service"}->{$key}) ? $c->{"${name}_service"}->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | : exists($c->{"${name}_${key}"}) ? $c->{"${name}_${key}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | : ref($def) eq 'CODE' ? $def->($self) : $def; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub run_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_method: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my ($self, $meth, $args, $extra) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my $meta = $self->api_meta || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->api_meta || {}
MC/DC0%0/1
$self->api_meta || {}
$self->api_meta
Truth table0%0/2
A
A= $self->api_meta
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $begin = $meta->{'log_prefix'} ? Time::HiRes::time() : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $meth =~ tr|/.-|___|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | throw "Cannot call method", {class => ref($self), meth => $meth} if $self->_restrict($meth); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my $code = $self->find_method($meth) || throw "Invalid Respite method", {class => ref($self), method => $meth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->find_method($meth) || throw('Invalid Respite method', {'class', ref $self, 'method', $meth})
MC/DC0%0/2
$self->find_method($meth) || throw('Invalid Respite method', {'class', ref $self, 'method', $meth})
$self->find_method($meth)
throw('Invalid Respite method', {'class', ref $self, 'method', $meth})
Truth table0%0/3
A || B
A= $self->find_method($meth)B= throw('Invalid Respite method', {'class', ref $self, 'method', $meth})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $utf8 = $meta->{'utf8_encoded'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $enc = $utf8 && (!ref($utf8) || $utf8->{$meth}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$utf8 && (!ref($utf8) || $utf8->{$meth})
not ref $utf8 or $utf8->{$meth}
MC/DC0%0/3
$utf8 && (!ref($utf8) || $utf8->{$meth})
$utf8
not ref $utf8
$utf8->{$meth}
Truth table0%0/4
A && not(B) or C
A= $utf8B= not ref $utf8C= $utf8->{$meth}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $trp = $self->{'transport'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'transport'} || ''
MC/DC0%0/1
$self->{'transport'} || ''
$self->{'transport'}
Truth table0%0/2
A
A= $self->{'transport'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ($enc) { # consistently handle args from json, form, or commandline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | _encode_utf8_recurse($args) if $trp eq 'json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | _decode_utf8_recurse($args) if $trp && $trp ne 'json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$trp and $trp ne "json"
MC/DC0%0/2
$trp and $trp ne "json"
$trp
$trp ne "json"
Truth table0%0/3
A and B
A= $trpB= $trp ne "json"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my $resp = eval { $self->$code($args, $extra) } || do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
$self->$code($args, $extra)
}
} || do {
my $resp = $@;
$resp = eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
} || $@ unless ref $resp and $resp->{'error'};
warn $resp if $trp ne 'cmdline';
$resp
}
MC/DC0%0/2
eval {
do {
$self->$code($args, $extra)
}
} || do {
my $resp = $@;
$resp = eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
} || $@ unless ref $resp and $resp->{'error'};
warn $resp if $trp ne 'cmdline';
$resp
}
eval {
do {
$self->$code($args, $extra)
}
}
do {
my $resp = $@;
$resp = eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
} || $@ unless ref $resp and $resp->{'error'};
warn $resp if $trp ne 'cmdline';
$resp
}
Truth table0%0/3
A || B
A= eval {
do {
$self->$code($args, $extra)
}
}B= do {
my $resp = $@;
$resp = eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
} || $@ unless ref $resp and $resp->{'error'};
warn $resp if $trp ne 'cmdline';
$resp
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $resp = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $resp = eval { throw 'Trouble dispatching', {method => $meth, msg => $resp} } || $@ if !ref($resp) || !$resp->{'error'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $resp and $resp->{"error"}
eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
} || $@
MC/DC0%0/2
ref $resp and $resp->{"error"}
ref $resp
$resp->{"error"}
MC/DC0%0/2
eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
} || $@
eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
}
$@
Truth table0%0/3
A and B
A= ref $respB= $resp->{"error"}
Truth table0%0/3
A || B
A= eval {
do {
throw('Trouble dispatching', {'method', $meth, 'msg', $resp})
}
}B= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | warn $resp if $trp ne 'cmdline'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | $self->log_request({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | method => $meth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | request => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | response => $resp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | api_ip => $self->{'api_ip'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | api_brand => $self->{'api_brand'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | remote_ip => $self->{'remote_ip'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | remote_user => $self->{'remote_user'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | admin_user => $self->{'admin_user'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | caller => $self->{'caller'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | elapsed => (Time::HiRes::time() - $begin), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }) if $begin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | _decode_utf8_recurse($resp) if ref($resp) eq 'HASH' && exists($resp->{'_utf8_encoded'}) ? delete($resp->{'_utf8_encoded'}) : $enc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $resp eq "HASH" and exists $resp->{"_utf8_encoded"}
MC/DC0%0/2
ref $resp eq "HASH" and exists $resp->{"_utf8_encoded"}
ref $resp eq "HASH"
exists $resp->{"_utf8_encoded"}
Truth table0%0/3
A and B
A= ref $resp eq "HASH"B= exists $resp->{"_utf8_encoded"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub _restrict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_restrict: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ($class, $meth) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | return 0 if __PACKAGE__->SUPER::can($meth); # any of the inherited methods from Net::Respite::Base are not Respite methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return $meth =~ /^_/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 31 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 31 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 31 | ▶ | my $meth = $Net::Respite::Base::AUTOLOAD =~ /::(\w+)$/ ? $1 : throw "Invalid method", {method => $Net::Respite::Base::AUTOLOAD}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 31 | ▶ | throw "Self was not passed while looking up method", {method => $meth, trace => 1} if ! blessed $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 31 | ▶ | local $self->{'_autoload'}->{$meth} = ($self->{'_autoload'}->{$meth} || 0) + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'_autoload'}{$meth} || 0
MC/DC0%0/1
$self->{'_autoload'}{$meth} || 0
$self->{'_autoload'}{$meth}
Truth table50%1/2
A
A= $self->{'_autoload'}{$meth}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 31 | ▶ | throw "Recursive method lookup", {class => ref($self), method => $meth} if $self->{'_autoload'}->{$meth} > $max_recurse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 31 | ▶ | my $code = $self->find_method($meth) || throw "Invalid Respite method during AUTOLOAD", {class => ref($self), method => $meth}, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->find_method($meth) || throw('Invalid Respite method during AUTOLOAD', {'class', ref $self, 'method', $meth}, 1)
MC/DC0%0/2
$self->find_method($meth) || throw('Invalid Respite method during AUTOLOAD', {'class', ref $self, 'method', $meth}, 1)
$self->find_method($meth)
throw('Invalid Respite method during AUTOLOAD', {'class', ref $self, 'method', $meth}, 1)
Truth table33%1/3
A || B
A= $self->find_method($meth)B= throw('Invalid Respite method during AUTOLOAD', {'class', ref $self, 'method', $meth}, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 30 | return $self->$code(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 9 | ▶ | sub api_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_meta: called CC=4 SCAR=15.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 9 | my $ref = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | return ${"${ref}::api_meta"} if ${"${ref}::api_meta"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 9 | ▶ | return $self->{'api_meta'} ||= ($ref eq __PACKAGE__ ? throw "No api_meta defined", {class => $self, type => 'no_meta'} : {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"api_meta"} ||= $ref eq __PACKAGE__ ? throw("No api_meta defined", {"class", $self, "type", "no_meta"}) : {}
MC/DC0%0/2
$self->{"api_meta"} ||= $ref eq __PACKAGE__ ? throw("No api_meta defined", {"class", $self, "type", "no_meta"}) : {}
$self->{"api_meta"}
$ref eq __PACKAGE__ ? throw("No api_meta defined", {"class", $self, "type", "no_meta"}) : {}
Truth table33%1/3
A ||= B
A= $self->{"api_meta"}B= $ref eq __PACKAGE__ ? throw("No api_meta defined", {"class", $self, "type", "no_meta"}) : {}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub api_preload { shift->find_method; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_preload: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub _encode_utf8_recurse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_utf8_recurse: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $d = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (UNIVERSAL::isa($d, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | for my $k (keys %$d) { my $v = $d->{$k}; (ref $v) ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v) and utf8::encode($d->{$k}) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
ref $v ? _encode_utf8_recurse($v) : $v
utf8::is_utf8($v)
Truth table0%0/3
A and B
A= ref $v ? _encode_utf8_recurse($v) : $vB= utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } elsif (UNIVERSAL::isa($d, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | for my $v (@$d) { (ref $v) ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v) and utf8::encode($v) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
ref $v ? _encode_utf8_recurse($v) : $v
utf8::is_utf8($v)
Truth table0%0/3
A and B
A= ref $v ? _encode_utf8_recurse($v) : $vB= utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub _decode_utf8_recurse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_utf8_recurse: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $d = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my $seen = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return if $seen->{$d}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if (UNIVERSAL::isa($d, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | for my $k (keys %$d) { my $v = $d->{$k}; (ref $v) ? _decode_utf8_recurse($v, $seen) : $v and !utf8::is_utf8($v) and utf8::decode($d->{$k}) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
ref $v ? _decode_utf8_recurse($v, $seen) : $v
not utf8::is_utf8($v)
Truth table0%0/3
A and not(B)
A= ref $v ? _decode_utf8_recurse($v, $seen) : $vB= not utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } elsif (UNIVERSAL::isa($d, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | for my $v (@$d) { (ref $v) ? _decode_utf8_recurse($v, $seen) : $v and !utf8::is_utf8($v) and utf8::decode($v) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
ref $v ? _decode_utf8_recurse($v, $seen) : $v
not utf8::is_utf8($v)
Truth table0%0/3
A and not(B)
A= ref $v ? _decode_utf8_recurse($v, $seen) : $vB= not utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | sub validate_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_args: called CC=17 SCAR=43.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | my ($self, $args, $val_hash) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | ▶ | my $sub = (caller(my $n = 1))[3]; $sub = (caller ++$n)[3] while $sub eq '(eval)' || $sub =~ /::validate_args$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sub eq "(eval)" or $sub =~ /::validate_args$/
MC/DC0%0/2
$sub eq "(eval)" or $sub =~ /::validate_args$/
$sub eq "(eval)"
$sub =~ /::validate_args$/
Truth table33%1/3
A or B
A= $sub eq "(eval)"B= $sub =~ /::validate_args$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | ▶ | if (! $val_hash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | my $code = $self->can("${sub}__meta") or throw "Could not find meta information.", {method => $sub}, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | my $meta = $code->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | $val_hash = $meta->{'args'} || throw "Missing args in meta information", {method => $sub}, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$meta->{'args'} || throw('Missing args in meta information', {'method', $sub}, 1)
MC/DC0%0/2
$meta->{'args'} || throw('Missing args in meta information', {'method', $sub}, 1)
$meta->{'args'}
throw('Missing args in meta information', {'method', $sub}, 1)
Truth table33%1/3
A || B
A= $meta->{'args'}B= throw('Missing args in meta information', {'method', $sub}, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if (my $ra = $meta->{'requires_admin'} and (eval { $self->api_meta->{'enforce_requires_admin'} } || do { my $e = $@; die $e if $e && (!ref($e) || $e->{'type'} ne 'no_meta'); 0 })) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition8%1/12
my $ra = $meta->{"requires_admin"} and eval {
do {
$self->api_meta->{"enforce_requires_admin"}
}
} || do {
my $e = $@;
die $e if $e and !ref($e) || $e->{"type"} ne "no_meta";
0
}
eval {
do {
$self->api_meta->{"enforce_requires_admin"}
}
} or do {
my $e = $@;
die $e if $e and !ref($e) || $e->{"type"} ne "no_meta";
0
}
$e and !ref($e) || $e->{"type"} ne "no_meta"
not ref $e or $e->{"type"} ne "no_meta"
MC/DC0%0/3
my $ra = $meta->{"requires_admin"} and eval {
do {
$self->api_meta->{"enforce_requires_admin"}
}
} || do {
my $e = $@;
die $e if $e and !ref($e) || $e->{"type"} ne "no_meta";
0
}
my $ra = $meta->{"requires_admin"}
eval {
do {
$self->api_meta->{"enforce_requires_admin"}
}
}
do {
my $e = $@;
die $e if $e and !ref($e) || $e->{"type"} ne "no_meta";
0
}
MC/DC0%0/3
$e and !ref($e) || $e->{"type"} ne "no_meta"
$e
not ref $e
$e->{"type"} ne "no_meta"
Truth table25%1/4
A and B or C
A= my $ra = $meta->{"requires_admin"}B= eval {
do {
$self->api_meta->{"enforce_requires_admin"}
}
}C= do {
my $e = $@;
die $e if $e and !ref($e) || $e->{"type"} ne "no_meta";
0
}
Truth table0%0/4
A and not(B) or C
A= $eB= not ref $eC= $e->{"type"} ne "no_meta"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $self->require_admin(ref($ra) eq 'CODE' ? $ra->($self, $sub, $args) : ref($ra) eq 'HASH' ? $ra : {$ra => 1, method => $sub}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | ▶ | my $error_hash = validate($args || {}, $val_hash) || return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
validate($args || {}, $val_hash) || (return 1)
$args || {}
MC/DC100%1/1
validate($args || {}, $val_hash) || (return 1)
validate($args || {}, $val_hash)
MC/DC0%0/1
$args || {}
$args
Truth table100%2/2
A
A= validate($args || {}, $val_hash)
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | throw "Failed to validate args", { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | errors => $error_hash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | type => 'validation', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | ($args->{'_no_trace'} ? () : (trace => 1)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | }, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | sub api_ip { $_[0]->{'api_ip'} || ($_[0]->{'base'} ? $_[0]->{'base'}->api_ip : throw "Missing api_ip",0,1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_ip: called CC=3 SCAR=16.0
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | sub api_brand { $_[0]->{'api_brand'} || ($_[0]->{'base'} ? $_[0]->{'base'}->api_brand : ($_[0]->is_local && $ENV{'PROV'}) || throw "Missing api_brand",0,1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_brand: called CC=5 SCAR=22.0
Pod
documented
Branch: 2 branches
Condition33%2/6
$_[0]->is_local and $ENV{"PROV"} or throw("Missing api_brand", 0, 1)
$_[0]->is_local and $ENV{"PROV"}
MC/DC0%0/3
$_[0]->is_local and $ENV{"PROV"} or throw("Missing api_brand", 0, 1)
$_[0]->is_local
$ENV{"PROV"}
throw("Missing api_brand", 0, 1)
Truth table0%0/5
A and B or C
A= $_[0]->is_localB= $ENV{"PROV"}C= throw("Missing api_brand", 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub remote_ip { $_[0]->{'remote_ip'} || ($_[0]->{'base'} ? $_[0]->{'base'}->remote_ip : throw "Missing remote_ip",0,1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remote_ip: not called CC=3 SCAR=24.8
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub remote_user { $_[0]->{'remote_user'} || ($_[0]->{'base'} ? $_[0]->{'base'}->remote_user : throw "Missing remote_user",0,1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remote_user: not called CC=3 SCAR=24.8
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub admin_user { $_[0]->{'admin_user'} || ($_[0]->{'base'} ? $_[0]->{'base'}->admin_user : throw "Not authenticated",0,1) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
admin_user: not called CC=3 SCAR=24.8
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | sub transport { $_[0]->{'transport'} || ($_[0]->{'base'} ? $_[0]->{'base'}->transport : '') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transport: called CC=3 SCAR=12.7
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub is_server { exists($_[0]->{'is_server'}) ? $_[0]->{'is_server'} : ($_[0]->{'base'} && $_[0]->{'base'}->is_server) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_server: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
Condition0%0/3
$_[0]{"base"} and $_[0]{"base"}->is_server
MC/DC0%0/2
$_[0]{"base"} and $_[0]{"base"}->is_server
$_[0]{"base"}
$_[0]{"base"}->is_server
Truth table0%0/3
A and B
A= $_[0]{"base"}B= $_[0]{"base"}->is_server
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub is_authed { eval { shift->admin_user } ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_authed: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | sub is_local { $_[0]->transport =~ /^(?:cmdline|gui)$/ ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_local: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub who { shift->remote_user } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
who: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub base { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if (! $self->{'base'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | throw "Could not find base when called_from_base",0,1 if $self->{'called_from_base'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $class = $self->base_class || throw "Could not find a base_class when accessing base from direct source",0,1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->base_class || throw('Could not find a base_class when accessing base from direct source', 0, 1)
MC/DC0%0/2
$self->base_class || throw('Could not find a base_class when accessing base from direct source', 0, 1)
$self->base_class
throw('Could not find a base_class when accessing base from direct source', 0, 1)
Truth table0%0/3
A || B
A= $self->base_classB= throw('Could not find a base_class when accessing base from direct source', 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | return $self if ref($self) eq $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | (my $file = "$class.pm") =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | eval { require $file } || throw "Could not load base_class", {msg => $@, class => $class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $self->{'base'} = $class->new({$self->SHARE, map {$_ => $self->{$_}} qw(api_ip api_brand remote_ip remote_user admin_user is_server)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | return $self->{'base'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub base_class { shift->{'base_class'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base_class: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 40 | ▶ | sub find_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_method: called CC=72 SCAR=46.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 40 | my ($self, $meth, $opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 40 | ▶ | my $meta = $self->api_meta || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->api_meta || {}
MC/DC0%0/1
$self->api_meta || {}
$self->api_meta
Truth table50%1/2
A
A= $self->api_meta
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 40 | ▶ | my $cache = $meta->{'_cache'}->{ref($self)} ||= {%{ $meta->{'methods'} || {} }}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$meta->{"_cache"}{ref $self} ||= {%{$meta->{"methods"} or {};}}
$meta->{'methods'} || {}
MC/DC100%1/1
$meta->{"_cache"}{ref $self} ||= {%{$meta->{"methods"} or {};}}
$meta->{"_cache"}{ref $self}
MC/DC100%1/1
$meta->{'methods'} || {}
$meta->{'methods'}
Truth table100%2/2
A
A= $meta->{"_cache"}{ref $self}
Truth table100%2/2
A
A= $meta->{'methods'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 40 | ▶ | if ($meth) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 31 | ▶ | return $cache->{$meth} if exists $cache->{$meth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | ▶ | return $cache->{$meth} if exists $cache->{$meth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 8 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | return $cache->{$meth} = $code if $code = $self->can($meth) and $code ne \&{__PACKAGE__."::$meth"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$code = $self->can($meth) and $code ne \&{'Net::Respite::Base' . "::$meth";}
MC/DC0%0/2
$code = $self->can($meth) and $code ne \&{'Net::Respite::Base' . "::$meth";}
$code = $self->can($meth)
$code ne \&{'Net::Respite::Base' . "::$meth";}
Truth table33%1/3
A and B
A= $code = $self->can($meth)B= $code ne \&{'Net::Respite::Base' . "::$meth";}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 8 | ▶ | return $cache->{$meth} = $code if $code = $self->can("__$meth"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } elsif (!$cache->{'--load--'}->{'builtin'}++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 9 | my @search = ref($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 9 | ▶ | while (my $pkg = shift @search) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 16 | ▶ | unshift @search, @{"${pkg}::ISA"} if $pkg ne __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 16 | for my $meth (keys %{"${pkg}::"}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 477 | ▶ | next if ! defined &{"${pkg}::$meth"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 329 | ▶ | next if ($pkg eq __PACKAGE__) ? $meth !~ /^__/ : defined &{__PACKAGE__."::$meth"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 54 | ▶ | next if $pkg =~ /^_[a-z]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 54 | ▶ | next if $meth !~ /__meta$/ && $meth !~ /^__/ && !defined &{"${pkg}::${meth}__meta"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$meth =~ /__meta$/ or $meth =~ /^__/ or defined &{"${pkg}::${meth}__meta";}
$meth =~ /__meta$/ or $meth =~ /^__/
MC/DC0%0/3
$meth =~ /__meta$/ or $meth =~ /^__/ or defined &{"${pkg}::${meth}__meta";}
$meth =~ /__meta$/
$meth =~ /^__/
defined &{"${pkg}::${meth}__meta";}
Truth table75%3/4
A or B or C
A= $meth =~ /__meta$/B= $meth =~ /^__/C= defined &{"${pkg}::${meth}__meta";}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 54 | (my $name = $meth) =~ s/^__//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 54 | ▶ | $cache->{$name} ||= "${pkg}::$meth"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cache->{$name} ||= "${pkg}::$meth"
MC/DC100%1/1
$cache->{$name} ||= "${pkg}::$meth"
$cache->{$name}
Truth table100%2/2
A
A= $cache->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | foreach my $type ('namespaces', 'lib_dirs') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 24 | ▶ | my $NS = $meta->{$type} || next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$meta->{$type} || (next)
MC/DC100%1/1
$meta->{$type} || (next)
$meta->{$type}
Truth table100%2/2
A
A= $meta->{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 15 | ▶ | $NS = $cache->{'--load--'}->{'lib_dirs'} ||= $self->_load_lib_dir($NS) if $type eq 'lib_dirs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cache->{"--load--"}{"lib_dirs"} ||= $self->_load_lib_dir($NS)
MC/DC0%0/2
$cache->{"--load--"}{"lib_dirs"} ||= $self->_load_lib_dir($NS)
$cache->{"--load--"}{"lib_dirs"}
$self->_load_lib_dir($NS)
Truth table66%2/3
A ||= B
A= $cache->{"--load--"}{"lib_dirs"}B= $self->_load_lib_dir($NS)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 15 | foreach my $ns (sort keys %$NS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 27 | my $opt = $NS->{$ns}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 27 | ▶ | $opt = {match => $opt} if ref($opt) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 27 | ▶ | my $name = !$meth ? undef : ($meth !~ /^${ns}_*(\w+)$/) ? next : $opt->{'full_name'} ? $meth : $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 21 | ▶ | my $pkg = $opt->{'pkg'} || $opt->{'package'} || do { (my $pkg = $ns) =~ s/(?:_|\b)([a-z])/\u$1/g; $pkg }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$opt->{'pkg'} || $opt->{'package'} || do {
(my $pkg = $ns) =~ s/(?:_|\b)([a-z])/\u$1/g;
$pkg
}
$opt->{"pkg"} or $opt->{"package"}
MC/DC0%0/3
$opt->{'pkg'} || $opt->{'package'} || do {
(my $pkg = $ns) =~ s/(?:_|\b)([a-z])/\u$1/g;
$pkg
}
$opt->{"pkg"}
$opt->{"package"}
do {
(my $pkg = $ns) =~ s/(?:_|\b)([a-z])/\u$1/g;
$pkg
}
Truth table50%2/4
A or B || C
A= $opt->{"pkg"}B= $opt->{"package"}C= do {
(my $pkg = $ns) =~ s/(?:_|\b)([a-z])/\u$1/g;
$pkg
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 21 | ▶ | if (! $pkg->can('new')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | (my $file = "$pkg.pm") =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | if (! eval { require ($opt->{'file'} ||= $file) }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{"file"} ||= $file
MC/DC0%0/2
$opt->{"file"} ||= $file
$opt->{"file"}
$file
Truth table33%1/3
A ||= B
A= $opt->{"file"}B= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | warn "Failed to load listed module $pkg ($opt->{'file'}): $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | ▶ | $INC{$file} = $INC{$opt->{'file'}} if $opt->{'file'} ne $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # TODO - faster lookup if we know the method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 21 | ▶ | my $qr = $opt->{'match'} || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->{'match'} || 1
MC/DC100%1/1
$opt->{'match'} || 1
$opt->{'match'}
Truth table100%2/2
A
A= $opt->{'match'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 21 | ▶ | $qr = ($qr eq '1' || $qr eq '*') ? qr{.} : qr{^$qr} if $qr && !ref $qr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
$qr and not ref $qr
$qr eq 1 or $qr eq "*"
MC/DC0%0/2
$qr and not ref $qr
$qr
not ref $qr
MC/DC50%1/2
$qr eq 1 or $qr eq "*"
$qr eq 1
$qr eq "*"
Truth table33%1/3
A and not(B)
A= $qrB= not ref $qr
Truth table66%2/3
A or B
A= $qr eq 1B= $qr eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 21 | for my $meth (keys %{"${pkg}::"}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 111 | ▶ | next if ! defined &{"${pkg}::$meth"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 53 | ▶ | next if ($pkg eq __PACKAGE__) ? $meth !~ /^__/ : defined &{__PACKAGE__."::$meth"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 49 | ▶ | next if $meth =~ /^_[a-z]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 49 | ▶ | next if $qr && $meth !~ $qr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$qr and not $meth =~ /$qr/
MC/DC0%0/2
$qr and not $meth =~ /$qr/
$qr
not $meth =~ /$qr/
Truth table33%1/3
A and not(B)
A= $qrB= not $meth =~ /$qr/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 49 | ▶ | next if $meth !~ /__meta$/ && $meth !~ /^__/ && !defined &{"${pkg}::${meth}__meta"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$meth =~ /__meta$/ or $meth =~ /^__/ or defined &{"${pkg}::${meth}__meta";}
$meth =~ /__meta$/ or $meth =~ /^__/
MC/DC100%3/3
$meth =~ /__meta$/ or $meth =~ /^__/ or defined &{"${pkg}::${meth}__meta";}
$meth =~ /__meta$/
$meth =~ /^__/
defined &{"${pkg}::${meth}__meta";}
Truth table100%4/4
A or B or C
A= $meth =~ /__meta$/B= $meth =~ /^__/C= defined &{"${pkg}::${meth}__meta";}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 33 | (my $name = $meth) =~ s/^__//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 33 | ▶ | $name = "${ns}_${name}" if !$opt->{'full_name'} && $name !~ /^\Q$ns\E_/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{"full_name"} or $name =~ /^\Q$ns\E_/
MC/DC0%0/2
$opt->{"full_name"} or $name =~ /^\Q$ns\E_/
$opt->{"full_name"}
$name =~ /^\Q$ns\E_/
Truth table33%1/3
A or B
A= $opt->{"full_name"}B= $name =~ /^\Q$ns\E_/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 33 | ▶ | my $dt = $opt->{'dispatch_type'} || $meta->{'dispatch_type'} || 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$opt->{'dispatch_type'} || $meta->{'dispatch_type'} || 'new'
$opt->{"dispatch_type"} or $meta->{"dispatch_type"}
MC/DC100%2/2
$opt->{'dispatch_type'} || $meta->{'dispatch_type'} || 'new'
$opt->{"dispatch_type"}
$meta->{"dispatch_type"}
Truth table100%3/3
A or B
A= $opt->{"dispatch_type"}B= $meta->{"dispatch_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 4 | ▶ | $cache->{$name} ||= ($dt eq 'new') ? sub { my $base = shift; $pkg->new({base => $base, called_from_base => 1, $base->SHARE})->$meth(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | : ($dt eq 'morph') ? sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | my $base = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | my $prev = ref $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | local $base->{'base'} = $base->{'base'} || $base; weaken($base->{'base'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$base->{'base'} || $base
MC/DC0%0/2
$base->{'base'} || $base
$base->{'base'}
$base
Truth table33%1/3
A || B
A= $base->{'base'}B= $base
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | ▶ | my $resp; my $ok = eval { bless $base, $pkg; $resp = $base->$meth(@_); 1 }; my $err = $@; bless $base, $prev; die $err if ! $ok; return $resp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 13 | ▶ | : ($dt eq 'cache') ? sub { my $base = shift; ($base->{$pkg} ||= do { my $s = $pkg->new({base => $base, $base->SHARE}); weaken $s->{'base'}; $s })->$meth(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Condition66%2/3
$base->{$pkg} ||= do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
}
MC/DC0%0/2
$base->{$pkg} ||= do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
}
$base->{$pkg}
do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
}
Truth table66%2/3
A ||= B
A= $base->{$pkg}B= do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 33 | ▶ | : throw "Unknown dispatch_type", {dispatch_type => $dt}, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$cache->{$name} ||= $dt eq "new" ? sub {
my $base = shift();
$pkg->new({"base", $base, "called_from_base", 1, $base->SHARE})->$meth(@_);
}
: ($dt eq "morph" ? sub {
my $base = shift();
my $prev = ref $base;
local $base->{"base"} = $base->{"base"} || $base;
builtin::weaken($base->{"base"});
my $resp;
my $ok = eval {
do {
bless $base, $pkg;
$resp = $base->$meth(@_);
1
}
};
my $err = $@;
bless $base, $prev;
die $err unless $ok;
return $resp;
}
: ($dt eq "cache" ? sub {
my $base = shift();
($base->{$pkg} ||= do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
})->$meth(@_);
}
: throw("Unknown dispatch_type", {"dispatch_type", $dt}, 1)))
MC/DC0%0/2
$cache->{$name} ||= $dt eq "new" ? sub {
my $base = shift();
$pkg->new({"base", $base, "called_from_base", 1, $base->SHARE})->$meth(@_);
}
: ($dt eq "morph" ? sub {
my $base = shift();
my $prev = ref $base;
local $base->{"base"} = $base->{"base"} || $base;
builtin::weaken($base->{"base"});
my $resp;
my $ok = eval {
do {
bless $base, $pkg;
$resp = $base->$meth(@_);
1
}
};
my $err = $@;
bless $base, $prev;
die $err unless $ok;
return $resp;
}
: ($dt eq "cache" ? sub {
my $base = shift();
($base->{$pkg} ||= do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
})->$meth(@_);
}
: throw("Unknown dispatch_type", {"dispatch_type", $dt}, 1)))
$cache->{$name}
$dt eq "new" ? sub {
my $base = shift();
$pkg->new({"base", $base, "called_from_base", 1, $base->SHARE})->$meth(@_);
}
: ($dt eq "morph" ? sub {
my $base = shift();
my $prev = ref $base;
local $base->{"base"} = $base->{"base"} || $base;
builtin::weaken($base->{"base"});
my $resp;
my $ok = eval {
do {
bless $base, $pkg;
$resp = $base->$meth(@_);
1
}
};
my $err = $@;
bless $base, $prev;
die $err unless $ok;
return $resp;
}
: ($dt eq "cache" ? sub {
my $base = shift();
($base->{$pkg} ||= do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
})->$meth(@_);
}
: throw("Unknown dispatch_type", {"dispatch_type", $dt}, 1)))
Truth table66%2/3
A ||= B
A= $cache->{$name}B= $dt eq "new" ? sub {
my $base = shift();
$pkg->new({"base", $base, "called_from_base", 1, $base->SHARE})->$meth(@_);
}
: ($dt eq "morph" ? sub {
my $base = shift();
my $prev = ref $base;
local $base->{"base"} = $base->{"base"} || $base;
builtin::weaken($base->{"base"});
my $resp;
my $ok = eval {
do {
bless $base, $pkg;
$resp = $base->$meth(@_);
1
}
};
my $err = $@;
bless $base, $prev;
die $err unless $ok;
return $resp;
}
: ($dt eq "cache" ? sub {
my $base = shift();
($base->{$pkg} ||= do {
my $s = $pkg->new({"base", $base, $base->SHARE});
builtin::weaken($s->{"base"});
$s
})->$meth(@_);
}
: throw("Unknown dispatch_type", {"dispatch_type", $dt}, 1)))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 21 | ▶ | if (($meta->{'allow_nested'} || $opt->{'allow_nested'}) && defined(&{"${pkg}::api_meta"}) && $pkg->can('find_method')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$meta->{"allow_nested"} || $opt->{"allow_nested"} and defined &{"${pkg}::api_meta";} and $pkg->can("find_method")
$meta->{"allow_nested"} || $opt->{"allow_nested"} and defined &{"${pkg}::api_meta";}
$meta->{"allow_nested"} or $opt->{"allow_nested"}
MC/DC25%1/4
$meta->{"allow_nested"} || $opt->{"allow_nested"} and defined &{"${pkg}::api_meta";} and $pkg->can("find_method")
$meta->{"allow_nested"}
$opt->{"allow_nested"}
defined &{"${pkg}::api_meta";}
$pkg->can("find_method")
Truth table28%2/7
A or B and C and D
A= $meta->{"allow_nested"}B= $opt->{"allow_nested"}C= defined &{"${pkg}::api_meta";}D= $pkg->can("find_method")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | my $c2 = $pkg->new({$self->SHARE})->find_method; # TODO - pass them in | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | for my $meth (keys %$c2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 18 | ▶ | next if $qr && $meth !~ $qr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$qr and not $meth =~ /$qr/
MC/DC0%0/2
$qr and not $meth =~ /$qr/
$qr
not $meth =~ /$qr/
Truth table33%1/3
A and not(B)
A= $qrB= not $meth =~ /$qr/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 18 | ▶ | $name = (!$opt->{'full_name'} && $meth !~ /^\Q$ns\E_/) ? "${ns}_${meth}" : $meth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{'full_name'} || $meth =~ /^\Q$ns\E_/
MC/DC0%0/2
$opt->{'full_name'} || $meth =~ /^\Q$ns\E_/
$opt->{'full_name'}
$meth =~ /^\Q$ns\E_/
Truth table33%1/3
A || B
A= $opt->{'full_name'}B= $meth =~ /^\Q$ns\E_/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 18 | $cache->{$name} = $c2->{$meth}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 21 | ▶ | return $cache->{$meth} if $meth && $cache->{$meth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$meth and $cache->{$meth}
MC/DC50%1/2
$meth and $cache->{$meth}
$meth
$cache->{$meth}
Truth table66%2/3
A and B
A= $methB= $cache->{$meth}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 10 | ▶ | return $cache->{$meth} = 0 if $meth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 9 | return $cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | sub _load_lib_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_lib_dir: called CC=13 SCAR=33.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | my ($self, $NS) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | ▶ | if ($NS eq '1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | throw "lib_dirs cannot be 1 when accessed from Net::Respite::Base directly" if ref($self) eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | (my $file = ref($self).".pm") =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | (my $dir = $INC{$file} || '') =~ s|\.pm$|| or throw "Could not determine library path location for lib_dirs", {file => $file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$INC{$file} || ''
MC/DC0%0/1
$INC{$file} || ''
$INC{$file}
Truth table0%0/2
A
A= $INC{$file}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $NS = {$dir => {pkg_prefix => ref($self)}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | my %h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | foreach my $dir (keys %$NS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | opendir my $dh, $dir or do { warn "Failed to opendir $dir: $!"; next }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | my $opt = $NS->{$dir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | ▶ | $opt = {match => $opt} if ref($opt) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 3 | ▶ | my $prefix = $opt->{'pkg_prefix'} ? "$opt->{'pkg_prefix'}::" : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | foreach my $sub (readdir $dh) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 12 | ▶ | next if $sub !~ /^([a-zA-Z]\w*)\.pm$/; # TODO - possibly handle dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | my $pkg = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | ▶ | next if $opt->{'pkg_exclude'} && $pkg =~ $opt->{'pkg_exclude'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{"pkg_exclude"} and $pkg =~ /$opt->{"pkg_exclude"}/
MC/DC0%0/2
$opt->{"pkg_exclude"} and $pkg =~ /$opt->{"pkg_exclude"}/
$opt->{"pkg_exclude"}
$pkg =~ /$opt->{"pkg_exclude"}/
Truth table33%1/3
A and B
A= $opt->{"pkg_exclude"}B= $pkg =~ /$opt->{"pkg_exclude"}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | (my $name = $pkg) =~ s/(?: (?<=[a-z])(?=[A-Z]) | (?<=[A-Z])(?=[A-Z][a-z]) )/_/xg; # FooBar => Foo_Bar, RespiteUser => Respite_User | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | $h{lc $name} = {%$opt, pkg => "$prefix$pkg", file => "$dir/$sub"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | return \%h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | ▶ | sub __methods__meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__methods__meta: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | ▶ | my $class = ref($_[0]) || $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | desc => "Return a list of all known $class methods. Optionally return all meta information as well", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | args => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | meta => {desc => 'If true, returns all meta information for the method instead of just the description'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | method => {desc => 'If passed will be used to filter the available methods - can contain * as a wildcard'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | resp => {methods => 'hashref of available method/description pairs. Will return method/metainfo pairs if meta => 1 is passed.'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | ▶ | sub __methods { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__methods: called CC=14 SCAR=30.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | ▶ | my $pkg = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | my %m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my $qr = !$args->{'method'} ? undef : do { (my $p = $args->{'method'}) =~ s/\*/.*/g; qr/^$p$/i }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | my $meths = $self->find_method(); # will load all | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | foreach my $meth (keys %$meths) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 36 | ▶ | next if $meth !~ /^(\w+)__meta$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 14 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 14 | ▶ | next if $qr && $name !~ $qr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$qr and not $name =~ /$qr/
MC/DC0%0/2
$qr and not $name =~ /$qr/
$qr
not $name =~ /$qr/
Truth table33%1/3
A and not(B)
A= $qrB= not $name =~ /$qr/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 14 | ▶ | my $meta = eval { $self->$meth() } || do { (my $err = $@ || '') =~ s/ at \/.*//s; {desc => "Not documented".($err ? ": $err" : '')} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
eval {
do {
$self->$meth
}
} || do {
(my $err = $@ || '') =~ s[ at /.*][]s;
+{'desc', 'Not documented' . ($err ? ": $err" : '')}
}
$@ || ''
MC/DC0%0/2
eval {
do {
$self->$meth
}
} || do {
(my $err = $@ || '') =~ s[ at /.*][]s;
+{'desc', 'Not documented' . ($err ? ": $err" : '')}
}
eval {
do {
$self->$meth
}
}
do {
(my $err = $@ || '') =~ s[ at /.*][]s;
+{'desc', 'Not documented' . ($err ? ": $err" : '')}
}
MC/DC0%0/1
$@ || ''
$@
Truth table66%2/3
A || B
A= eval {
do {
$self->$meth
}
}B= do {
(my $err = $@ || '') =~ s[ at /.*][]s;
+{'desc', 'Not documented' . ($err ? ": $err" : '')}
}
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 14 | ▶ | next if $ENV{'REQUEST_METHOD'} && $meta->{'no_listing'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{"REQUEST_METHOD"} and $meta->{"no_listing"}
MC/DC0%0/2
$ENV{"REQUEST_METHOD"} and $meta->{"no_listing"}
$ENV{"REQUEST_METHOD"}
$meta->{"no_listing"}
Truth table33%1/3
A and B
A= $ENV{"REQUEST_METHOD"}B= $meta->{"no_listing"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 14 | ▶ | $m{$name} = $args->{'meta'} ? $meta : $meta->{'no_listing'} ? "(Not listed in Web Respite) $meta->{'desc'}" : $meta->{'desc'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 14 | delete $meta->{'api_enum'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | return {methods => \%m}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 3 | ▶ | sub __hello__meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__hello__meta: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 3 | desc => 'Basic call to test connection', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | args => {test_auth => {validate_if => 'test_auth', enum => ['', 0, 1], desc => 'Optional - if passed it will require authentication'}}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | resp => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | server_time => "Server epoch time", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | args => "Echo of the passed in args", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | api_ip => 'IP', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | api_brand => 'Which brand is in use (if any)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | admin_user => 'Returned if test_auth is passed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | sub __hello { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__hello: called CC=6 SCAR=20.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | ▶ | sleep $args->{'sleep'} if $args->{'sleep'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | ▶ | throw delete($args->{'fail'}), {args => $args} if $args->{'fail'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | server_time => time(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | api_ip => $self->api_ip, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | ▶ | api_brand => eval { $self->api_brand } || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args->{"test_auth"} and $self->require_admin
MC/DC0%0/2
$args->{"test_auth"} and $self->require_admin
$args->{"test_auth"}
$self->require_admin
Truth table33%1/3
A and B
A= $args->{"test_auth"}B= $self->require_admin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ($args->{'test_auth'} && $self->require_admin ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | admin_user => $self->admin_user, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | ▶ | token => $self->{'new_token'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
$self->api_brand
}
} || undef
MC/DC0%0/1
eval {
do {
$self->api_brand
}
} || undef
eval {
do {
$self->api_brand
}
}
Truth table50%1/2
A
A= eval {
do {
$self->api_brand
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||