blib/lib/YATT/Lite.pm

filter: Statementstmt 84.3% 323 / 383 Branchbran 62.9% 73 / 116 Conditioncond 47.6% 30 / 63 MC/DCmcdc 15.0% 6 / 40 Subroutinesub 84.4% 76 / 90 Podpod 8.7% 5 / 57 totaltotal 68.4% 513 / 749 CC 83 SCAR 18.9
CC
83
Cov
76%
prepare_part_handler
42.0
entity_stash
42.0
ensure_supplns
15.2
CRAP 6.6
« blib/lib/YATT/Lite/WebMVC0/SubRoutes.pm ↑ Summary blib/lib/YATT/Lite/Partial/Gettext.pm »
1 package YATT::Lite; sub MY () {__PACKAGE__}
2 80 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 80 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 80 ▶use 5.010; no if $] >= 5.017011, warnings => "experimental";
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 80 ▶use Carp qw(carp croak confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 80 our $VERSION = '0.201';
8 80 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 80 ▶use Scalar::Util qw/weaken/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 80 ▶use List::MoreUtils qw/uniq/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #
14 # YATT Internalへの Facade. YATT の初期化パラメータの保持者でもある。
15 #
16 80 ▶use parent qw/YATT::Lite::Object File::Spec/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 80 ▶use YATT::Lite::Partial::MarkAfterNew -as_base;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 80 ▶use YATT::Lite::MFields qw/_YATT
Subroutine BEGIN: called CC=1 SCAR=0.0
19 dir
20 vfs base
21 factory
22 header_charset
23 output_encoding
24 tmpl_encoding
25 index_name
26 ext_public
27 ext_private
28 app_ns
29 _entns
30 _cgen_class
31  
32 app_name
33 debug_cgen debug_parser namespace only_parse
34 special_entities no_lineinfo check_lineno
35 rc_script
36 tmpl_cache
37 dont_map_args
38 dont_debug_param
39 info
40 lcmsg_sink
41 always_refresh_deps
42 no_mro_c3
43 render_as_bytes
44  
45 default_lang
46  
47 entns2vfs_item
48 import
49 match_argsroute_first
50 stash_unknown_params_to
51 body_argument
52 body_argument_type
53 prefer_call_for_entity
54 no_conditional_call
55 allow_bare_entity_in_decl
56 no_chdir
57 pagevars
58 argmacro
59 80 /;
60  
61 80 ▶use constant DEBUG => $ENV{DEBUG_YATT_LITE};
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 80 MY->cf_mkaccessors(qw/app_name/);
64  
65 # Entities を多重継承する理由は import も継承したいから。
66 # XXX: やっぱり、 YATT::Lite には固有の import を用意すべきではないか?
67 # yatt_default や cgen_perl を定義するための。
68 80 ▶use YATT::Lite::Entities -as_base, qw(*YATT *CON *SYS import);
Subroutine BEGIN: called CC=1 SCAR=0.0
69  
70 # For error, raise, DONE. This is inserted to ISA too.
71 80 ▶use YATT::Lite::Partial::ErrorReporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
72  
73 80 ▶use YATT::Lite::Partial::AppPath;
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 80 ▶use YATT::Lite::Util qw/globref lexpand extname ckrequire terse_dump escape
Subroutine BEGIN: called CC=1 SCAR=0.0
76 set_inc ostream try_invoke list_isa symtab
77 look_for_globref
78 subname ckeval ckrequire
79 secure_text_plain
80 raise_psgi_error
81 define_const
82 add_entity_into
83 80 /;
84  
85 sub Facade () {__PACKAGE__}
86 0 ▶sub default_app_ns {'MyYATT'}
Subroutine default_app_ns: not called CC=1 SCAR=6.9
Pod undocumented
87 242 ▶sub default_trans {'YATT::Lite::Core'}
Subroutine default_trans: called CC=1 SCAR=0.0
Pod undocumented
88 21 ▶sub default_export {(shift->SUPER::default_export, qw(Entity *SYS *CON))}
Subroutine default_export: called CC=1 SCAR=0.0
Pod undocumented
89 0 ▶sub default_index_name { '' }
Subroutine default_index_name: not called CC=1 SCAR=6.9
Pod undocumented
90 39 ▶sub default_ext_public {'yatt'}
Subroutine default_ext_public: called CC=1 SCAR=0.0
Pod undocumented
91 39 ▶sub default_ext_private {'ytmpl'}
Subroutine default_ext_private: called CC=1 SCAR=0.0
Pod undocumented
92 38 ▶sub default_body_argument { 'body' }
Subroutine default_body_argument: called CC=1 SCAR=0.0
Pod undocumented
93 38 ▶sub default_body_argument_type { 'code' }
Subroutine default_body_argument_type: called CC=1 SCAR=0.0
Pod undocumented
94 39 ▶sub default_output_encoding { 'utf-8' }
Subroutine default_output_encoding: called CC=1 SCAR=0.0
Pod undocumented
95  
96 621 ▶sub with_system {
Subroutine with_system: called CC=1 SCAR=0.0
Pod undocumented
97 621 (my MY $self, local $SYS, my $method) = splice @_, 0, 3;
98 621 local $YATT = $self;
99 621 $self->$method(@_);
100 }
101  
102 #
103 # "The cwd of a template is its directory" - scoped chdir with restore.
104 # Returns a guard object which restores the previous cwd when it goes
105 # out of scope (also when the scope dies). Returns undef (no-op) when
106 # this handler has no physical directory or no_chdir is configured.
107 # Note: chdir happens only for the entry dirhandler; templates in other
108 # directories called via base/import do not re-chdir. GH-267
109 #
110 623 ▶sub chdir_guard {
Subroutine chdir_guard: called CC=3 SCAR=11.0
Pod undocumented
111 623 (my MY $self) = @_;
112 623 ▶ return undef if $self->{no_chdir};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"no_chdir"} 1 622 623
113 622 ▶ defined(my $dir = $self->{dir}) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
defined(my $dir = $self->{"dir"}) or return undef 622 0 622
114 622 YATT::Lite::ChdirGuard->new($dir);
115 }
116  
117 {
118 package YATT::Lite::ChdirGuard;
119 80 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
120 80 ▶ use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
121 80 require Cwd;
122 622 ▶ sub new {
Subroutine new: called CC=2 SCAR=7.0
123 622 my ($pack, $dir) = @_;
124 622 my $prev = Cwd::getcwd();
125 622 ▶ chdir($dir)
Branch: 1 branch
BranchTrueFalseTotal
chdir $dir or Carp::croak("Can't chdir '${dir}': $!") 622 0 622
126 or Carp::croak("Can't chdir '$dir': $!");
127 622 bless \$prev, $pack;
128 }
129 622 ▶ sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=7.2
130 622 my ($self) = @_;
131 # Best effort restore. Never die in DESTROY.
132 622 ▶ chdir($$self) if defined $$self;
Branch: 1 branch
BranchTrueFalseTotal
if defined $$self 622 0 622
133 }
134 }
135  
136 80 ▶sub after_new {
Subroutine after_new: called CC=7 SCAR=19.9
Pod documented
137 321 (my MY $self) = @_;
138 321 $self->SUPER::after_new;
139 321 ▶ $self->{index_name} //= "";
Condition100%2/2
$self->{"index_name"} //= ""
l!l
28239
MC/DC100%1/1
$self->{"index_name"} //= ""
$self->{"index_name"}
Truth table100%2/2
A
A= $self->{"index_name"}
Aresult
11
00
140 321 ▶ $self->{ext_public} //= $self->default_ext_public;
Condition66%2/3
$self->{"ext_public"} //= $self->default_ext_public
l!l&&r!l&&!r
282390
MC/DC0%0/2
$self->{"ext_public"} //= $self->default_ext_public
$self->{"ext_public"} $self->default_ext_public
Truth table66%2/3
A //= B
A= $self->{"ext_public"}B= $self->default_ext_public
ABresult
1X1
011
000
141 321 ▶ $self->{ext_private} //= $self->default_ext_private;
Condition66%2/3
$self->{"ext_private"} //= $self->default_ext_private
l!l&&r!l&&!r
282390
MC/DC0%0/2
$self->{"ext_private"} //= $self->default_ext_private
$self->{"ext_private"} $self->default_ext_private
Truth table66%2/3
A //= B
A= $self->{"ext_private"}B= $self->default_ext_private
ABresult
1X1
011
000
142 321 ▶ $self->{body_argument} //= $self->default_body_argument;
Condition66%2/3
$self->{"body_argument"} //= $self->default_body_argument
l!l&&r!l&&!r
283380
MC/DC0%0/2
$self->{"body_argument"} //= $self->default_body_argument
$self->{"body_argument"} $self->default_body_argument
Truth table66%2/3
A //= B
A= $self->{"body_argument"}B= $self->default_body_argument
ABresult
1X1
011
000
143 321 ▶ $self->{body_argument_type} //= $self->default_body_argument_type;
Condition66%2/3
$self->{"body_argument_type"} //= $self->default_body_argument_type
l!l&&r!l&&!r
283380
MC/DC0%0/2
$self->{"body_argument_type"} //= $self->default_body_argument_type
$self->{"body_argument_type"} $self->default_body_argument_type
Truth table66%2/3
A //= B
A= $self->{"body_argument_type"}B= $self->default_body_argument_type
ABresult
1X1
011
000
144 321 ▶ $self->{output_encoding} //= $self->default_output_encoding;
Condition66%2/3
$self->{"output_encoding"} //= $self->default_output_encoding
l!l&&r!l&&!r
282390
MC/DC0%0/2
$self->{"output_encoding"} //= $self->default_output_encoding
$self->{"output_encoding"} $self->default_output_encoding
Truth table66%2/3
A //= B
A= $self->{"output_encoding"}B= $self->default_output_encoding
ABresult
1X1
011
000
145 }
146  
147 321 ▶sub _after_after_new {
Subroutine _after_after_new: called CC=1 SCAR=0.0
148 321 (my MY $self) = @_;
149 321 weaken($self->{factory});
150 }
151  
152 0 ▶sub rel_app_name {
Subroutine rel_app_name: not called CC=2 SCAR=17.9
Pod undocumented
153 0 (my MY $self) = @_;
154 0 ▶ unless ($SYS) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($YATT::Lite::SYS) 0 0 0
155 0 Carp::croak "rel_app_name() is called without setting \$SYS!";
156 }
157 # XXX: This assumes $dir is somewhere under $app_root tree.
158 0 my $rel_app_name = substr($self->{dir}, length($SYS->app_root));
159 # Make sure leading / is removed.
160 0 $rel_app_name =~ s|^/||;
161 0 $rel_app_name;
162 }
163  
164 # XXX: kludge!
165 78 ▶sub find_neighbor_yatt {
Subroutine find_neighbor_yatt: called CC=1 SCAR=0.0
Pod undocumented
166 78 (my MY $self, my ($dir)) = @_;
167 78 $self->{factory}->load_yatt($dir);
168 }
169 77 ▶sub find_neighbor_vfs {
Subroutine find_neighbor_vfs: called CC=1 SCAR=0.0
Pod undocumented
170 77 (my MY $self, my ($dir)) = @_;
171 77 $self->find_neighbor_yatt($dir)->get_trans;
172 }
173 46 ▶sub find_neighbor {
Subroutine find_neighbor: called CC=1 SCAR=0.0
Pod undocumented
174 46 (my MY $self, my ($dir)) = @_;
175 46 $self->find_neighbor_vfs($dir)->root;
176 }
177  
178 #
179 # list all configs (named $name). (base first, then local one)
180 # (useful to avoid config repeation)
181 #
182 2 ▶sub cget_all {
Subroutine cget_all: called CC=2 SCAR=7.6
Pod undocumented
183 2 (my MY $self, my $name) = @_;
184 2 ▶ if ($name =~ /^_/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^_/) 0 2 2
185 0 croak "Private field is prohibited: $name";
186 }
187 (map($_->cget_all($name)
188 , $self->list_base_obj)
189 2 , lexpand($self->{$name}));
190 }
191  
192 2 ▶sub list_base_obj {
Subroutine list_base_obj: called CC=1 SCAR=0.0
Pod undocumented
193 2 (my MY $self) = @_;
194 map {
195 2 $self->find_neighbor_yatt($self->app_path_normalize($_))
196 } $self->list_base_dir;
197 }
198  
199 2 ▶sub list_base_dir {
Subroutine list_base_dir: called CC=3 SCAR=11.7
Pod undocumented
200 2 (my MY $self) = @_;
201  
202 2 ▶ my $base = $self->{base} // do {
Condition33%1/3
$self->{"base"} // do { my(%vfs) = lexpand($self->{"vfs"}); [map({if (ref $_ eq "ARRAY") { my(%vfs_base) = @$_; $vfs_base{"dir"}; } else { $_->{"path"}; } ;} lexpand($vfs{"base"}))] }
l!l&&r!l&&!r
020
MC/DC0%0/2
$self->{"base"} // do { my(%vfs) = lexpand($self->{"vfs"}); [map({if (ref $_ eq "ARRAY") { my(%vfs_base) = @$_; $vfs_base{"dir"}; } else { $_->{"path"}; } ;} lexpand($vfs{"base"}))] }
$self->{"base"} do { my(%vfs) = lexpand($self->{"vfs"}); [map({if (ref $_ eq "ARRAY") { my(%vfs_base) = @$_; $vfs_base{"dir"}; } else { $_->{"path"}; } ;} lexpand($vfs{"base"}))] }
Truth table33%1/3
A // B
A= $self->{"base"}B= do { my(%vfs) = lexpand($self->{"vfs"}); [map({if (ref $_ eq "ARRAY") { my(%vfs_base) = @$_; $vfs_base{"dir"}; } else { $_->{"path"}; } ;} lexpand($vfs{"base"}))] }
ABresult
1X1
011
000
203 2 my %vfs = lexpand($self->{vfs});
204 [map {
205 #
206 # Each element of $vfs{base} is either ARRAY (of vfs spec)
207 # or YATT::Lite::VFS::Dir object (instantiated from spec).
208 #
209 1 ▶ if (ref $_ eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ eq 'ARRAY') { } 1 0 1
210 1 my %vfs_base = @$_;
211 1 $vfs_base{dir};
212 } else {
213 0 $_->{path};
214 }
215 2 } lexpand($vfs{base})];
216 };
217  
218 2 lexpand($base);
219 }
220  
221 #========================================
222 # file extension based handler dispatching.
223 #========================================
224  
225 495 ▶sub handle {
Subroutine handle: called CC=3 SCAR=11.2
Pod undocumented
226 495 (my MY $self, my ($ext, $con, $file)) = @_;
227 495 local ($YATT, $CON) = ($self, $con);
228 495 $con->configure(yatt => $self);
229 495 ▶ if (my $enc = $self->{output_encoding}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $enc = $self->{"output_encoding"}) 495 0 495
230 495 $con->configure(encoding => $enc);
231 }
232  
233 495 ▶ unless (defined $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 0 495 495
234 0 confess "\n\nFilename for DirHandler->handle() is undef!"
235 ." in $self->{app_ns}.\n";
236 }
237  
238 495 my $sub = $YATT->find_handler($ext, $file, $CON);
239  
240 495 my $result = $sub->($YATT, $CON, $file);
241  
242 360 try_invoke($CON, 'flush_headers');
243  
244 360 $result;
245 }
246  
247 21 ▶sub render {
Subroutine render: called CC=2 SCAR=6.9
Pod documented
248 21 my MY $self = shift;
249 21 my $raw_bytes = $self->render_encoded(@_);
250 21 ▶ if ($self->{render_as_bytes}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'render_as_bytes'}) { } 1 20 21
251 1 $raw_bytes
252 } else {
253 20 Encode::decode(utf8 => $raw_bytes);
254 }
255 }
256  
257 21 ▶sub render_encoded {
Subroutine render_encoded: called CC=4 SCAR=13.9
Pod undocumented
258 21 my MY $self = shift;
259 21 my $buffer; {
260 21 ▶ my $encName = $self->{render_as_bytes} ? undef : $self->{output_encoding};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'render_as_bytes'} ? : 1 20 21
261 21 ▶ my $con = $SYS
Branch: 2 branches
BranchTrueFalseTotal
$YATT::Lite::SYS ? : 0 21 21
$encName ? : 20 1 21
262 ? $SYS->make_connection(undef, buffer => \$buffer, yatt => $self,
263 noheader => 1,
264 encoding => $encName)
265 : ostream(\$buffer, $encName ? ":encoding($encName)" : "");
266 21 $self->render_into($con, @_);
267 }
268 21 $buffer;
269 }
270  
271 150 ▶sub render_into {
Subroutine render_into: called CC=3 SCAR=11.0
Pod documented
272 150 (my MY $self, my ($con, $file, $args)) = @_;
273 150 local ($YATT, $CON) = ($self, $con);
274 150 ▶ if (ref $file eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file eq 'ARRAY') { } 1 149 150
275 # [$file, $type, $item]
276 1 $self->open_trans->render_into($CON, $file, $args);
277 } else {
278 $self->raw_render_into(
279 $con,
280 149 ▶ YATT::Lite::Util::rootname($file || $self->{index_name}),
Condition100%3/3
$file || $self->{'index_name'}
l!l&&r!l&&!r
14063
MC/DC100%2/2
$file || $self->{'index_name'}
$file $self->{'index_name'}
Truth table100%3/3
A || B
A= $fileB= $self->{'index_name'}
ABresult
1X1
011
000
281 $args,
282 );
283 }
284 136 try_invoke($con, 'flush_headers');
285 }
286  
287 149 ▶sub raw_render_into {
Subroutine raw_render_into: called CC=1 SCAR=0.0
Pod undocumented
288 149 (local ($YATT), my ($con, $file, $args)) = @_;
289 149 my ($part, $sub, $pkg) = $YATT->open_trans->find_part_renderer($file);
290 135 $sub->($pkg, $con, $part->reorder_hash_params($args));
291 }
292  
293 411 ▶sub find_handler {
Subroutine find_handler: called CC=5 SCAR=18.9
Pod documented
294 411 (my MY $self, my ($ext, $file, $con)) = @_;
295 411 ▶ $ext //= $self->cut_ext($file) || $self->{ext_public};
Condition16%1/6
$ext //= $self->cut_ext($file) || $self->{"ext_public"}
l!l&&r!l&&!r
41100
$self->cut_ext($file) || $self->{'ext_public'}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ext //= $self->cut_ext($file) || $self->{"ext_public"}
$ext $self->cut_ext($file) $self->{'ext_public'}
Truth table0%0/4
A //= B || C
A= $extB= $self->cut_ext($file)C= $self->{'ext_public'}
ABCresult
1XX1
01X1
0011
0000
296 411 ▶ $ext = "yatt" if $ext eq $self->{ext_public};
Branch: 1 branch
BranchTrueFalseTotal
if $ext eq $self->{"ext_public"} 399 12 411
297 411 ▶ my $sub = $self->can("_handle_$ext")
Branch: 1 branch
BranchTrueFalseTotal
my $sub = $self->can("_handle_$ext") or die "Unsupported file type: $ext" 411 0 411
298 or die "Unsupported file type: $ext";
299 411 $sub;
300 }
301  
302 #----------------------------------------
303  
304 # 直接呼ぶことは禁止。∵ $YATT, $CON を設定するのは handle の役目だから。
305 399 ▶sub _handle_yatt {
Subroutine _handle_yatt: called CC=1 SCAR=0.0
306 399 (my MY $self, my ($con, $file)) = @_;
307  
308 399 my ($part, $sub, $pkg, $args)
309 = $self->prepare_part_handler($con, $file);
310  
311 390 $sub->($pkg, $con, @$args);
312  
313 330 $con;
314 }
315  
316 0 ▶sub _handle_ytmpl {
Subroutine _handle_ytmpl: not called CC=1 SCAR=6.9
317 0 (my MY $self, my ($con, $file)) = @_;
318  
319 0 $self->raise_psgi_error(403, "Forbidden filetype: $file");
320 }
321  
322 #----------------------------------------
323  
324 0 ▶sub prepare_part_handler {
Subroutine prepare_part_handler: not called CC=6 SCAR=37.4
Pod undocumented
325 0 (my MY $self, my ($con, $file)) = @_;
326  
327 0 my $trans = $self->open_trans;
328  
329 0 my $mapped = [$file, my ($type, $item) = $con->sigil_type_item()];
330 0 ▶ if (not $self->{dont_debug_param}
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"dont_debug_param"} and -e ".htdebug_param") 0 0 0
Condition0%0/3
not $self->{"dont_debug_param"} and -e ".htdebug_param"
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"dont_debug_param"} and -e ".htdebug_param"
not $self->{"dont_debug_param"} -e ".htdebug_param"
Truth table0%0/3
not(A) and B
A= not $self->{"dont_debug_param"}B= -e ".htdebug_param"
ABresult
0X0
100
111
331 and -e ".htdebug_param") {
332 0 $self->dump($mapped, [map {[$_ => $con->param($_)]} $con->param]);
333 }
334  
335 # XXX: public に限定するのはどこで? ここで?それとも find_自体?
336 0 my ($part, $sub, $pkg) = $trans->find_part_handler($mapped);
337 0 ▶ unless ($part->public) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($part->public) 0 0 0
338 # XXX: refresh する手もあるだろう。
339 0 croak $self->error(q|Forbidden request %s|, terse_dump($mapped));
340 }
341  
342 0 my @args; @args = $trans->reorder_cgi_params($part, $con)
343 0 ▶ unless $self->{dont_map_args} || $part->isa($trans->Action);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"dont_map_args"} or $part->isa($trans->Action) 0 0 0
Condition0%0/3
$self->{"dont_map_args"} or $part->isa($trans->Action)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"dont_map_args"} or $part->isa($trans->Action)
$self->{"dont_map_args"} $part->isa($trans->Action)
Truth table0%0/3
A or B
A= $self->{"dont_map_args"}B= $part->isa($trans->Action)
ABresult
1X1
011
000
344  
345 0 ($part, $sub, $pkg, \@args);
346 }
347  
348 # XXX: deprecated
349 399 ▶sub parse_request_sigil {
Subroutine parse_request_sigil: called CC=1 SCAR=0.0
Pod undocumented
350 399 (my MY $self, my ($con)) = @_;
351 399 $con->sigil_type_item();
352 }
353  
354 495 ▶sub cut_ext {
Subroutine cut_ext: called CC=3 SCAR=11.4
Pod undocumented
355 495 my ($self, $fn) = @_;
356 495 ▶ croak "Undefined filename!" unless defined $fn;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fn 0 495 495
357 495 ▶ return undef unless $fn =~ s/\.(\w+$)//;
Branch: 1 branch
BranchTrueFalseTotal
unless $fn =~ s/\.(\w+$)// 0 495 495
358 495 $1;
359 }
360  
361 #========================================
362 # hook
363 #========================================
364 648 ▶sub finalize_connection {}
Subroutine finalize_connection: called CC=1 SCAR=0.0
Pod undocumented
365  
366 #========================================
367 # Output encoding. Used in scripts/yatt*
368 #========================================
369 4 ▶sub fconfigure_encoding {
Subroutine fconfigure_encoding: called CC=4 SCAR=14.0
Pod undocumented
370 4 my MY $self = shift;
371 4 ▶ return unless $self->{output_encoding};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"output_encoding"} 0 4 4
372 4 my $enc = "encoding($self->{output_encoding})";
373 4 require PerlIO;
374 4 foreach my $fh (@_) {
375 8 ▶ next if grep {$_ eq $enc} PerlIO::get_layers($fh);
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $enc;} &PerlIO::get_layers($fh) 0 8 8
376 8 binmode($fh, ":$enc");
377 }
378 4 $self;
379 }
380  
381 #========================================
382 # Delayed loading of YATT::Lite::Core
383 #========================================
384  
385 80 *open_vfs = *open_trans; *open_vfs = *open_trans;
386 664 ▶sub open_trans {
Subroutine open_trans: called CC=1 SCAR=0.0
Pod undocumented
387 664 (my MY $self) = @_;
388 664 my $trans = $self->get_trans;
389 659 $trans->reset_refresh_mark;
390 659 $trans;
391 }
392  
393 80 *get_vfs = *get_trans; *get_vfs = *get_trans;
394 1560 ▶sub get_trans {
Subroutine get_trans: called CC=2 SCAR=6.9
Pod undocumented
395 1560 (my MY $self) = @_;
396 1560 ▶ $self->{_YATT} || $self->build_trans($self->{tmpl_cache});
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_YATT"} or $self->build_trans($self->{"tmpl_cache"}) 1318 242 1560
397 }
398  
399 242 ▶sub build_trans {
Subroutine build_trans: called CC=3 SCAR=11.4
Pod undocumented
400 242 (my MY $self, my ($vfscache, $vfsspec, @rest)) = @_;
401 242 my $class = $self->default_trans;
402 242 ckrequire($class);
403  
404 242 ▶ my @vfsspec = @{$vfsspec || $self->{vfs}};
Condition33%1/3
$vfsspec || $self->{'vfs'}
l!l&&r!l&&!r
02420
MC/DC0%0/2
$vfsspec || $self->{'vfs'}
$vfsspec $self->{'vfs'}
Truth table33%1/3
A || B
A= $vfsspecB= $self->{'vfs'}
ABresult
1X1
011
000
405 242 ▶ push @vfsspec, base => $self->{base} if $self->{base};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"base"} 0 242 242
406  
407 $self->{_YATT} = $class->new
408 (\@vfsspec
409 , facade => $self
410 , cache => $vfscache
411 , entns2vfs_item => $self->{entns2vfs_item}
412 , entns => $self->{_entns}
413 , @rest
414 242 , $self->cf_delegate_defined($self->_cf_delegates));
415 }
416  
417 243 ▶sub _cf_delegates {
Subroutine _cf_delegates: called CC=1 SCAR=0.0
418 243 qw(namespace
419 base
420 die_in_error
421 tmpl_encoding
422 debug_cgen
423 debug_parser
424 special_entities
425 no_lineinfo
426 check_lineno
427 index_name
428 ext_public
429 ext_private
430 rc_script
431 lcmsg_sink
432 only_parse
433 always_refresh_deps
434 no_mro_c3
435 import
436 match_argsroute_first
437 stash_unknown_params_to
438 body_argument
439 body_argument_type
440 prefer_call_for_entity
441 no_conditional_call
442 allow_bare_entity_in_decl
443 pagevars
444 argmacro
445 )
446 }
447  
448 321 ▶sub _before_after_new {
Subroutine _before_after_new: called CC=2 SCAR=7.6
449 321 (my MY $self) = @_;
450 321 ▶ $self->{app_ns} //= $self->default_app_ns;
Condition33%1/3
$self->{"app_ns"} //= $self->default_app_ns
l!l&&r!l&&!r
32100
MC/DC0%0/2
$self->{"app_ns"} //= $self->default_app_ns
$self->{"app_ns"} $self->default_app_ns
Truth table33%1/3
A //= B
A= $self->{"app_ns"}B= $self->default_app_ns
ABresult
1X1
011
000
451 321 $self->{_entns} = $self->ensure_entns($self->{app_ns});
452 }
453  
454 #========================================
455 # Code generator class
456 #========================================
457  
458 sub root_CGEN_perl () { 'YATT::Lite::CGen::Perl' }
459 80 *CGEN_perl = *root_CGEN_perl; *CGEN_perl = *root_CGEN_perl;
460 207 ▶sub ensure_cgen_for {
Subroutine ensure_cgen_for: called CC=1 SCAR=0.0
Pod undocumented
461 207 my ($mypack, $type, $app_ns) = @_;
462 207 $mypack->ensure_supplns("CGEN_$type" => $app_ns);
463 }
464  
465 564 ▶sub get_cgen_class {
Subroutine get_cgen_class: called CC=3 SCAR=11.3
Pod undocumented
466 564 (my MY $self, my $type) = @_;
467 564 my $name = "CGEN_$type";
468 564 ▶ my $sub = $self->can("root_$name")
Branch: 1 branch
BranchTrueFalseTotal
my $sub = $self->can("root_$name") or croak("Unknown cgen class: $type") 564 0 564
469 or croak "Unknown cgen class: $type";
470 $self->{_cgen_class}{$type}
471 564 ▶ ||= $self->ensure_cgen_for($type, $self->{app_ns});
Condition66%2/3
$self->{"_cgen_class"}{$type} ||= $self->ensure_cgen_for($type, $self->{"app_ns"})
l!l&&r!l&&!r
3602040
MC/DC0%0/2
$self->{"_cgen_class"}{$type} ||= $self->ensure_cgen_for($type, $self->{"app_ns"})
$self->{"_cgen_class"}{$type} $self->ensure_cgen_for($type, $self->{"app_ns"})
Truth table66%2/3
A ||= B
A= $self->{"_cgen_class"}{$type}B= $self->ensure_cgen_for($type, $self->{"app_ns"})
ABresult
1X1
011
000
472 }
473  
474 120 ▶sub is_default_cgen_ready {
Subroutine is_default_cgen_ready: called CC=1 SCAR=0.0
Pod undocumented
475 120 (my MY $self) = @_;
476 120 $self->{_cgen_class}{perl};
477 }
478  
479 #========================================
480 # Entity
481 #========================================
482  
483 175 ▶sub root_EntNS { 'YATT::Lite::Entities' }
Subroutine root_EntNS: called CC=1 SCAR=0.0
Pod undocumented
484  
485 # ${app_ns}::EntNS を作り、(YATT::Lite::Entities へ至る)継承関係を設定する。
486 # $app_ns に EntNS constant を追加する。
487 # 複数回呼ばれた場合、既に定義済みの entns を返す
488  
489 3030 ▶sub should_use_mro_c3 {
Subroutine should_use_mro_c3: called CC=2 SCAR=6.9
Pod undocumented
490 3030 (my MY $self_or_pack) = @_;
491 3030 ▶ if (ref $self_or_pack) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self_or_pack) { } 1296 1734 3030
492 not $self_or_pack->{no_mro_c3}
493 1296 } else {
494 1734 mro::get_mro($self_or_pack) eq 'c3';
495 }
496 }
497  
498 #========================================
499  
500 # These ns-related methods (ensure_...) are called as Class Methods.
501 # This means you can't touch instance fields.
502  
503 # Old interface.
504 # ensure_entns($app_ns, @base_entns)
505 # returns EntNS for $app_ns with correct inheritance settings.
506 #
507 1898 ▶sub ensure_entns {
Subroutine ensure_entns: called CC=1 SCAR=0.0
Pod undocumented
508 1898 my ($mypack, $app_ns, @base_entns) = @_;
509 1898 my $entns = $mypack->ensure_supplns(EntNS => $app_ns, \@base_entns
510 , undef, +{no_fields => 1});
511 1898 $entns;
512 }
513  
514 # New interface.
515 # ensure_supplns($kind, $app_ns, [@base_suppls], [@base_mains], {%opts})
516 # returns ${app_ns}::${kind} with correct inheritance.
517 #
518 # [@base_suppls] gives base supplemental classes for this supplns.
519 # [@base_mains] gives (not supplemental but) main classes for this.
520 #
521 # If both base_suppls and base_mains is empty, base_mains is derived
522 # from current @ISA of $app_ns.
523 #
524 2519 ▶sub ensure_supplns {
Subroutine ensure_supplns: called CC=15 SCAR=27.2
Pod undocumented
525 2519 my ($mypack, $kind, $app_ns, $base_suppls, $base_mains, $opts) = @_;
526  
527 2519 my $supplns = join("::", $app_ns, $kind);
528  
529 80 ▶ my $sym = do {no strict 'refs'; \*{$supplns}};
Subroutine BEGIN: called CC=1 SCAR=0.0
530 2519 ▶ if (*{$sym}{CODE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (*{$sym;}{"CODE"}) 1209 1310 2519
531 # croak "$kind for $app_ns is already defined!";
532 1209 return $supplns;
533 }
534  
535 1310 my $app_ns_filename = do {
536 1310 my $sub = $app_ns->can("filename");
537 1310 ▶ $sub ? ("(For path '".($sub->() // '')."')") : "";
Branch: 1 branch
BranchTrueFalseTotal
$sub ? : 474 836 1310
Condition100%2/2
&$sub() // ""
l!l
4695
MC/DC100%1/1
&$sub() // ""
&$sub()
Truth table100%2/2
A
A= &$sub()
Aresult
11
00
538 };
539  
540 1310 print STDERR "# First ensure_supplns $kind for $app_ns $app_ns_filename: "
541 , terse_dump($base_suppls, $base_mains, $opts), "\n" if DEBUG;
542  
543 1310 ▶ if (not $base_suppls and not $base_mains) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($base_suppls or $base_mains) 410 900 1310
Condition66%2/3
$base_suppls or $base_mains
l!l&&r!l&&!r
9000410
MC/DC50%1/2
$base_suppls or $base_mains
$base_suppls $base_mains
Truth table66%2/3
A or B
A= $base_supplsB= $base_mains
ABresult
1X1
011
000
544 410 my @isa = list_isa($app_ns);
545 410 print STDERR "# app_ns $app_ns isa: "
546 , terse_dump(@isa), "\n" if DEBUG;
547  
548 410 ▶ $base_mains = $mypack->should_use_mro_c3
Branch: 1 branch
BranchTrueFalseTotal
$mypack->should_use_mro_c3 ? : 406 4 410
549 ? [reverse @isa] : \@isa;
550 }
551  
552 my @baseclass = (lexpand($base_suppls), map {
553 1310 $mypack->ensure_supplns($kind => $_, undef, undef, $opts);
554 } lexpand($base_mains));
555  
556 1310 ▶ if ($mypack->should_use_mro_c3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mypack->should_use_mro_c3) { } 1304 6 1310
557 1304 print STDERR "# $kind - Set mro c3 for $supplns $app_ns_filename since $mypack uses c3\n" if DEBUG;
558 1304 mro::set_mro($supplns, 'c3')
559 } else {
560 6 print STDERR "# $kind - Keep mro dfs for $supplns $app_ns_filename since $mypack uses dfs\n" if DEBUG;
561 }
562  
563 # $app_ns が %FIELDS 定義を持たない時(ex YLObjectでもPartialでもない)に限り、
564 # YATT::Lite への継承を設定する
565 1310 ▶ unless (YATT::Lite::MFields->has_fields($app_ns)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("YATT::Lite::MFields"->has_fields($app_ns)) 39 1271 1310
566 # XXX: $mypack への継承にすると、あちこち動かなくなるぜ?なんで?
567 39 print STDERR "# app_ns - Add ISA for '$app_ns' with fields: ",MY,"\n"
568 if DEBUG;
569 39 YATT::Lite::MFields->add_isa_to($app_ns, MY)->define_fields($app_ns);
570 }
571  
572 1310 ▶ unless (grep {$_->can($kind)} @baseclass) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_->can($kind);} @baseclass) 1310 0 1310
573 1310 ▶ my $base = try_invoke($app_ns, $kind) // $mypack->can("root_$kind")->();
Condition66%2/3
try_invoke($app_ns, $kind) // $mypack->can("root_$kind")->()
l!l&&r!l&&!r
11351750
MC/DC0%0/2
try_invoke($app_ns, $kind) // $mypack->can("root_$kind")->()
try_invoke($app_ns, $kind) $mypack->can("root_$kind")->()
Truth table66%2/3
A // B
A= try_invoke($app_ns, $kind)B= $mypack->can("root_$kind")->()
ABresult
1X1
011
000
574 1310 ckrequire($base);
575 1310 print STDERR "# $kind - Set default base for $supplns <- ($base)\n" if DEBUG;
576 1310 ▶ if ($mypack->should_use_mro_c3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mypack->should_use_mro_c3) { } 1304 6 1310
577 1304 push @baseclass, $base;
578 } else {
579 6 unshift @baseclass, $base;
580 }
581 }
582  
583 1310 do {
584 1310 my @cls = uniq @baseclass;
585 1310 print STDERR "# $kind - Add ISA for $supplns <- (@cls)\n" if DEBUG;
586 1310 YATT::Lite::MFields->add_isa_to($supplns, @cls);
587 };
588 1310 ▶ if (not $opts->{no_fields}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"no_fields"}) 410 900 1310
589 410 YATT::Lite::MFields->define_fields($supplns);
590 }
591  
592 1310 set_inc($supplns, 1);
593  
594 # $kind() を足すのは最後にしないと、再帰継承に陥る
595 1310 ▶ unless (my $code = *{$sym}{CODE}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $code = *{$sym;}{'CODE'}) { } 0 1310 1310
if (do { (my $old = &$code()) ne $supplns }) { } 0 0 0
596 1310 define_const($sym, $supplns);
597 } elsif ((my $old = $code->()) ne $supplns) {
598 0 croak "Can't add $kind() to '$app_ns'. Already has $kind as $old!";
599 } else {
600 # ok.
601 }
602 1310 $supplns
603 }
604  
605 213 ▶sub list_entns {
Subroutine list_entns: called CC=2 SCAR=6.9
Pod undocumented
606 213 my ($pack, $inspected) = @_;
607 map {
608 213 ▶ defined(symtab($_)->{'EntNS'}) ? join("::", $_, 'EntNS') : ()
Branch: 1 branch
BranchTrueFalseTotal
defined symtab($_)->{'EntNS'} ? : 204 129 333
609 } list_isa($inspected)
610 }
611  
612 # use YATT::Lite qw(Entity); で呼ばれ、
613 # $callpack に Entity 登録関数を加える.
614 657 ▶sub define_Entity {
Subroutine define_Entity: called CC=5 SCAR=16.1
Pod undocumented
615 657 my ($myPack, $opts, $callpack, @base) = @_;
616  
617 # Entity を追加する先は、 $callpack が Object 系か、 stateless 系かで変化する
618 # Object 系の場合は、 ::EntNS を作ってそちらに加え, 同時に YATT() も定義する
619 657 my $is_objclass = is_objclass($callpack);
620 657 ▶ my $destns = $is_objclass
Branch: 1 branch
BranchTrueFalseTotal
$is_objclass ? : 650 7 657
621 ? $myPack->ensure_entns($callpack, @base)
622 : $callpack;
623  
624 # 既にあるなら何もしない。... バグの温床にならないことを祈る。
625 657 my $ent = globref($callpack, 'Entity');
626 657 ▶ unless (*{$ent}{CODE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (*{$ent;}{"CODE"}) 646 11 657
627 2052 ▶ *$ent = sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
628 2052 my ($name, $sub) = @_;
629 2052 ▶ if ($myPack->add_entity_into($destns, $name, $sub)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($myPack->add_entity_into($destns, $name, $sub)) 2052 0 2052
630 2052 print STDERR "# defined entity $name in $destns\n" if DEBUG;
631 }
632 646 };
633 }
634  
635 657 ▶ if ($is_objclass) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_objclass) 650 7 657
636 650 *{globref($destns, 'YATT')} = *YATT;
637  
638 650 ▶ unless ($callpack->can("entity")) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($callpack->can("entity")) 94 556 650
639 94 *{globref($callpack, "entity")} = $myPack->can('entity');
640 }
641 }
642  
643 657 return $destns;
644 }
645  
646 #
647 # Note about 'Action' registration mechanism in .htyattrc.pl
648 #
649 # First, *globref() = $action is not enough. Because...
650 #
651 # There are 2 places to hold actions.
652 # 1. $YATT->{Action} <= comes from *.ydo
653 # 2. $vfs_folder->{Item} <= comes from !yatt:action in templates
654 #
655 # Action in .htyattrc.pl is, special case of 2.
656 # Since 2. is managed by yatt vfs, it must be wrapped by Action object
657 # so that $vfs->find_part_handler works well.
658 #
659 #
660 # This is bit complicated because .htyattrc.pl is loaded *BEFORE* $YATT
661 # is instantiated. This means "Action => name, $handler" can not touch $YATT
662 # at that time. So, I need to delay actual registration until $YATT is created.
663 #
664 # To achieve this, $handler is registered first in %Actions of caller,
665 # then installed into actual vfs.
666 #
667 # Also note: loading of .htyattrc.pl is handled by Factory.
668 #
669 sub ACTION_DICT_SYM () {'Actions'}
670 1 ▶sub define_Action {
Subroutine define_Action: called CC=1 SCAR=0.0
Pod undocumented
671 1 my ($myPack, $opts, $callpack) = @_;
672  
673 1 *{globref($callpack, ACTION_DICT_SYM)} = my $action_dict = +{};
674  
675 1 ▶ *{globref($callpack, 'Action')} = sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
676 1 my ($name, $sub) = @_;
677 1 my @caller = my ($callpack, $filename, $lineno) = caller;
678 1 ▶ if (defined (my $old = $action_dict->{$name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $old = $action_dict->{$name})) 0 1 1
679 0 croak "Duplicate definition of Action '$name'! previously"
680 ." at $old->[1][1] line $old->[1][2]\n new at $filename line $lineno\n";
681 }
682 1 $action_dict->{$name} = [$sub, \@caller];
683 1 };
684 }
685  
686 17 ▶sub setup_rc_actions {
Subroutine setup_rc_actions: called CC=3 SCAR=11.0
Pod undocumented
687 17 (my $self) = @_;
688 17 ▶ my $glob = look_for_globref($self, ACTION_DICT_SYM)
Branch: 1 branch
BranchTrueFalseTotal
my $glob = look_for_globref($self, "Actions") or return 1 16 17
689 or return;
690 1 my $dict = *{$glob}{HASH};
691  
692 1 my $vfs = $self->get_vfs;
693 1 foreach my $name (keys %$dict) {
694 1 $vfs->add_root_action_handler($name, @{$dict->{$name}});
695 }
696 }
697  
698 # ここで言う Object系とは、
699 # YATT::Lite::Object を継承してるか、
700 # 又は既に %FIELDS が定義されている class
701 # のこと
702 657 ▶sub is_objclass {
Subroutine is_objclass: called CC=3 SCAR=11.0
Pod undocumented
703 657 my ($class) = @_;
704 657 ▶ return 1 if UNIVERSAL::isa($class, 'YATT::Lite::Object');
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($class, "YATT::Lite::Object") 638 19 657
705 19 ▶ my $sym = look_for_globref($class, 'FIELDS')
Branch: 1 branch
BranchTrueFalseTotal
my $sym = look_for_globref($class, "FIELDS") or return 0 12 7 19
706 or return 0;
707 12 *{$sym}{HASH};
708 }
709  
710 0 ▶sub entity {
Subroutine entity: not called CC=1 SCAR=6.9
Pod documented
711 0 (my MY $yatt, my $name) = splice @_, 0, 2;
712 0 my $this = $yatt->EntNS;
713 0 $this->can("entity_$name")->($this, @_);
714 }
715  
716 80 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
717 80 MY->define_Entity(undef, MY);
718 }
719  
720 #========================================
721 # Locale gettext support.
722 #========================================
723  
724 0 ▶sub use_encoded_config {
Subroutine use_encoded_config: not called CC=1 SCAR=6.9
Pod undocumented
725 0 (my MY $self) = @_;
726 $self->{tmpl_encoding}
727 0 }
728  
729 80 ▶use YATT::Lite::Partial::Gettext;
Subroutine BEGIN: called CC=1 SCAR=0.0
730  
731 # Extract (and cache, for later merging) l10n msgs from filelist.
732 # By default, it merges $filelist into existing locale_cache.
733 # To get fresh list, explicitly pass $msglist=[].
734 #
735 3 ▶sub lang_extract_lcmsg {
Subroutine lang_extract_lcmsg: called CC=3 SCAR=11.0
Pod undocumented
736 3 (my MY $self, my ($lang, $filelist, $msglist, $msgdict)) = @_;
737  
738 3 ▶ if (not $msglist and not $msgdict) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msglist or $msgdict) 1 2 3
Condition66%2/3
$msglist or $msgdict
l!l&&r!l&&!r
201
MC/DC50%1/2
$msglist or $msgdict
$msglist $msgdict
Truth table66%2/3
A or B
A= $msglistB= $msgdict
ABresult
1X1
011
000
739 1 ($msglist, $msgdict) = $self->lang_msgcat($lang)
740 }
741  
742 3 $self->get_trans->extract_lcmsg($filelist, $msglist, $msgdict);
743 }
744  
745 0 ▶sub default_default_lang { 'en' }
Subroutine default_default_lang: not called CC=1 SCAR=6.9
Pod undocumented
746 0 ▶sub default_lang {
Subroutine default_lang: not called CC=2 SCAR=17.9
Pod undocumented
747 0 (my MY $self) = @_;
748 0 ▶ $self->{default_lang} || $self->default_default_lang;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"default_lang"} or $self->default_default_lang 0 0 0
749 }
750  
751 #========================================
752 # Delegation to the core(Translator, which is useless for non-templating.)
753 #
754 # Note: these wrappers do not call YATT::Lite::VFS->reset_refresh_mark.
755 # This means once templates is compiled, it is not updated even if
756 # they are modified. You can avoid this behavior by
757 # directly using $YATT->open_trans->xxx instead.
758 #========================================
759 80 foreach
760 (qw/find_part
761 find_part_from_entns
762 find_file
763 find_product
764 find_renderer
765 find_part_handler
766 ensure_parsed
767  
768 list_items
769 list_base
770 list_internal_base_folders
771  
772 add_to
773 /
774 ) {
775 880 my $meth = $_;
776 880 *{globref(MY, $meth)} = subname(join("::", MY, $meth)
777 801 ▶ , sub { shift->get_trans->$meth(@_) });
Subroutine __ANON__: called CC=1 SCAR=0.0
778 }
779  
780 0 ▶sub dump {
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
781 0 my MY $self = shift;
782 # XXX: charset...
783 die [200, [$self->secure_text_plain]
784 0 , [map {terse_dump($_)."\n"} @_]];
785 }
786  
787 #========================================
788 # Builtin Entities.
789 #========================================
790  
791 3 ▶sub YATT::Lite::EntNS::entity_template {
Subroutine entity_template: called CC=2 SCAR=8.1
Pod undocumented
792 3 my ($this, $pkg) = @_;
793 3 ▶ $YATT->get_trans->find_template_from_package($pkg // $this);
Condition33%1/3
$pkg // $this
l!l&&r!l&&!r
030
MC/DC0%0/2
$pkg // $this
$pkg $this
Truth table33%1/3
A // B
A= $pkgB= $this
ABresult
1X1
011
000
794 };
795  
796 0 ▶sub YATT::Lite::EntNS::entity_stash {
Subroutine entity_stash: not called CC=6 SCAR=37.4
Pod undocumented
797 0 my $this = shift;
798 0 my $prop = $CON->prop;
799 0 ▶ my $stash = $prop->{_stash} //= {};
Condition0%0/2
$prop->{"_stash"} //= {}
l!l
00
MC/DC0%0/1
$prop->{"_stash"} //= {}
$prop->{"_stash"}
Truth table0%0/2
A
A= $prop->{"_stash"}
Aresult
11
00
800 0 ▶ unless (@_) {
Branch: 4 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
if (do { @_ > 1 }) { } 0 0 0
elsif (not defined $_[0]) { } 0 0 0
elsif (ref $_[0]) { } 0 0 0
801 0 $stash
802 } elsif (@_ > 1) {
803 0 %$stash = @_;
804 } elsif (not defined $_[0]) {
805 0 carp "Undefined argument for :stash()";
806 } elsif (ref $_[0]) {
807 0 $prop->{_stash} = $_[0]
808 } else {
809 0 $stash->{$_[0]};
810 }
811 };
812  
813 # drop "[]" from "qname[]" and returns "qname"
814 0 ▶sub YATT::Lite::EntNS::entity_trim_array_suffix {
Subroutine entity_trim_array_suffix: not called CC=1 SCAR=6.9
Pod undocumented
815 0 my ($this, $name) = @_;
816 0 $name =~ s/\[\]\z//;
817 0 $name;
818 }
819  
820 2 ▶sub YATT::Lite::EntNS::entity_mkhidden {
Subroutine entity_mkhidden: called CC=5 SCAR=17.8
Pod undocumented
821 2 my ($this) = shift;
822 2 my $no_nested_query = $CON->prop->{no_nested_query};
823 \ join "\n", map {
824 2 my $name = $_;
825 2 ▶ $name =~ s/\[\]\z// if not $no_nested_query;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_nested_query 2 0 2
826 map {
827 2 my $v = $_;
828 2 ▶ if (ref $v eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $v eq 'HASH') { } 0 2 2
elsif (ref $v eq 'ARRAY') { } 2 0 2
829 map {
830 0 _hidden_input(escape($name."[$_]"), $v->{$_});
831 } keys %$v;
832 } elsif (ref $v eq 'ARRAY') {
833 map {
834 2 _hidden_input(escape($name."[]"), $_);
835 } @$v;
836 } else {
837 0 _hidden_input(escape($name), $v);
838 }
839 } $CON->multi_param($name);
840 2 } do {
841 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2 0 2
842 2 @_;
843 } else {
844 0 $CON->param
845 }
846 };
847 };
848  
849 4 ▶sub _hidden_input {
Subroutine _hidden_input: called CC=1 SCAR=0.0
850 4 sprintf(qq|<input type="hidden" name="%s" value="%s">|
851 , $_[0], escape($_[1]));
852 }
853  
854 0 ▶sub YATT::Lite::EntNS::entity_file_rootname {
Subroutine entity_file_rootname: not called CC=2 SCAR=17.9
Pod undocumented
855 0 my ($this, $fn) = @_;
856 0 ▶ $fn //= $CON->file();
Condition0%0/3
$fn //= $YATT::Lite::CON->file
l!l&&r!l&&!r
000
MC/DC0%0/2
$fn //= $YATT::Lite::CON->file
$fn $YATT::Lite::CON->file
Truth table0%0/3
A //= B
A= $fnB= $YATT::Lite::CON->file
ABresult
1X1
011
000
857 0 $fn =~ s/\.\w+$//;
858 0 $fn;
859 };
860  
861 0 ▶sub YATT::Lite::EntNS::entity_app_name {
Subroutine entity_app_name: not called CC=1 SCAR=6.9
Pod undocumented
862 0 my ($this) = @_;
863 0 $YATT->cget('app_name');
864 };
865  
866 #----------------------------------------
867 80 ▶use YATT::Lite::Breakpoint ();
Subroutine BEGIN: called CC=1 SCAR=0.0
868 80 YATT::Lite::Breakpoint::break_load_facade();
869  
870 80 1;
« blib/lib/YATT/Lite/WebMVC0/SubRoutes.pm ↑ Summary blib/lib/YATT/Lite/Partial/Gettext.pm »