blib/lib/YATT/Lite/Site.pm

filter: Statementstmt 95.2% 162 / 170 Branchbran 69.3% 61 / 88 Conditioncond 58.1% 32 / 55 MC/DCmcdc 29.0% 9 / 31 Subroutinesub 100% 22 / 22 Podpod 71.4% 5 / 7 totaltotal 78.0% 291 / 373 CC 70 SCAR 22.5
CC
70
Cov
81%
psgi_env_for
18.9
encode_query
15.9
render_file
15.8
CRAP 9.5
« blib/lib/YATT/Lite/XHF.pm ↑ Summary blib/lib/YATT/Lite/LRXML/ParseEntpath.pm »
1 package YATT::Lite::Site; sub MY () {__PACKAGE__}
2 72 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 72 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 72 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 72 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 #========================================
8 # YATT::Lite::Site is the public facade API of YATT::Lite.
9 #
10 # This class is inserted as a parent class of YATT::Lite::Factory,
11 # so that every site object satisfies `$site isa YATT::Lite::Site`
12 # (YATT::Lite::WebMVC0::SiteApp = Site + PSGI adapter).
13 #
14 # This class must NOT declare any fields and must NOT have parent classes.
15 # Methods only. All instance fields it touches are defined in Factory
16 # (or its subclasses), so keep `$self` untyped here.
17 #========================================
18  
19 72 ▶use YATT::Lite::Util qw(catch try_invoke);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 72 ▶use YATT::Lite::PSGIEnv;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 72 require File::Basename;
23 72 require Encode;
24  
25 72 require YATT::Lite::Response;
26  
27 #========================================
28 # Class methods to open a site.
29 #========================================
30  
31 # Resolve which class implements the factory machinery.
32 # (Site is a *parent* of Factory, so Site itself cannot inherit them.)
33 61 ▶sub _facade_factory_class {
Subroutine _facade_factory_class: called CC=2 SCAR=6.9
34 61 my ($pack) = @_;
35 61 ▶ if ($pack->can('find_load_factory_script')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pack->can('find_load_factory_script')) { } 29 32 61
36 29 $pack;
37 } else {
38 32 require YATT::Lite::Factory;
39 32 'YATT::Lite::Factory';
40 }
41 }
42  
43 # Load the site object defined by app.psgi/runyatt.psgi, searching upward
44 # from $opts{dir}. Dies when not found. Defaults to offline => 1
45 # (error_handler passes raw die through) since this entry is mainly for
46 # programs and tools; the web entry point is app.psgi itself.
47 #
48 # Like Node's require.cache, one factory script yields one site object
49 # per process: loading the same script twice would collide on app_ns
50 # anyway, so subsequent load()s return the cached instance (with any
51 # explicitly given opts re-configured onto it).
52 72 our %SCRIPT_CACHE;
53 23 ▶sub load {
Subroutine load: called CC=8 SCAR=21.1
Pod documented
54 23 my ($pack, %opts) = @_;
55 23 my $class = $pack->_facade_factory_class;
56 23 ▶ my $dir = delete $opts{dir} // '.';
Condition50%1/2
delete $opts{"dir"} // "."
l!l
230
MC/DC0%0/1
delete $opts{"dir"} // "."
delete $opts{"dir"}
Truth table50%1/2
A
A= delete $opts{"dir"}
Aresult
11
00
57 23 my $stop_at = delete $opts{stop_at};
58 23 ▶ my ($script) = $class->find_factory_script($dir, stop_at => $stop_at)
Branch: 2 branches
BranchTrueFalseTotal
my($script) = $class->find_factory_script($dir, "stop_at", $stop_at) or croak(q[Can't find factory script (app.psgi or runyatt.psgi)] . " at or above: $dir" . (defined $stop_at ? " (search stopped at: $stop_at)" : "")) 21 2 23
defined $stop_at ? : 1 1 2
59 or croak "Can't find factory script (app.psgi or runyatt.psgi)"
60 . " at or above: $dir"
61 . (defined $stop_at ? " (search stopped at: $stop_at)" : "");
62 21 my $key = YATT::Lite::Util::normalize_fs_path($class->rel2abs($script));
63 21 ▶ if (my $site = $SCRIPT_CACHE{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $site = $YATT::Lite::Site::SCRIPT_CACHE{$key}) 6 15 21
64 6 ▶ $site->configure(%opts) if %opts;
Branch: 1 branch
BranchTrueFalseTotal
if %opts 0 6 6
65 6 return $site;
66 }
67 15 ▶ $opts{offline} = 1 unless exists $opts{offline};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"offline"} 15 0 15
68 15 ▶ my $site = $class->load_factory_script($key)
Branch: 1 branch
BranchTrueFalseTotal
my $site = $class->load_factory_script($key) or croak("Can't load YATT::Lite::Factory instance from $script") 15 0 15
69 or croak "Can't load YATT::Lite::Factory instance from $script";
70 15 $site->configure(%opts);
71 15 $SCRIPT_CACHE{$key} = $site;
72 }
73  
74 # Like load, but falls back to a plain SiteApp when no factory script
75 # is found. app_ns is auto-uniquified so that multiple default sites
76 # can coexist in one process. The class of the synthesized site can be
77 # overridden with class => 'My::SiteApp'.
78 38 ▶sub load_or_default {
Subroutine load_or_default: called CC=5 SCAR=16.2
Pod documented
79 38 my ($pack, %opts) = @_;
80 38 my $class = $pack->_facade_factory_class;
81 38 ▶ my $app_class = delete $opts{class} // 'YATT::Lite::WebMVC0::SiteApp';
Condition100%2/2
delete $opts{"class"} // "YATT::Lite::WebMVC0::SiteApp"
l!l
1721
MC/DC100%1/1
delete $opts{"class"} // "YATT::Lite::WebMVC0::SiteApp"
delete $opts{"class"}
Truth table100%2/2
A
A= delete $opts{"class"}
Aresult
11
00
82 38 ▶ if ($class->find_factory_script($opts{dir}, stop_at => $opts{stop_at})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->find_factory_script($opts{"dir"}, "stop_at", $opts{"stop_at"})) 19 19 38
83 19 return $pack->load(%opts);
84 }
85 19 my $dir = delete $opts{dir};
86 19 delete $opts{stop_at};
87 19 ▶ $opts{offline} = 1 unless exists $opts{offline};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"offline"} 19 0 19
88 19 YATT::Lite::Util::ckrequire($app_class);
89 19 ▶ $app_class->new
Branch: 1 branch
BranchTrueFalseTotal
defined $dir ? : 19 0 19
90 (app_ns => $pack->_uniq_default_app_ns
91 , (defined $dir ? (app_root => $dir, doc_root => $dir) : ())
92 , header_charset => 'utf-8'
93 , tmpl_encoding => 'utf-8'
94 , output_encoding => 'utf-8'
95 , %opts);
96 }
97  
98 72 our $DEFAULT_APP_NS_SEQ = 0;
99 19 ▶sub _uniq_default_app_ns {
Subroutine _uniq_default_app_ns: called CC=3 SCAR=11.0
100 19 my ($pack) = @_;
101 19 my $ns;
102 do {
103 19 my $seq = $DEFAULT_APP_NS_SEQ++;
104 19 ▶ $ns = 'MyYATT' . ($seq ? $seq : '');
Branch: 1 branch
BranchTrueFalseTotal
$seq ? : 10 9 19
105 72 ▶ } while (do {no strict 'refs'; %{"${ns}::"}});
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
do { no strict 'refs'; %{"${ns}::";} } and do { do { my $seq = $YATT::Lite::Site::DEFAULT_APP_NS_SEQ++; $ns = 'MyYATT' . ($seq ? $seq : "") } } 0 19 19
106 19 $ns;
107 }
108  
109 #========================================
110 # resolve_file: filename => (dirhandler, template_name [, location])
111 #
112 # Files under doc_root are resolved via location (exactly like the web
113 # does), others fall back to the physical dirhandler.
114 #========================================
115  
116 27 ▶sub resolve_file {
Subroutine resolve_file: called CC=5 SCAR=16.7
Pod documented
117 27 my ($self, $fn) = @_;
118 27 ▶ defined $fn and $fn ne ''
Branch: 1 branch
BranchTrueFalseTotal
defined $fn and $fn ne "" or croak("resolve_file: filename is missing!") 27 0 27
Condition33%1/3
defined $fn and $fn ne ""
!ll&&!rl&&r
0027
MC/DC0%0/2
defined $fn and $fn ne ""
defined $fn $fn ne ""
Truth table33%1/3
A and B
A= defined $fnB= $fn ne ""
ABresult
0X0
100
111
119 or croak "resolve_file: filename is missing!";
120 27 my $abs = YATT::Lite::Util::normalize_fs_path($self->rel2abs($fn));
121 27 my $dir = File::Basename::dirname($abs);
122 27 my $name = File::Basename::basename($abs);
123 27 my $loc = $self->_loc_under_doc_root($dir);
124 27 ▶ my $dh = defined $loc
Branch: 1 branch
BranchTrueFalseTotal
defined $loc ? : 25 2 27
125 ? $self->get_lochandler($loc)
126 : $self->get_dirhandler($dir);
127 27 ▶ wantarray ? ($dh, $name, $loc) : $dh;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 27 0 27
128 }
129  
130 27 ▶sub _loc_under_doc_root {
Subroutine _loc_under_doc_root: called CC=4 SCAR=13.9
131 27 my ($self, $dir) = @_;
132 my $root = $self->{doc_root}
133 27 ▶ or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $root = $self->{"doc_root"} or return undef 27 0 27
134 27 $root = YATT::Lite::Util::normalize_fs_path($self->rel2abs($root));
135 27 $root =~ s{/+\z}{};
136 27 ▶ if ($dir eq $root) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dir eq $root) { } 20 7 27
elsif (index($dir, "$root/") == 0) { } 5 2 7
137 20 '/';
138 } elsif (index($dir, "$root/") == 0) {
139 5 substr($dir, length($root));
140 } else {
141 2 undef;
142 }
143 }
144  
145 #========================================
146 # request($method, $path, $args, %opts)
147 #
148 # Synthesizes a PSGI env and runs it through the real call($env),
149 # so the result is identical to a real web request
150 # (path resolution, sigil, public check, SIG traps, error page and all).
151 #========================================
152  
153 7 ▶sub request {
Subroutine request: called CC=3 SCAR=11.0
Pod documented
154 7 my ($self, $method, $path, $args, %opts) = @_;
155 7 ▶ my $call = $self->can('call')
Branch: 1 branch
BranchTrueFalseTotal
my $call = $self->can("call") or croak('request() requires a web-capable site (SiteApp), not: ' . ref($self)) 7 0 7
156 or croak "request() requires a web-capable site (SiteApp), not: "
157 . ref($self);
158 7 my Env $env = $self->psgi_env_for($method, $path, $args, %opts);
159 7 ▶ $self->prepare_app unless $self->{is_psgi};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"is_psgi"} 2 5 7
160 7 YATT::Lite::Response->from_psgi($call->($self, $env));
161 }
162  
163 26 ▶sub psgi_env_for {
Subroutine psgi_env_for: called CC=15 SCAR=29.4
Pod undocumented
164 26 my ($self, $method, $path, $args, %opts) = @_;
165 26 ▶ $method = uc($method // 'GET');
Condition50%1/2
$method // "GET"
l!l
260
MC/DC0%0/1
$method // "GET"
$method
Truth table50%1/2
A
A= $method
Aresult
11
00
166 26 ▶ defined $path and $path =~ m{^/}
Branch: 1 branch
BranchTrueFalseTotal
defined $path and $path =~ m[^/] or croak(q[request path must start with '/': ] . ($path // "(undef)")) 26 0 26
Condition20%1/5
defined $path and $path =~ m[^/]
!ll&&!rl&&r
0026
$path // "(undef)"
l!l
00
MC/DC0%0/2
defined $path and $path =~ m[^/]
defined $path $path =~ m[^/]
MC/DC0%0/1
$path // "(undef)"
$path
Truth table33%1/3
A and B
A= defined $pathB= $path =~ m[^/]
ABresult
0X0
100
111
Truth table0%0/2
A
A= $path
Aresult
11
00
167 or croak "request path must start with '/': " . ($path // '(undef)');
168 26 my ($path_info, $query) = $path =~ m{^([^?]*) (?:\?(.*))?\z}x;
169  
170 26 my Env $env = Env->psgi_simple_env(PATH_INFO => $path_info);
171 26 $env->{REQUEST_METHOD} = $method;
172 26 $env->{SCRIPT_NAME} = '';
173 26 $env->{SERVER_NAME} = 'localhost';
174 26 $env->{SERVER_PORT} = 80;
175 26 $env->{SERVER_PROTOCOL} = 'HTTP/1.1';
176 26 $env->{HTTP_HOST} = 'localhost';
177  
178 26 my $encoded = $self->encode_query($args);
179 26 ▶ if ($method eq 'POST' or $method eq 'PUT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq 'POST' or $method eq 'PUT') { } 1 25 26
Condition66%2/3
$method eq "POST" or $method eq "PUT"
l!l&&r!l&&!r
1025
MC/DC50%1/2
$method eq "POST" or $method eq "PUT"
$method eq "POST" $method eq "PUT"
Truth table66%2/3
A or B
A= $method eq "POST"B= $method eq "PUT"
ABresult
1X1
011
000
180 1 ▶ $env->{QUERY_STRING} = $query // '';
Condition50%1/2
$query // ""
l!l
01
MC/DC0%0/1
$query // ""
$query
Truth table50%1/2
A
A= $query
Aresult
11
00
181 1 ▶ my $body = $encoded // '';
Condition50%1/2
$encoded // ""
l!l
10
MC/DC0%0/1
$encoded // ""
$encoded
Truth table50%1/2
A
A= $encoded
Aresult
11
00
182 1 ▶ open my $input, '<', \$body or die "Can't open in-memory body: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $input, "<", \$body or die "Can't open in-memory body: $!" 1 0 1
183 1 $env->{'psgi.input'} = $input;
184 1 $env->{CONTENT_TYPE} = 'application/x-www-form-urlencoded';
185 1 $env->{CONTENT_LENGTH} = length($body);
186 } else {
187 25 ▶ $env->{QUERY_STRING} = join '&', grep {defined $_ and $_ ne ''}
Condition66%2/3
defined $_ && $_ ne ''
!ll&&!rl&&r
4703
MC/DC50%1/2
defined $_ && $_ ne ''
defined $_ $_ ne ''
Truth table66%2/3
A && B
A= defined $_B= $_ ne ''
ABresult
0X0
100
111
188 ($query, $encoded);
189 }
190 $env->{REQUEST_URI} = $path_info
191 26 ▶ . (($env->{QUERY_STRING} // '') ne '' ? "?$env->{QUERY_STRING}" : '');
Branch: 1 branch
BranchTrueFalseTotal
($env->{'QUERY_STRING'} // '') ne '' ? : 3 23 26
Condition50%1/2
$env->{"QUERY_STRING"} // ""
l!l
260
MC/DC0%0/1
$env->{"QUERY_STRING"} // ""
$env->{"QUERY_STRING"}
Truth table50%1/2
A
A= $env->{"QUERY_STRING"}
Aresult
11
00
192  
193 26 ▶ if (my $override = $opts{env}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $override = $opts{"env"}) 0 26 26
194 0 $env->{$_} = $override->{$_} for keys %$override;
195 }
196 26 $env;
197 }
198  
199 # $args: HASH (value may be ARRAY for multi-value), ARRAY of pairs,
200 # or a raw query string.
201 26 ▶sub encode_query {
Subroutine encode_query: called CC=9 SCAR=27.7
Pod undocumented
202 26 my ($self, $args) = @_;
203 26 ▶ return undef unless defined $args;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args 22 4 26
204 4 ▶ return $args unless ref $args;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args 0 4 4
205 4 my @pairs;
206 4 ▶ if (ref $args eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $args eq 'HASH') { } 4 0 4
elsif (ref $args eq 'ARRAY') { } 0 0 0
207 4 foreach my $key (sort keys %$args) {
208 4 my $value = $args->{$key};
209 push @pairs, _url_encode($key) . '=' . _url_encode($_)
210 4 ▶ for ref $value eq 'ARRAY' ? @$value : $value;
Branch: 1 branch
BranchTrueFalseTotal
ref $value eq 'ARRAY' ? : 0 4 4
211 }
212 } elsif (ref $args eq 'ARRAY') {
213 0 my @list = @$args;
214 0 ▶ while (my ($key, $value) = splice @list, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@list, 0, 2)) 0 0 0
215 0 push @pairs, _url_encode($key) . '=' . _url_encode($value);
216 }
217 } else {
218 0 croak "Unsupported args type for query: " . ref $args;
219 }
220 4 join '&', @pairs;
221 }
222  
223 8 ▶sub _url_encode {
Subroutine _url_encode: called CC=3 SCAR=11.0
224 8 my ($str) = @_;
225 8 ▶ $str //= '';
Condition50%1/2
$str //= ""
l!l
80
MC/DC0%0/1
$str //= ""
$str
Truth table50%1/2
A
A= $str
Aresult
11
00
226 8 ▶ $str = Encode::encode_utf8($str) if utf8::is_utf8($str);
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($str) 1 7 8
227 8 $str =~ s{([^0-9A-Za-z_.~-])}{sprintf("%%%02X", ord $1)}eg;
228 8 $str;
229 }
230  
231 #========================================
232 # render_file($fn, $args, %opts)
233 #
234 # Dispatch (part resolution, sigil, public check, argument reordering)
235 # is identical to the web, but the error policy defaults to tool style:
236 # no error page conversion, raw die passes through (perl -d friendly).
237 # Pass error_style => 'web' for web-equivalent error handling.
238 #========================================
239  
240 19 ▶sub render_file {
Subroutine render_file: called CC=14 SCAR=27.6
Pod documented
241 19 my ($self, $fn, $args, %opts) = @_;
242 19 ▶ my $error_style = delete $opts{error_style} // 'raw';
Condition100%2/2
delete $opts{"error_style"} // "raw"
l!l
118
MC/DC100%1/1
delete $opts{"error_style"} // "raw"
delete $opts{"error_style"}
Truth table100%2/2
A
A= delete $opts{"error_style"}
Aresult
11
00
243 19 ▶ $error_style =~ /^(?:raw|web)\z/
Branch: 1 branch
BranchTrueFalseTotal
$error_style =~ /^(?:raw|web)\z/ or croak("Unknown error_style: $error_style (raw or web)") 19 0 19
244 or croak "Unknown error_style: $error_style (raw or web)";
245  
246 19 my ($dh, $name, $loc) = $self->resolve_file($fn);
247  
248 19 my Env $env = $self->psgi_env_for(GET => $self->_path_info_for($name, $loc));
249 19 try_invoke($self, 'set_yatt_script_name', $env);
250  
251 19 require Hash::MultiValue;
252 my $params = Hash::MultiValue->new
253 (map {
254 19 my $key = $_; my $value = $args->{$key};
255 0 ▶ ref $value eq 'ARRAY' ? (map {($key => $_)} @$value) : ($key => $value);
Branch: 2 branches
BranchTrueFalseTotal
ref $value eq 'ARRAY' ? : 0 11 11
$args ? : 19 0 19
256 } $args ? keys %$args : ());
257  
258 my $con = $self->make_connection
259 (undef
260 , env => $env
261 , path_info => $env->{PATH_INFO}
262 19 , parameters => $params
263 , file => $name
264 , noheader => 1
265 , yatt => $dh);
266  
267 19 my $dh_fields = YATT::Lite::Util::fields_hash($dh);
268 19 ▶ my $error = catch {
Subroutine __ANON__: called CC=4 SCAR=14.3
269 19 ▶ if ($error_style eq 'web'
Branch: 1 branch
BranchTrueFalseTotal
if ($error_style eq 'web' or not $dh_fields && $dh_fields->{'_ignore_die'}) { } 1 18 19
Condition50%3/6
$error_style eq "web" or not $dh_fields && $dh_fields->{"_ignore_die"}
l!l&&r!l&&!r
1018
$dh_fields && $dh_fields->{'_ignore_die'}
!ll&&!rl&&r
0018
MC/DC33%1/3
$error_style eq "web" or not $dh_fields && $dh_fields->{"_ignore_die"}
$error_style eq "web" $dh_fields $dh_fields->{'_ignore_die'}
Truth table50%2/4
A or not(B && C)
A= $error_style eq "web"B= $dh_fieldsC= $dh_fields->{'_ignore_die'}
ABCresult
1XX1
00X1
0101
0110
270 or not ($dh_fields and $dh_fields->{_ignore_die})) {
271 1 $self->run_dirhandler($dh, $con, $name);
272 } else {
273 # Tool style: neutralize the __DIE__/__WARN__ traps installed by
274 # DirApp::handle, so plain die reaches the caller (and perl -d) as is.
275 18 local $dh->{_ignore_die} = 1;
276 18 local $dh->{_ignore_warn} = 1;
277 18 $self->run_dirhandler($dh, $con, $name);
278 }
279 19 };
280  
281 19 try_invoke($con, 'flush_headers');
282  
283 19 ▶ if ($error_style eq 'web' and $con->can('is_error') and $con->is_error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error_style eq "web" and $con->can("is_error") and $con->is_error) 0 19 19
Condition66%4/6
$error_style eq "web" and $con->can("is_error") and $con->is_error
!ll&&!rl&&r
1810
$error_style eq "web" and $con->can("is_error")
!ll&&!rl&&r
1801
MC/DC0%0/3
$error_style eq "web" and $con->can("is_error") and $con->is_error
$error_style eq "web" $con->can("is_error") $con->is_error
Truth table50%2/4
A and B and C
A= $error_style eq "web"B= $con->can("is_error")C= $con->is_error
ABCresult
0XX0
10X0
1100
1111
284 0 return $self->_error_to_response($con->error_list->[0], $env, $con);
285 }
286  
287 19 ▶ if (not $error or YATT::Lite::Util::is_done($error)) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $error or YATT::Lite::Util::is_done($error)) { } 13 6 19
elsif (ref $error eq 'ARRAY' or ref $error eq 'CODE') { } 2 4 6
elsif ($error_style eq 'web' and UNIVERSAL::isa($error, 'YATT::Lite::Error')) { } 1 3 4
Condition66%2/3
not $error or YATT::Lite::Util::is_done($error)
l!l&&r!l&&!r
1306
MC/DC50%1/2
not $error or YATT::Lite::Util::is_done($error)
not $error YATT::Lite::Util::is_done($error)
Truth table66%2/3
not(A) or B
A= not $errorB= YATT::Lite::Util::is_done($error)
ABresult
1X1
011
000
288 13 $self->_response_of_connection($con);
289 ▶ } elsif (ref $error eq 'ARRAY' or ref $error eq 'CODE') {
Condition66%2/3
ref $error eq "ARRAY" or ref $error eq "CODE"
l!l&&r!l&&!r
204
MC/DC50%1/2
ref $error eq "ARRAY" or ref $error eq "CODE"
ref $error eq "ARRAY" ref $error eq "CODE"
Truth table66%2/3
A or B
A= ref $error eq "ARRAY"B= ref $error eq "CODE"
ABresult
1X1
011
000
290 2 YATT::Lite::Response->from_psgi($error);
291 ▶ } elsif ($error_style eq 'web'
Condition66%2/3
$error_style eq "web" and UNIVERSAL::isa($error, "YATT::Lite::Error")
!ll&&!rl&&r
301
MC/DC50%1/2
$error_style eq "web" and UNIVERSAL::isa($error, "YATT::Lite::Error")
$error_style eq "web" UNIVERSAL::isa($error, "YATT::Lite::Error")
Truth table66%2/3
A and B
A= $error_style eq "web"B= UNIVERSAL::isa($error, "YATT::Lite::Error")
ABresult
0X0
100
111
292 and UNIVERSAL::isa($error, 'YATT::Lite::Error')) {
293 1 $self->_error_to_response($error, $env, $con);
294 } else {
295 3 die $error;
296 }
297 }
298  
299 19 ▶sub _path_info_for {
Subroutine _path_info_for: called CC=4 SCAR=13.9
300 19 my ($self, $name, $loc) = @_;
301 19 my $req_name = $name;
302 19 ▶ if (defined(my $ext = $self->{ext_public})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $ext = $self->{"ext_public"})) 19 0 19
303 19 $req_name =~ s/\.\Q$ext\E\z//;
304 }
305 19 ▶ my $path_info = $loc // '/';
Condition100%2/2
$loc // "/"
l!l
181
MC/DC100%1/1
$loc // "/"
$loc
Truth table100%2/2
A
A= $loc
Aresult
11
00
306 19 ▶ $path_info .= '/' unless $path_info =~ m{/\z};
Branch: 1 branch
BranchTrueFalseTotal
unless $path_info =~ m[/\z] 4 15 19
307 19 $path_info . $req_name;
308 }
309  
310 13 ▶sub _response_of_connection {
Subroutine _response_of_connection: called CC=3 SCAR=11.7
311 13 my ($self, $con) = @_;
312 13 ▶ my @headers = $con->can('list_header') ? $con->list_header : ();
Branch: 1 branch
BranchTrueFalseTotal
$con->can('list_header') ? : 13 0 13
313 13 ▶ YATT::Lite::Response->new
Condition50%1/2
try_invoke($con, ["cget", "status"]) // 200
l!l
013
MC/DC0%0/1
try_invoke($con, ["cget", "status"]) // 200
try_invoke($con, ["cget", "status"])
Truth table50%1/2
A
A= try_invoke($con, ["cget", "status"])
Aresult
11
00
314 (status => (try_invoke($con, [cget => 'status']) // 200)
315 , headers => \@headers
316 , body => [$con->buffer]);
317 }
318  
319 1 ▶sub _error_to_response {
Subroutine _error_to_response: called CC=2 SCAR=7.6
320 1 my ($self, $err, $env, $con) = @_;
321 1 ▶ if ($self->can('error_response')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can('error_response')) { } 1 0 1
322 1 YATT::Lite::Response->from_psgi($self->error_response($err, $env, $con));
323 } else {
324 0 die $err;
325 }
326 }
327  
328 72 1;
« blib/lib/YATT/Lite/XHF.pm ↑ Summary blib/lib/YATT/Lite/LRXML/ParseEntpath.pm »