| 1 | package YATT::Lite::WebMVC0::DirApp; sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 44 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 44 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 44 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 44 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 44 | ▶ | use constant DEBUG_ERROR => $ENV{DEBUG_YATT_ERROR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 44 | ▶ | use YATT::Lite -as_base, qw/*SYS *CON | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 44 | Entity/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 44 | ▶ | use YATT::Lite::MFields qw/dir_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | use_subpath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | overwrite_status_code_for_errors_as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ext_public_action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | _ignore_warn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | _ignore_die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 44 | _Action/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 44 | ▶ | use YATT::Lite::WebMVC0::Connection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub Connection () {'YATT::Lite::WebMVC0::Connection'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub PROP () {Connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 44 | ▶ | use YATT::Lite::Util qw/cached_in ckeval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | dofile_in compile_file_in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | try_invoke | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | psgi_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | terse_dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 44 | /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 44 | ▶ | use YATT::Lite::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 137 | ▶ | sub after_new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_new: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 137 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 137 | $self->SUPER::after_new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 137 | ▶ | $self->{ext_public_action} //= $self->default_ext_public_action; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"ext_public_action"} //= $self->default_ext_public_action
MC/DC0%0/2
$self->{"ext_public_action"} //= $self->default_ext_public_action
$self->{"ext_public_action"}
$self->default_ext_public_action
Truth table33%1/3
A //= B
A= $self->{"ext_public_action"}B= $self->default_ext_public_action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # sub handle_ydo, _do, _psgi... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 331 | ▶ | sub handle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 331 | (my MY $self, my ($type, $con, $file)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 331 | my $chdir_guard = $self->chdir_guard; # cwd is restored at scope exit. GH-267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | local $SIG{__WARN__} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my ($msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($self->{_ignore_warn}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | print STDERR "# ignore __WARN__ $msg\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | print STDERR "# from __WARN__ $msg\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | die $self->raise(warn => $_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 331 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 49 | ▶ | local $SIG{__DIE__} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 49 | my ($err) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 49 | ▶ | if ($self->{_ignore_die}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | print STDERR "# ignore __DIE__ $err\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 45 | ▶ | unless ($^S) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | print STDERR "# interp state is falsy: ignore __DIE__ $err\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 39 | ▶ | if (ref $err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 30 | print STDERR Carp::longmess("# in __DIE__, got ref error: " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | , terse_dump($err)), "\n" if DEBUG_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 30 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 9 | print STDERR "# from __DIE__ $err\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | local $self->{in_sig_die} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 9 | die $self->error({ignore_frame => [undef, __FILE__, __LINE__]}, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 331 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 331 | ▶ | if (my $charset = $self->header_charset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 331 | $con->set_charset($charset); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 331 | $self->SUPER::handle($type, $con, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | ▶ | sub with_ignoring_die { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_ignoring_die: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | (my MY $self, my ($sub, @args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | local $self->{_ignore_warn} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | local $self->{_ignore_die} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | $sub->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub with_ignoring_warn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with_ignoring_warn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | (my MY $self, my ($sub, @args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | local $self->{_ignore_warn} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $sub->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # WebMVC0 specific url mapping. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 281 | ▶ | sub prepare_part_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_part_handler: called CC=13 SCAR=28.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 281 | (my MY $self, my ($con, $file)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 281 | my $trans = $self->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 281 | my PROP $prop = $con->prop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 281 | my ($part, $sub, $pkg, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 281 | my ($type, $item) = $self->parse_request_sigil($con); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 281 | ▶ | if (defined $type and my $subpath = $prop->{subpath}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $type and my $subpath = $prop->{"subpath"}
MC/DC0%0/2
defined $type and my $subpath = $prop->{"subpath"}
defined $type
my $subpath = $prop->{"subpath"}
Truth table66%2/3
A and B
A= defined $typeB= my $subpath = $prop->{"subpath"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | croak $self->error(q|Bad request: subpath %s and sigil %s| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | , $subpath, terse_dump($type, $item)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | if $type ne 'action'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 281 | ▶ | if (not defined $type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
not defined $type and $self->{"use_subpath"} and $prop->{"subpath"} and (my $tmpl, $part, my($formal, $actual)) = $self->find_subpath_handler($trans, $file, $prop->{"subpath"})
not defined $type and $self->{"use_subpath"} and $prop->{"subpath"}
not defined $type and $self->{"use_subpath"}
MC/DC50%2/4
not defined $type and $self->{"use_subpath"} and $prop->{"subpath"} and (my $tmpl, $part, my($formal, $actual)) = $self->find_subpath_handler($trans, $file, $prop->{"subpath"})
not defined $type
$self->{"use_subpath"}
$prop->{"subpath"}
(my $tmpl, $part, my($formal, $actual)) = $self->find_subpath_handler($trans, $file, $prop->{"subpath"})
Truth table60%3/5
not(A) and B and C and D
A= not defined $typeB= $self->{"use_subpath"}C= $prop->{"subpath"}D= (my $tmpl, $part, my($formal, $actual)) = $self->find_subpath_handler($trans, $file, $prop->{"subpath"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | and $self->{use_subpath} and $prop->{subpath} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | and (my $tmpl, $part, my ($formal, $actual)) = $self->find_subpath_handler( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | $trans, $file, $prop->{subpath} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 87 | ▶ | $pkg = $trans->find_product(perl => $tmpl) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | croak $self->error("Can't compile template file: %s", $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 87 | ▶ | $sub = $pkg->can($part->method_name) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | croak $self->error("Can't find %s %s for file: %s" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | , $part->cget('kind'), $part->public_name, $file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | @args = $trans->reorder_cgi_params($part, $con, $actual) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 87 | ▶ | unless $self->{dont_map_args}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 192 | ($part, $sub, $pkg) = $trans->find_part_handler([$file, $type, $item]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | @args = $trans->reorder_cgi_params($part, $con) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 187 | ▶ | unless $self->{dont_map_args}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 273 | ▶ | unless ($part->public) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # XXX: refresh する手もあるだろう。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | croak $self->error(q|Forbidden request %s|, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 273 | ($part, $sub, $pkg, \@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 89 | ▶ | sub find_subpath_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_subpath_handler: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 89 | (my MY $self, my ($trans, $file, $subpath)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 89 | ▶ | my $tmpl = $trans->find_file($file) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | croak $self->error("No such file: %s", $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 89 | ▶ | if (my @found = $tmpl->match_subroutes($subpath)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 87 | return ($tmpl, @found); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | ▶ | if ($subpath ne '/') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | die $self->psgi_error(404, "No such subpath:: ". $subpath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | . " in file " . $tmpl->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Action handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 137 | ▶ | sub default_ext_public_action {'ydo'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_ext_public_action: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 331 | ▶ | sub find_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_handler: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 331 | (my MY $self, my ($ext, $file, $con)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 331 | my PROP $prop = $con->prop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 331 | ▶ | if ($prop->{is_index}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 162 | my $sub_fn = substr($prop->{path_info}, length($prop->{location})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 162 | $sub_fn =~ s,/.*,,; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 162 | ▶ | if ($sub_fn ne '' and my $action = $self->get_action_handler($sub_fn, 1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$sub_fn ne "" and my $action = $self->get_action_handler($sub_fn, 1)
MC/DC100%2/2
$sub_fn ne "" and my $action = $self->get_action_handler($sub_fn, 1)
$sub_fn ne ""
my $action = $self->get_action_handler($sub_fn, 1)
Truth table100%3/3
A and B
A= $sub_fn ne ""B= my $action = $self->get_action_handler($sub_fn, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 38 | return $action | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 293 | $self->SUPER::find_handler($ext, $file, $con); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 12 | ▶ | sub _handle_ydo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_ydo: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 12 | (my MY $self, my ($con, $file, @rest)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 12 | ▶ | my $action = $self->get_action_handler($file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | or die "Can't find action handler for file '$file'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # XXX: this は EntNS pkg か $YATT か... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 10 | $action->($self->EntNS, $con); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # XXX: cached_in 周りは面倒過ぎる。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # XXX: package per dir で、本当に良いのか? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # XXX: Should handle union mount! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 92 | ▶ | sub get_action_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_action_handler: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 92 | (my MY $self, my ($filename, $can_be_missing)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 92 | my $path = "$self->{dir}/$filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # Each action item is stored as: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # [$action_sub, $is_virtual, @more_opts..., $age_from_mtime] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | my $item = $self->cached_in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 30 | ▶ | ($self->{_Action} //= {}, $path, $self, undef, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # first time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 30 | my ($self, $sys, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 30 | ▶ | return undef unless $path =~ m{\.$self->{ext_public_action}\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | my $age = -M $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | ▶ | return undef if not defined $age and $can_be_missing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $age and $can_be_missing
MC/DC0%0/2
not defined $age and $can_be_missing
not defined $age
$can_be_missing
Truth table33%1/3
not(A) and B
A= not defined $ageB= $can_be_missing
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6 | my $sub = compile_file_in(ref $self, $path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # is not virtual. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | [$sub, 0, $age]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 44 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # second time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 44 | my ($item, $sys, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 44 | my ($sub, $age); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 44 | ▶ | if (not defined $item) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # XXX: (Accidental) negative cache. Is this ok? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } elsif ($item->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # return $action_sub without examining $path when item is virtual. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 38 | return $item->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } elsif (not defined ($age = -M $path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # item is removed from filesystem, so undef $sub. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } elsif ($$item[-1] == $age) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | $sub = compile_file_in($self->{app_ns}, $path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | @{$item}[0, -1] = ($sub, $age); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 92 | ▶ | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_Action"} //= {}
MC/DC100%1/1
$self->{"_Action"} //= {}
$self->{"_Action"}
Truth table100%2/2
A
A= $self->{"_Action"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 90 | ▶ | return unless defined $item and $item->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $item and $item->[0]
MC/DC50%1/2
defined $item and $item->[0]
defined $item
$item->[0]
Truth table66%2/3
A and B
A= defined $itemB= $item->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 48 | ▶ | wantarray ? @$item : $item->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 38 | ▶ | sub set_action_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_action_handler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 38 | (my MY $self, my ($filename, $sub)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 38 | $filename =~ s,^/*,,; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 38 | my $path = "$self->{dir}/$filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 38 | $self->{_Action}{$path} = [$sub, 1, undef]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # Response Header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub default_header_charset {''} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_header_charset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 331 | ▶ | sub header_charset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_charset: called CC=4 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 331 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | $self->{header_charset} || $self->{output_encoding} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 331 | ▶ | || $SYS->header_charset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"header_charset"} or $self->{"output_encoding"} or $YATT::Lite::WebMVC0::DirApp::SYS->header_charset
$self->{"header_charset"} or $self->{"output_encoding"}
MC/DC0%0/3
$self->{"header_charset"} or $self->{"output_encoding"} or $YATT::Lite::WebMVC0::DirApp::SYS->header_charset
$self->{"header_charset"}
$self->{"output_encoding"}
$YATT::Lite::WebMVC0::DirApp::SYS->header_charset
Truth table25%1/4
A or B or C
A= $self->{"header_charset"}B= $self->{"output_encoding"}C= $YATT::Lite::WebMVC0::DirApp::SYS->header_charset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | || $self->default_header_charset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub get_lang_msg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_lang_msg: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | (my MY $self, my $lang) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | $self->{_locale_cache}{$lang} || do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if (-r (my $fn = $self->fn_msgfile($lang))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->lang_load_msgcat($lang, $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub fn_msgfile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fn_msgfile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | (my MY $self, my $lang) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | "$self->{dir}/.htyattmsg.$lang.po"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # Following code is for per-DirApp error handling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # Since this complicates error handling too much, I might drop this code near(?) future. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 22 | ▶ | sub error_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_handler: called CC=12 SCAR=28.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 22 | (my MY $self, my $type, my Error $err) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # どこに出力するか、って問題も有る。 $CON を rewind すべき? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 22 | ▶ | my $errcon = try_invoke($self->CON, 'as_error') || do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
try_invoke($self->CON, 'as_error') || do {
my $con = $YATT::Lite::WebMVC0::DirApp::SYS ? $YATT::Lite::WebMVC0::DirApp::SYS->make_connection(undef, 'yatt', $self, 'noheader', 1) : $self->CON;
try_invoke($con, 'as_error');
$con
}
MC/DC0%0/2
try_invoke($self->CON, 'as_error') || do {
my $con = $YATT::Lite::WebMVC0::DirApp::SYS ? $YATT::Lite::WebMVC0::DirApp::SYS->make_connection(undef, 'yatt', $self, 'noheader', 1) : $self->CON;
try_invoke($con, 'as_error');
$con
}
try_invoke($self->CON, 'as_error')
do {
my $con = $YATT::Lite::WebMVC0::DirApp::SYS ? $YATT::Lite::WebMVC0::DirApp::SYS->make_connection(undef, 'yatt', $self, 'noheader', 1) : $self->CON;
try_invoke($con, 'as_error');
$con
}
Truth table33%1/3
A || B
A= try_invoke($self->CON, 'as_error')B= do {
my $con = $YATT::Lite::WebMVC0::DirApp::SYS ? $YATT::Lite::WebMVC0::DirApp::SYS->make_connection(undef, 'yatt', $self, 'noheader', 1) : $self->CON;
try_invoke($con, 'as_error');
$con
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | my $con = $SYS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ? $SYS->make_connection(undef, yatt => $self, noheader => 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | : $self->CON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | try_invoke($con, 'as_error'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $con; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 22 | $errcon->add_error($err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | my $error_status = $self->{overwrite_status_code_for_errors_as} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | // $err->{http_status_code} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 22 | ▶ | // try_invoke($errcon, [cget => 'status']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%8/8
(($self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}) // try_invoke($errcon, ["cget", "status"])) // 500
($self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}) // try_invoke($errcon, ["cget", "status"])
$self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}
MC/DC100%3/3
(($self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}) // try_invoke($errcon, ["cget", "status"])) // 500
$self->{"overwrite_status_code_for_errors_as"}
$err->{"http_status_code"}
try_invoke($errcon, ["cget", "status"])
Truth table100%4/4
A // B // C
A= $self->{"overwrite_status_code_for_errors_as"}B= $err->{"http_status_code"}C= try_invoke($errcon, ["cget", "status"])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | // 500; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 22 | $errcon->configure(status => $error_status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 22 | $err->{http_status_code} = $error_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 22 | my $msg = $err->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # yatt/ytmpl 用の Code generator がまだ無いので、素直に raise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # XXX: 本当は正しくロードできる可能性もあるが, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # そこで更に fail すると真のエラーが隠されてしまうため、頑張らない。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 22 | ▶ | unless ($self->is_default_cgen_ready) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | print STDERR "# error_handler(with cgen): $msg\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # For [GH #172] - to avoid 'ARRAY(0x5575a6c9c2a8)Compilation failed in require' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 21 | ▶ | if ($self->{in_sig_die}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 8 | print STDERR "# error_handler(sig die): $msg\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 8 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 13 | print STDERR "# error_handler(normal): $msg\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 13 | my $maybeCON = $self->CON; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 13 | ▶ | my $is_psgi = $maybeCON ? $maybeCON->cget('is_psgi') : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # error.ytmpl を探し、あれば呼び出す。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 13 | my ($sub, $pkg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 13 | ▶ | ($sub, $pkg) = $self->find_renderer($type => ignore_error => 1) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 13 | print {*$errcon} $err->reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 13 | ▶ | if ($is_psgi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 13 | $self->DONE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | die $err->reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $sub->($pkg, $errcon, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if ($is_psgi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $self->raise_psgi_html($error_status | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | , $errcon->buffer); # ->DONE was not ok. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | try_invoke($errcon, 'flush_headers'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->DONE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # dir_config should be fetched from target dirapp for this request($CON) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # instead from container of called template($this) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # because widgets can be abstracted out to library dirs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | Entity dir_config => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $CON->YATT->dir_config(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 44 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | sub dir_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir_config: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | (my MY $self, my ($name, $default)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my PROP $prop = $CON->prop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my $cache = $prop->{_dir_config_cache} //= +{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prop->{"_dir_config_cache"} //= {}
MC/DC0%0/1
$prop->{"_dir_config_cache"} //= {}
$prop->{"_dir_config_cache"}
Truth table0%0/2
A
A= $prop->{"_dir_config_cache"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # This ensures every request has a fresh cache for dir_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # and every request tests the cache at most once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my $config = $cache->{$self->{app_name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | unless ($config) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | my $cfg = $self->{dir_config} || +{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'dir_config'} || {}
MC/DC0%0/1
$self->{'dir_config'} || {}
$self->{'dir_config'}
Truth table0%0/2
A
A= $self->{'dir_config'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # If dirapp_config exist, merge it onto original dir_config. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if (my $dirapp_config = $SYS->dirapp_config_for($self)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $cfg->{$_} = $dirapp_config->{$_} for keys %$dirapp_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $config = $cache->{$self->{app_name}} = $cfg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | return $config unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $config->{$name} // $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$config->{$name} // $default
MC/DC0%0/2
$config->{$name} // $default
$config->{$name}
$default
Truth table0%0/3
A // B
A= $config->{$name}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | sub merged_dir_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merged_dir_config: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | (my MY $self, my $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $all_config = $self->dir_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my $base = $all_config->{$name} // +{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$all_config->{$name} // {}
MC/DC0%0/1
$all_config->{$name} // {}
$all_config->{$name}
Truth table0%0/2
A
A= $all_config->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | YATT::Lite::Util::merge_hash_renaming { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | /^${name}[_\.](.*)/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | } $base, $all_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 44 | ▶ | use YATT::Lite::Breakpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 44 | YATT::Lite::Breakpoint::break_load_dirhandler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 44 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||