| 1 | package Terse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 13 | our $VERSION = '0.28'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use Plack::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use Plack::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Cpanel::JSON::XS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use Scalar::Util qw/reftype/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use Time::HiRes qw(gettimeofday); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use Terse::WebSocket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 13 | ▶ | use Want qw/want/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 13 | ▶ | use Digest::SHA; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 13 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 13 | ▶ | use Struct::WOP qw/all/ => { type => ['UTF-8'], destruct => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | our ($JSON, %PRIVATE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 13 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | $JSON = Cpanel::JSON::XS->new->utf8->canonical(1)->allow_blessed->convert_blessed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | %PRIVATE = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 13 | map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | qw/new run logger logInfo logError websocket delayed_response build_terse content_type raiseError graft pretty serialize DESTROY TO_JSON AUTOLOAD to_app/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 44 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 44 | my ($pkg, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 44 | ▶ | $pkg = ref $pkg if ref $pkg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 44 | ▶ | if (delete $args{private}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | for my $key (keys %args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 41 | ▶ | if ($key !~ m/^_/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 41 | $args{"_$key"} = delete $args{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 44 | return bless \%args, $pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=31 SCAR=48.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | my ($pkg, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | my $j = $pkg->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | private => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | login => 'login', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | logout => 'logout', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | auth => 'auth', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | insecure_session => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | content_type => 'application/json', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | request_class => 'Plack::Request', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | websocket_class => 'Terse::WebSocket', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | sock => 'psgix.io', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | stream_check => 'psgi.streaming', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | favicon => 'favicon.ico', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | %args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | $j->headers = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | $j->_build_terse(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | $j->request = $j->{_request_class}->new($args{plack_env}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | $j->response = $pkg->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | authenticated => \0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | error => \0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | errors => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | if ($j->request->env->{PATH_INFO} =~ m/favicon.ico$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | return [500, [], []] unless -f $j->_favicon; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | open my $fh, '<', $j->_favicon; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $favicon = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return [200, ['Content-Type', 'image/vnd.microsoft.icon'], [$favicon] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | my $content_type = $j->request->content_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | if ($content_type && $content_type =~ m/application\/json/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$content_type and $content_type =~ m[application/json]
MC/DC0%0/2
$content_type and $content_type =~ m[application/json]
$content_type
$content_type =~ m[application/json]
Truth table33%1/3
A and B
A= $content_typeB= $content_type =~ m[application/json]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $j->graft('params', $j->request->raw_body || "{}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$j->request->raw_body || '{}'
MC/DC0%0/1
$j->request->raw_body || '{}'
$j->request->raw_body
Truth table0%0/2
A
A= $j->request->raw_body
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | ▶ | $j->params = {%{$j->request->parameters || {}}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$j->request->parameters || {}
MC/DC0%0/1
$j->request->parameters || {}
$j->request->parameters
Truth table50%1/2
A
A= $j->request->parameters
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | unless ((reftype($j->params) || "") eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($j->params) || ''
MC/DC0%0/1
builtin::reftype($j->params) || ''
builtin::reftype($j->params)
Truth table50%1/2
A
A= builtin::reftype($j->params)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $j->response->raiseError('Invalid parameters', 400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return $j->_response($j->response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | $j->sid = $j->request->cookies->{sid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | ▶ | unless ($j->sid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $h = Digest::SHA->new(256); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my @us = gettimeofday; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | push @us, map { $j->request->env->{$_} } grep { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $_ =~ /^HTTP(?:_|$)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | } keys %{ $j->request->env }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $h->add(@us); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $j->sid = $h->hexdigest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $j->sid = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | value => $j->is_logout ? "" : $j->sid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | path => $j->{_sid_path} || $j->{_root_path} || "/", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | secure => !$j->{_insecure_session}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | ▶ | samesite => 'none' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$j->{'_sid_path'} || $j->{'_root_path'} || '/'
$j->{"_sid_path"} or $j->{"_root_path"}
MC/DC0%0/2
$j->{'_sid_path'} || $j->{'_root_path'} || '/'
$j->{"_sid_path"}
$j->{"_root_path"}
Truth table33%1/3
A or B
A= $j->{"_sid_path"}B= $j->{"_root_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | my $auth = $j->{_auth}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | my ($session) = $j->_dispatch($auth, $pkg->new()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | my $req = $j->params->req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | ▶ | $req =~ /^([a-z][0-9a-zA-Z_]{1,31})$/ && do { $req = $1 // '' } if $req; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition37%3/8
$req && ($req =~ /^([a-z][0-9a-zA-Z_]{1,31})$/ && do {
$req = $1 // ''
})
$req =~ /^([a-z][0-9a-zA-Z_]{1,31})$/ and do {
$req = $1 // ""
}
$1 // ""
MC/DC0%0/3
$req && ($req =~ /^([a-z][0-9a-zA-Z_]{1,31})$/ && do {
$req = $1 // ''
})
$req
$req =~ /^([a-z][0-9a-zA-Z_]{1,31})$/
do {
$req = $1 // ""
}
MC/DC0%0/1
$1 // ""
$1
Truth table0%0/4
A && B and C
A= $reqB= $req =~ /^([a-z][0-9a-zA-Z_]{1,31})$/C= do {
$req = $1 // ""
}
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | ▶ | $req = $j->{_application}->preprocess_req($req, $j) if $j->{_application}->can('preprocess_req'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | if (!$req || !$session || $PRIVATE{$req}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $req && $session or $Terse::PRIVATE{$req}
$req && $session
MC/DC0%0/3
not $req && $session or $Terse::PRIVATE{$req}
$req
$session
$Terse::PRIVATE{$req}
Truth table25%1/4
not(A && B) or C
A= $reqB= $sessionC= $Terse::PRIVATE{$req}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $j->response->raiseError('Invalid request', 400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return $j->_response($j->response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | $j->req = $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | $j->response->authenticated = \1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | $j->session = $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | $j->sid->expires = (ref $j->session && $j->session->expires) || (time + 24 * 60 * 60) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $j->session && $j->session->expires || time + 86400
ref $j->session and $j->session->expires
MC/DC0%0/3
ref $j->session && $j->session->expires || time + 86400
ref $j->session
$j->session->expires
time + 86400
Truth table0%0/5
A and B || C
A= ref $j->sessionB= $j->session->expiresC= time + 86400
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | if (!$j->sid->expires); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ($j->is_login, $j->is_logout) = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | $j->{_login} eq $req, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 3 | $j->{_logout} eq $req | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | my ($out) = $j->_dispatch($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | ▶ | return $j->_response($j->response) if $j->response->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | $j->session = $out if ( $j->is_login || $j->is_logout ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$j->is_login or $j->is_logout
MC/DC0%0/2
$j->is_login or $j->is_logout
$j->is_login
$j->is_logout
Truth table33%1/3
A or B
A= $j->is_loginB= $j->is_logout
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | ($j->session) = $j->_dispatch($auth, $j->session) if $j->response->authenticated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | if ((!$j->response->authenticated || !$j->session) && !($j->is_login || $j->is_logout)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$j->response->authenticated and $j->session or ($j->is_login or $j->is_logout)
$j->response->authenticated and $j->session
$j->is_login or $j->is_logout
MC/DC25%1/4
$j->response->authenticated and $j->session or ($j->is_login or $j->is_logout)
$j->response->authenticated
$j->session
$j->is_login
$j->is_logout
Truth table28%2/7
A and B or C or D
A= $j->response->authenticatedB= $j->sessionC= $j->is_loginD= $j->is_logout
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | $j->response->raiseError('Unauthenticated during the request', 400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | return $j->_response($j->response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | return $j->_response($j->response, $j->sid, $j->content_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub to_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_app: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my ($self, $new, $run) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $app = $self->new($new ? %{ $new } : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my ($env) = (shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | Terse->run( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | plack_env => $env, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | application => $app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | ($env->{'psgix.logger'} ? (logger => $env->{'psgix.logger'}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | ▶ | sub logger { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logger: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | my ($self, $logger) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | $self->{_logger} = $logger if ($logger); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | return $self->{_logger}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | ▶ | sub logError { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logError: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 4 | my ($self, $message, $status, $no_response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | $self->{_application} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | ▶ | ? $self->response->raiseError($message, $status) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | : $self->raiseError($message, $status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4 | ▶ | $message = { message => $message } if (!ref $message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | $message = $self->{_application}->_logError($message, $status) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | ▶ | if ($self->{_application} && $self->{_application}->can('_logError')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"_application"} and $self->{"_application"}->can("_logError")
MC/DC100%2/2
$self->{"_application"} and $self->{"_application"}->can("_logError")
$self->{"_application"}
$self->{"_application"}->can("_logError")
Truth table100%3/3
A and B
A= $self->{"_application"}B= $self->{"_application"}->can("_logError")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ref $self->{_logger} eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ? $self->{_logger}->('error', $message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | : $self->{_logger}->error($message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 4 | ▶ | if $self->{_logger}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | ▶ | $self->response->no_response = 1 if $no_response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | ▶ | sub logInfo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logInfo: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | my ($self, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 8 | ▶ | $message = { message => $message } if (!ref $message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | $message = $self->{_application}->_logInfo($message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 8 | ▶ | if ($self->{_application} && $self->{_application}->can('_logInfo')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_application"} and $self->{"_application"}->can("_logInfo")
MC/DC50%1/2
$self->{"_application"} and $self->{"_application"}->can("_logInfo")
$self->{"_application"}
$self->{"_application"}->can("_logInfo")
Truth table66%2/3
A and B
A= $self->{"_application"}B= $self->{"_application"}->can("_logInfo")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ref $self->{_logger} eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ? $self->{_logger}->('info', $message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | : $self->{_logger}->info($message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 8 | ▶ | if $self->{_logger}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 6 | ▶ | sub raiseError { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raiseError: called CC=6 SCAR=20.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | my ($self, $message, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | ▶ | return $self->response->raiseError($message, $code) if $self->{_application}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | $self->{error} = \1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | ▶ | if ((reftype($message) || '') eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
builtin::reftype($message) || ''
MC/DC100%1/1
builtin::reftype($message) || ''
builtin::reftype($message)
Truth table100%2/2
A
A= builtin::reftype($message)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | push @{$self->{errors}}, @{$message}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | push @{$self->{errors}}, $message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6 | ▶ | $self->{status_code} = $code if ($code && !$self->{status_code}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$code and not $self->{"status_code"}
MC/DC0%0/2
$code and not $self->{"status_code"}
$code
not $self->{"status_code"}
Truth table33%1/3
A and not(B)
A= $codeB= not $self->{"status_code"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 5 | ▶ | sub graft { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
graft: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 5 | my ($self, $name, $json) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | ▶ | unless ($json =~ m/[\{\[]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $self->{$name} = $json; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | return $self->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | $self->{$name} = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | $JSON->decode($json); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | ▶ | return 0 if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 3 | return $self->_bless_tree($self->{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | sub pretty { $_[0]->{_pretty} = 1; $_[0]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 6 | ▶ | sub serialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 6 | my ($self, $die) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | ▶ | my $pretty = !!(reftype $self eq 'HASH' && $self->{_pretty}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::reftype($self) eq 'HASH' && $self->{'_pretty'}
MC/DC0%0/2
builtin::reftype($self) eq 'HASH' && $self->{'_pretty'}
builtin::reftype($self) eq 'HASH'
$self->{'_pretty'}
Truth table66%2/3
A && B
A= builtin::reftype($self) eq 'HASH'B= $self->{'_pretty'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | my $out = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 6 | $JSON->pretty($pretty)->encode(maybe_decode($self)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 6 | ▶ | die $@ if ($@ && $die); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ and $die
MC/DC0%0/2
$@ and $die
$@
$die
Truth table66%2/3
A and B
A= $@B= $die
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 6 | ▶ | return $out || $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$out || $@
MC/DC0%0/2
$out || $@
$out
$@
Truth table66%2/3
A || B
A= $outB= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 3 | ▶ | sub _build_terse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_terse: called CC=10 SCAR=33.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | my ($t) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 3 | ▶ | if (! $t->{_application}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $t->response->raiseError('No application passed to run', 500); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | return $t->_response($t->response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $t->{redirect} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my ($self, $url, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $url = URI->new($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $url->query_form( $url->query_form, %{$response || {}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$response || {}
MC/DC0%0/1
$response || {}
$response
Truth table0%0/2
A
A= $response
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $self->response->status_code = 302; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $self->response->message = 'Found'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $self->headers->Location = $url->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | $t->{websocket} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $websocket = $t->{_websocket_class}->new($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if (!ref $websocket) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $args{error}->($t, $websocket); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | $t->{_delayed_response} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $responder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $websocket->start($t, \%args, $responder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | return $websocket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | ▶ | } unless $t->{websocket} || !$t->{_websocket_class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$t->{"websocket"} or not $t->{"_websocket_class"}
MC/DC0%0/2
$t->{"websocket"} or not $t->{"_websocket_class"}
$t->{"websocket"}
not $t->{"_websocket_class"}
Truth table33%1/3
A or not(B)
A= $t->{"websocket"}B= not $t->{"_websocket_class"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $t->{delayed_response} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my ($self, $response, $sid, $ct, $status) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $sid ||= $self->sid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sid ||= $self->sid
MC/DC0%0/2
$sid ||= $self->sid
$sid
$self->sid
Truth table0%0/3
A ||= B
A= $sidB= $self->sid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $status ||= 200; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$status ||= 200
MC/DC0%0/1
$status ||= 200
$status
Truth table0%0/2
A
A= $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | $ct ||= 'application/json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ct ||= "application/json"
MC/DC0%0/1
$ct ||= "application/json"
$ct
Truth table0%0/2
A
A= $ct
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | return $self->{_application}->delayed_response_handle( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | $self, $response, $sid, $ct, $status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | ) if $self->{_application_has_delayed_response_handler}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $self->{_delayed_response} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $responder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $res = $self->_build_response($sid, $ct, $status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $res = [splice @{$res->finalize}, 0, 2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $writer = $responder->($res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $response = eval { $response->($writer); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($@ || $self->response->error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$@ or $self->response->error
MC/DC0%0/2
$@ or $self->response->error
$@
$self->response->error
Truth table0%0/3
A or B
A= $@B= $self->response->error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | $res->[0] = $self->response->status_code || 500; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->response->status_code || 500
MC/DC0%0/1
$self->response->status_code || 500
$self->response->status_code
Truth table0%0/2
A
A= $self->response->status_code
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | $self->raiseError($@) if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | push @{$res}, [$self->response->serialize]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | return $responder->($res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | elsif ($response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $writer->write($response->serialize); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $writer->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | ▶ | } unless $t->{delayed_response}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | ▶ | $t->{_application}->build_terse($t) if $t->{_application}->can('build_terse'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | $t->{_application_has_dispatcher} = !! $t->{_application}->can('dispatch'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 3 | $t->{_application_has_response_handler} = !! $t->{_application}->can('response_handle'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | $t->{_application_has_delayed_response_handler} = !! $t->{_application}->can('delayed_response_handle'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | ▶ | $t->{_build_response} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | my ($self, $sid, $content, $status) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | ▶ | my $res = $self->request->new_response($self->response->{status_code} ||= $status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->response->{"status_code"} ||= $status
MC/DC0%0/2
$self->response->{"status_code"} ||= $status
$self->response->{"status_code"}
$status
Truth table66%2/3
A ||= B
A= $self->response->{"status_code"}B= $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 3 | ▶ | $res->cookies($self->cookies) if $self->cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 3 | ▶ | $res->headers({%{$self->headers}}) if $self->headers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 3 | ▶ | $res->cookies->{sid} = {%{$sid}} if $sid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 3 | $res->content_type($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 3 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | ▶ | } unless $t->{_build_response}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | ▶ | $t->{content_type} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | ▶ | $_[0]->{_content_type} = $_[1] if $_[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | return $_[0]->{_content_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | ▶ | } unless $t->{content_type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 3 | ▶ | $t->{_response} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 3 | my ($self, $response_body, $sid, $ct, $status) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 3 | ▶ | return $self->{_application}->response_handle(@_) if $self->{_application_has_response_handler}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 3 | ▶ | $ct ||= 'application/json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ct ||= "application/json"
MC/DC100%1/1
$ct ||= "application/json"
$ct
Truth table100%2/2
A
A= $ct
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 3 | my $res = $self->{_delayed_response}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 3 | ▶ | return $res if ($res); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 3 | ▶ | $res = $self->_build_response($sid, $ct, $status || 200); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$status || 200
MC/DC0%0/1
$status || 200
$status
Truth table50%1/2
A
A= $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | $res->body($response_body->serialize()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 3 | return $res->finalize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | ▶ | } unless $t->{_response}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 7 | ▶ | $t->{_dispatch} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 7 | my ($self, $method, @params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | my @out = $self->{_application_has_dispatcher} ? eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->{_application}->dispatch($method, $self, @params) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 7 | ▶ | } : eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 7 | ▶ | unless ($self->{_application}->can($method)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | $self->response->raiseError('Invalid request - ' . $method, 400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | $self->{_application}->$method($self, @params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 7 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $self->response->raiseError(['Error while dispatching the request', $@], 400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 7 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 3 | ▶ | } unless $t->{_dispatch}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | return $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 42 | ▶ | sub _bless_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bless_tree: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 42 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 42 | my $refnode = ref $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 42 | ▶ | return unless $refnode eq 'HASH' || $refnode eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$refnode eq "HASH" or $refnode eq "ARRAY"
MC/DC100%2/2
$refnode eq "HASH" or $refnode eq "ARRAY"
$refnode eq "HASH"
$refnode eq "ARRAY"
Truth table100%3/3
A or B
A= $refnode eq "HASH"B= $refnode eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 20 | ▶ | if ($refnode eq 'HASH'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 18 | ▶ | bless $node, $node->{_inherit} ? ref $self : __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 18 | $self->_bless_tree($node->{$_}) for keys %$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 20 | ▶ | if ($refnode eq 'ARRAY'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 2 | bless $node, ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | $self->_bless_tree($_) for @$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 20 | $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | sub TO_JSON { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $ref = reftype $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | return $self unless $ref && $ref =~ m/ARRAY|HASH/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ref and $ref =~ /ARRAY|HASH/
MC/DC0%0/2
$ref and $ref =~ /ARRAY|HASH/
$ref
$ref =~ /ARRAY|HASH/
Truth table0%0/3
A and B
A= $refB= $ref =~ /ARRAY|HASH/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | return [@$self] if $ref eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | return 'cannot stringify application object' if $self->{_application}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $output = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $nodebug = ! $self->{_debug}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | for(keys %$self){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $skip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $skip++ if $_ =~ /^_/ && $nodebug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ =~ /^_/ and $nodebug
MC/DC0%0/2
$_ =~ /^_/ and $nodebug
$_ =~ /^_/
$nodebug
Truth table0%0/3
A and B
A= $_ =~ /^_/B= $nodebug
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | next if $skip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $output->{$_} = $self->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 49 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 49 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 49 | ▶ | (reftype $self eq 'HASH' ? %{$self} : @{$self}) = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 179 | ▶ | sub AUTOLOAD : lvalue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 179 | my $classname = ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 179 | my $validname = '[_a-zA-Z][\:a-zA-Z0-9_]*'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 179 | our $AUTOLOAD =~ /^${classname}::($validname)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 179 | my $key = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 179 | ▶ | die "illegal key name, must be of $validname form\n$AUTOLOAD" unless $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 179 | ▶ | my $miss = Want::want('REF OBJECT') ? {} : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 179 | my $retval = $_[0]->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 179 | ▶ | return $retval->(@_) if (ref $retval eq 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 161 | ▶ | die "illegal use of AUTOLOAD $classname -> $key - too many arguments" if (scalar @_ > 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 161 | ▶ | my $isBool = Want::want('SCALAR BOOL') && ((reftype($retval) // '') eq 'SCALAR'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
Want::want('SCALAR BOOL') && (builtin::reftype($retval) // '') eq 'SCALAR'
builtin::reftype($retval) // ""
MC/DC100%2/2
Want::want('SCALAR BOOL') && (builtin::reftype($retval) // '') eq 'SCALAR'
Want::want('SCALAR BOOL')
builtin::reftype($retval)
Truth table100%3/3
A && B
A= Want::want('SCALAR BOOL')B= builtin::reftype($retval)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 161 | ▶ | return $$retval if $isBool; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 154 | ▶ | $_[0]->{$key} = $_[1] // $retval // $miss; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
($_[1] // $retval) // $miss
$_[1] // $retval
MC/DC0%0/3
($_[1] // $retval) // $miss
$_[1]
$retval
$miss
Truth table50%2/4
A // B // C
A= $_[1]B= $retvalC= $miss
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 154 | ▶ | $_[0]->_bless_tree($_[0]->{$key}) if ref $_[0]->{$key} eq 'HASH' || ref $_[0]->{$key} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0]{$key} eq "HASH" or ref $_[0]{$key} eq "ARRAY"
MC/DC50%1/2
ref $_[0]{$key} eq "HASH" or ref $_[0]{$key} eq "ARRAY"
ref $_[0]{$key} eq "HASH"
ref $_[0]{$key} eq "ARRAY"
Truth table66%2/3
A or B
A= ref $_[0]{$key} eq "HASH"B= ref $_[0]{$key} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 154 | $_[0]->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||