blib/lib/YATT/Lite/Site.pm

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