blib/lib/Template/Nest.pm

filter: Statementstmt 97.0% 197 / 203 Branchbran 77.6% 87 / 112 Conditioncond 72.7% 24 / 33 MC/DCmcdc 35.0% 7 / 20 Subroutinesub 100% 25 / 25 Podpod 86.6% 13 / 15 totaltotal 86.5% 353 / 408 CC 82 SCAR 24.4
CC
82
Cov
89%
_fill_in
33.4
_render_hash
6.0
_render_array
5.6
CRAP 11.5
↑ Summary
1 package Template::Nest;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 our $VERSION = '0.10';
10  
11 sub new{
12 8 ▶ my ($class,%opts) = @_;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
13  
14  
15 # defaults:
16 8 my $self = {
17 comment_delims => [ '<!--','-->' ],
18 token_delims => [ '<%','%>' ],
19 name_label => 'NAME',
20 template_dir => '',
21 template_ext => '.html',
22 show_labels => 0,
23 defaults => {},
24 defaults_namespace_char => '.',
25 fixed_indent => 0,
26 die_on_bad_params => 1,
27 escape_char => "\\"
28 };
29  
30 8 bless $self,$class;
31  
32 8 ▶ if ( %opts ){
Branch: 1 branch
BranchTrueFalseTotal
if (%opts) 7 1 8
33 7 for my $k (keys %opts){
34 39 ▶ confess "$k is not a valid option" unless defined $self->can($k);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->can($k) 0 39 39
35 39 $self->$k( $opts{$k} );
36 }
37 }
38  
39 8 return $self;
40 }
41  
42  
43 sub template_dir{
44 87 ▶ my($self,$dir) = @_;
Subroutine template_dir: called CC=4 SCAR=14.1
Pod documented
45 87 ▶ confess "Expected a scalar directory name but got a ".ref($dir) if $dir && ref($dir);
Branch: 1 branch
BranchTrueFalseTotal
if $dir and ref $dir 0 87 87
Condition66%2/3
$dir and ref $dir
!ll&&!rl&&r
7980
MC/DC0%0/2
$dir and ref $dir
$dir ref $dir
Truth table66%2/3
A and B
A= $dirB= ref $dir
ABresult
0X0
100
111
46 87 ▶ $self->{template_dir} = $dir if $dir;
Branch: 1 branch
BranchTrueFalseTotal
if $dir 8 79 87
47 87 return $self->{template_dir};
48 }
49  
50  
51 sub template_hash{
52 4 ▶ my ($self,$template_hash) = @_;
Subroutine template_hash: called CC=2 SCAR=6.9
Pod undocumented
53  
54 4 ▶ $self->{template_hash} = $template_hash if $template_hash;
Branch: 1 branch
BranchTrueFalseTotal
if $template_hash 2 2 4
55 4 return $self->{template_hash};
56 }
57  
58  
59 sub defaults{
60 7 ▶ my ($self,$defaults) = @_;
Subroutine defaults: called CC=3 SCAR=11.0
Pod documented
61  
62 7 ▶ if ( $defaults ){
Branch: 1 branch
BranchTrueFalseTotal
if ($defaults) 5 2 7
63  
64 5 ▶ confess "defaults should be a hashref" unless ref $defaults eq ref {};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $defaults eq ref {} 0 5 5
65 5 $self->{defaults} = $defaults;
66  
67 }
68  
69 7 return $self->{defaults};
70 }
71  
72  
73 sub defaults_namespace_char{
74 12 ▶ my ($self,$char) = @_;
Subroutine defaults_namespace_char: called CC=4 SCAR=13.9
Pod documented
75  
76 12 ▶ if ( defined $char ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $char) 10 2 12
77 10 ▶ if ( $char eq '' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq '') { } 7 3 10
78 7 $self->{defaults_namespace_char} = '';
79 } else {
80 3 ▶ confess "defaults_namespace_char should be a single character or ''" unless $char =~ /./;
Branch: 1 branch
BranchTrueFalseTotal
unless $char =~ /./ 0 3 3
81 3 $self->{defaults_namespace_char} = $char;
82 }
83 }
84  
85 12 return $self->{defaults_namespace_char};
86 }
87
88  
89 sub comment_delims{
90 3 ▶ my ($self,$delim1,$delim2) = @_;
Subroutine comment_delims: called CC=3 SCAR=11.0
Pod documented
91 3 ▶ if (defined $delim1 ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $delim1) 2 1 3
92 2 ▶ $delim2 = $delim2 || '';
Condition50%1/2
$delim2 || ''
l!l
20
MC/DC0%0/1
$delim2 || ''
$delim2
Truth table50%1/2
A
A= $delim2
Aresult
11
00
93 2 $self->{'comment_delims'} = [ $delim1, $delim2 ];
94 }
95 3 return $self->{'comment_delims'};
96 }
97  
98  
99 sub token_delims{
100 9 ▶ my ($self,$delim1,$delim2) = @_;
Subroutine token_delims: called CC=4 SCAR=13.9
Pod documented
101
102 9 ▶ if (defined $delim1 ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $delim1) 8 1 9
103  
104 8 ▶ if ( ref $delim1 eq ref [] ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $delim1 eq ref []) 7 1 8
105 7 ($delim1,$delim2) = @$delim1;
106 }
107  
108 8 ▶ $delim2 ||= '';
Condition50%1/2
$delim2 ||= ""
l!l
80
MC/DC0%0/1
$delim2 ||= ""
$delim2
Truth table50%1/2
A
A= $delim2
Aresult
11
00
109 8 $self->{'token_delims'} = [ $delim1, $delim2 ];
110 }
111 9 return $self->{'token_delims'};
112 }
113  
114  
115  
116 sub show_labels{
117 78 ▶ my ($self,$show) = @_;
Subroutine show_labels: called CC=5 SCAR=16.1
Pod documented
118 78 ▶ confess "Expected a boolean but got $show" if $show && ! ( $show == 0 || $show == 1 );
Branch: 1 branch
BranchTrueFalseTotal
if $show and not $show == 0 || $show == 1 1 77 78
Condition83%5/6
$show and not $show == 0 || $show == 1
!ll&&!rl&&r
7521
$show == 0 || $show == 1
l!l&&r!l&&!r
021
MC/DC66%2/3
$show and not $show == 0 || $show == 1
$show $show == 0 $show == 1
Truth table75%3/4
A and not(B || C)
A= $showB= $show == 0C= $show == 1
ABCresult
0XX0
11X0
1010
1001
119 77 ▶ $self->{show_labels} = $show if defined $show;
Branch: 1 branch
BranchTrueFalseTotal
if defined $show 3 74 77
120 77 return $self->{show_labels};
121 }
122  
123  
124 sub template_ext{
125 87 ▶ my ($self,$ext) = @_;
Subroutine template_ext: called CC=4 SCAR=14.1
Pod documented
126 87 ▶ confess "Expected a scalar extension name but got a ".ref($ext) if defined $ext && ref($ext);
Branch: 1 branch
BranchTrueFalseTotal
if defined $ext and ref $ext 0 87 87
Condition66%2/3
defined $ext and ref $ext
!ll&&!rl&&r
7980
MC/DC0%0/2
defined $ext and ref $ext
defined $ext ref $ext
Truth table66%2/3
A and B
A= defined $extB= ref $ext
ABresult
0X0
100
111
127 87 ▶ $self->{template_ext} = $ext if defined $ext;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ext 8 79 87
128 87 return $self->{template_ext};
129 }
130
131  
132 sub name_label{
133 246 ▶ my ($self,$label) = @_;
Subroutine name_label: called CC=4 SCAR=14.1
Pod documented
134 246 ▶ confess "Expected a scalar name label but got a ".ref($label) if defined $label && ref($label);
Branch: 1 branch
BranchTrueFalseTotal
if defined $label and ref $label 0 246 246
Condition66%2/3
defined $label and ref $label
!ll&&!rl&&r
23880
MC/DC0%0/2
defined $label and ref $label
defined $label ref $label
Truth table66%2/3
A and B
A= defined $labelB= ref $label
ABresult
0X0
100
111
135 246 ▶ $self->{name_label} = $label if $label;
Branch: 1 branch
BranchTrueFalseTotal
if $label 8 238 246
136 246 return $self->{name_label};
137 }
138  
139  
140 sub fixed_indent{
141 9 ▶ my ($self,$indent) = @_;
Subroutine fixed_indent: called CC=4 SCAR=13.9
Pod documented
142  
143 9 ▶ if ( defined $indent ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $indent) 7 2 9
144 7 ▶ confess "Expected 0 or 1 but got $indent" unless $indent == 0 or $indent == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $indent == 0 or $indent == 1 1 6 7
Condition100%3/3
$indent == 0 or $indent == 1
l!l&&r!l&&!r
331
MC/DC100%2/2
$indent == 0 or $indent == 1
$indent == 0 $indent == 1
Truth table100%3/3
A or B
A= $indent == 0B= $indent == 1
ABresult
1X1
011
000
145 6 $self->{fixed_indent} = $indent;
146 }
147  
148 8 return $self->{fixed_indent};
149 }
150  
151  
152 sub die_on_bad_params{
153 8 ▶ my ($self,$should_die) = @_;
Subroutine die_on_bad_params: called CC=4 SCAR=13.9
Pod documented
154  
155 8 ▶ if ( defined $should_die ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $should_die) 6 2 8
156 6 ▶ confess "Expected 0 or 1 but got $should_die" unless $should_die == 0 or $should_die == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $should_die == 0 or $should_die == 1 1 5 6
Condition100%3/3
$should_die == 0 or $should_die == 1
l!l&&r!l&&!r
231
MC/DC100%2/2
$should_die == 0 or $should_die == 1
$should_die == 0 $should_die == 1
Truth table100%3/3
A or B
A= $should_die == 0B= $should_die == 1
ABresult
1X1
011
000
157 5 $self->{die_on_bad_params} = $should_die;
158 }
159  
160 7 return $self->{die_on_bad_params};
161 }
162  
163  
164  
165 sub escape_char{
166 7 ▶ my ($self,$char) = @_;
Subroutine escape_char: called CC=4 SCAR=14.0
Pod documented
167  
168 7 ▶ if (defined $char){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $char) 5 2 7
169 5 ▶ confess "escape_char should be a single character or ''" unless $char eq '' or $char =~ /./;
Branch: 1 branch
BranchTrueFalseTotal
unless $char eq "" or $char =~ /./ 0 5 5
Condition66%2/3
$char eq "" or $char =~ /./
l!l&&r!l&&!r
140
MC/DC0%0/2
$char eq "" or $char =~ /./
$char eq "" $char =~ /./
Truth table66%2/3
A or B
A= $char eq ""B= $char =~ /./
ABresult
1X1
011
000
170 5 $self->{escape_char} = $char;
171 }
172  
173 7 return $self->{escape_char};
174 }
175  
176  
177  
178 sub render{
179 134 ▶ my ($self,$comp) = @_;
Subroutine render: called CC=3 SCAR=11.0
Pod documented
180  
181 134 my $html;
182 134 ▶ if ( ref($comp) =~ /array/i ){
Branch: 2 branches
BranchTrueFalseTotal
if (ref($comp) =~ /array/i) { } 14 120 134
elsif (ref($comp) =~ /hash/i) { } 77 43 120
183 14 $html = $self->_render_array( $comp );
184 } elsif( ref( $comp ) =~ /hash/i ){
185 77 $html = $self->_render_hash( $comp );
186 } else {
187 43 $html = $comp;
188 }
189  
190 128 return $html;
191 }
192  
193  
194  
195 sub _render_hash{
196 77 ▶ my ($self,$h) = @_;
Subroutine _render_hash: called CC=6 SCAR=18.0
197  
198 77 ▶ confess "Expected a hashref. Instead got a ".ref($h) unless ref($h) =~ /hash/i;
Branch: 1 branch
BranchTrueFalseTotal
unless ref($h) =~ /hash/i 0 77 77
199  
200 77 my $template_name = $h->{ $self->name_label };
201  
202 77 ▶ confess 'Encountered hash with no name_label ("'.$self->name_label.'"): '.Dumper( $h ) unless $template_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $template_name 0 77 77
203  
204 77 my $param = {};
205  
206 77 foreach my $k ( keys %$h ){
207 160 ▶ next if $k eq $self->name_label;
Branch: 1 branch
BranchTrueFalseTotal
if $k eq $self->name_label 77 83 160
208 83 $param->{$k} = $self->render( $h->{$k} );
209 }
210  
211 75 my $template = $self->_get_template( $template_name );
212 75 my $html = $self->_fill_in( $template_name, $template, $param );
213  
214 72 ▶ if ( $self->show_labels ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->show_labels) 8 64 72
215  
216 8 my $ca = $self->{comment_delims}->[0];
217 8 my $cb = $self->{comment_delims}->[1];
218  
219 8 $html = "$ca BEGIN $template_name $cb\n$html\n$ca END $template_name $cb\n";
220 }
221  
222 72 return $html;
223  
224 }
225  
226  
227  
228  
229 sub _render_array{
230  
231 14 ▶ my ($self, $arr, $delim) = @_;
Subroutine _render_array: called CC=5 SCAR=17.2
232 14 ▶ confess "Expected an array. Instead got a ".ref($arr) unless ref($arr) =~ /array/i;
Branch: 1 branch
BranchTrueFalseTotal
unless ref($arr) =~ /array/i 0 14 14
233 14 my $html = '';
234 14 foreach my $comp (@$arr){
235 27 ▶ $html.= $delim if ($delim && $html);
Branch: 1 branch
BranchTrueFalseTotal
if $delim and $html 0 27 27
Condition33%1/3
$delim and $html
!ll&&!rl&&r
2700
MC/DC0%0/2
$delim and $html
$delim $html
Truth table33%1/3
A and B
A= $delimB= $html
ABresult
0X0
100
111
236 27 $html.= $self->render( $comp );
237 }
238 13 return $html;
239  
240 }
241  
242  
243  
244 sub _get_template{
245 81 ▶ my ($self,$template_name) = @_;
Subroutine _get_template: called CC=4 SCAR=13.9
246  
247 81 my $template = '';
248 81 ▶ if ( $self->{template_hash} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'template_hash'}) { } 3 78 81
249 3 $template = $self->{template_hash}{$template_name};
250 } else {
251  
252 78 my $filename = File::Spec->catdir(
253 $self->template_dir,
254 $template_name.$self->template_ext
255 );
256  
257 78 my $fh;
258 78 ▶ open $fh,'<',$filename or confess "Could not open file $filename: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "<", $filename or confess("Could not open file ${filename}: $!") 0 78 78
259  
260 78 my $text = '';
261 78 ▶ while( my $line = <$fh> ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 335 78 413
262 335 $template.=$line;
263 }
264  
265 }
266  
267 81 $template =~ s/\n$//;
268 81 return $template;
269 }
270  
271  
272  
273  
274 sub params{
275 6 ▶ my ($self,$template_name) = @_;
Subroutine params: called CC=3 SCAR=11.0
Pod undocumented
276  
277 6 my $esc = $self->{escape_char};
278 6 my $template = $self->_get_template( $template_name );
279 6 my @frags = split( /\Q$esc$esc\E/, $template );
280 6 my $tda = $self->{token_delims}[0];
281 6 my $tdb = $self->{token_delims}[1];
282  
283 6 my %rem;
284 6 for my $i (0..$#frags){
285 6 my @f = $frags[$i] =~ m/(?<!\Q$esc\E)\Q$tda\E(.*?)\Q$tdb\E/g;
286 6 for my $f ( @f ){
287 14 $f =~ s/^\s*//;
288 14 $f =~ s/\s*$//;
289 14 $rem{$f} = 1;
290 }
291 }
292
293 6 my @params = sort(keys %rem);
294 6 return \@params;
295 }
296  
297  
298  
299  
300 sub _fill_in{
301 75 ▶ my ($self,$template_name,$template,$param) = @_;
Subroutine _fill_in: called CC=27 SCAR=35.1
302 # this sub has grown a little unwieldy
303 # but doesn't break naturally
304 # TODO re-param and break up (if it gets any bigger?)
305  
306 75 my $esc = $self->{escape_char};
307 75 my @frags;
308  
309 75 ▶ if ( $esc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) { } 75 0 75
310 75 @frags = split( /\Q$esc$esc\E/, $template );
311 } else {
312 0 @frags = ( $template );
313 }
314  
315 75 my $tda = $self->{token_delims}[0];
316 75 my $tdb = $self->{token_delims}[1];
317  
318 # first, attempt to replace the parameters we were provided
319 75 foreach my $param_name (keys %$param){
320  
321 79 my $param_val = $param->{$param_name};
322
323 79 my $replaced = 0;
324  
325 79 ▶ if ( $self->{fixed_indent} ){ #if fixed_indent we need to add spaces during the replacement
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'fixed_indent'}) { } 10 69 79
326 10 for my $i (0..$#frags){
327 10 my @spaces_repl;
328 10 ▶ if ( $esc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) { } 10 0 10
329 10 @spaces_repl = $frags[$i] =~ m/([^\S\r\n]*)(?<!\Q$esc\E)(\Q$tda\E\s+$param_name\s+\Q$tdb\E)/g;
330 } else {
331 0 @spaces_repl = $frags[$i] =~ m/([^\S\r\n]*)(\Q$tda\E\s+$param_name\s+\Q$tdb\E)/g;
332 }
333
334 10 ▶ while(@spaces_repl){
Branch: 1 branch
BranchTrueFalseTotal
if (@spaces_repl) 10 10 20
335 10 my $sp = shift @spaces_repl;
336 10 my $repl = shift @spaces_repl;
337 10 my $param_out = $param_val;
338 10 $param_out =~ s/\n/\n$sp/g;
339  
340 10 ▶ if ( $esc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) { } 10 0 10
341 10 ▶ $replaced = 1 if $frags[$i] =~ s/(?<!\Q$esc\E)\Q$repl\E/$param_out/;
Branch: 1 branch
BranchTrueFalseTotal
if $frags[$i] =~ s/(?<!\Q$esc\E)\Q$repl\E/$param_out/ 10 0 10
342 } else {
343 0 ▶ $replaced = 1 if $frags[$i] =~ s/\Q$repl\E/$param_out/;
Branch: 1 branch
BranchTrueFalseTotal
if $frags[$i] =~ s/\Q$repl\E/$param_out/ 0 0 0
344 }
345 }
346 }
347 } else { #if no fixed_indent global search/replace is probably quicker
348 69 for my $i (0..$#frags){
349 77 ▶ if ( $esc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) { } 77 0 77
350 77 ▶ $replaced = 1 if $frags[$i] =~ s/(?<!\Q$esc\E)\Q$tda\E\s+$param_name\s+\Q$tdb\E/$param_val/g;
Branch: 1 branch
BranchTrueFalseTotal
if $frags[$i] =~ s/(?<!\Q$esc\E)\Q$tda\E\s+$param_name\s+\Q$tdb\E/$param_val/g 65 12 77
351 } else {
352 0 ▶ $replaced = 1 if $frags[$i] =~ s/\Q$tda\E\s+$param_name\s+\Q$tdb\E/$param_val/g;
Branch: 1 branch
BranchTrueFalseTotal
if $frags[$i] =~ s/\Q$tda\E\s+$param_name\s+\Q$tdb\E/$param_val/g 0 0 0
353 }
354 }
355 }
356  
357 79 ▶ if ( $self->{die_on_bad_params} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"die_on_bad_params"}) 75 4 79
358 75 ▶ confess "Could not replace template param '$param_name': token does not exist in template '$template_name'" unless $replaced;
Branch: 1 branch
BranchTrueFalseTotal
unless $replaced 3 72 75
359 }
360 }
361  
362 # now handle remaining, unreplaced tokens
363 72 ▶ if ( %{$self->{defaults}} ){
Branch: 1 branch
BranchTrueFalseTotal
if (%{$self->{'defaults'};}) { } 18 54 72
364 # defaults were provided, so we need to find out if any tokens match defaults
365 18 my $char = $self->{defaults_namespace_char};
366 18 for my $i (0..$#frags){
367  
368 18 my @rem = $frags[$i] =~ m/(?<!\Q$esc\E)\Q$tda\E\s+(.*?)\s+\Q$tdb\E/g;
369 18 my %rem;
370 18 for my $name ( @rem ){;
371 # $name =~ s/^\s*//;
372 # $name =~ s/\s*$//;
373 14 $rem{$name} = 1
374 }
375  
376 18 for my $name (keys %rem){
377 14 my @parts = ( $name );
378 14 ▶ @parts = split( /\Q$char\E/, $name ) if $char;
Branch: 1 branch
BranchTrueFalseTotal
if $char 11 3 14
379 14 my $val = $self->_get_default_val($self->{defaults},@parts);
380 14 $frags[$i] =~ s/(?<!\Q$esc\E)\Q$tda\E\s+$name\s+\Q$tdb\E/$val/g;
381 }
382
383 18 ▶ if ( $esc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) { } 18 0 18
384 18 $frags[$i] =~ s/(?<!\Q$esc\E)\Q$tda\E\s.*?\s\Q$tdb\E//g;
385 } else {
386 0 $frags[$i] =~ s/\Q$tda\E\s.*?\s\Q$tdb\E//g;
387 }
388 }
389  
390 } else {
391  
392 # we don't have any defaults, so quicker to directly remove any params that weren't specified
393 54 for my $i (0..$#frags){
394 58 ▶ if ( $esc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) { } 58 0 58
395 58 $frags[$i] =~ s/(?<!\Q$esc\E)\Q$tda\E\s.*?\s\Q$tdb\E//g;
396 } else {
397 0 $frags[$i] =~ s/\Q$tda\E\s.*?\s\Q$tdb\E//g;
398 }
399 }
400 }
401  
402  
403 72 ▶ if ( $esc ){
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) 72 0 72
404 72 for my $i (0..$#frags){
405 76 $frags[$i] =~ s/\Q$esc\E//gs;
406 }
407 }
408  
409  
410 72 ▶ my $text = $esc? join($esc,@frags): $frags[0];
Branch: 1 branch
BranchTrueFalseTotal
$esc ? : 72 0 72
411 72 return $text;
412 }
413  
414
415  
416 sub _get_default_val{
417 25 ▶ my ($self,$ref,@parts) = @_;
Subroutine _get_default_val: called CC=4 SCAR=13.9
418  
419 25 ▶ if ( @parts == 1 ){
Branch: 1 branch
BranchTrueFalseTotal
if (@parts == 1) { } 12 13 25
420 12 ▶ my $val = $ref->{$parts[0]} || '';
Condition100%2/2
$$ref{$parts[0]} || ''
l!l
111
MC/DC100%1/1
$$ref{$parts[0]} || ''
$$ref{$parts[0]}
Truth table100%2/2
A
A= $$ref{$parts[0]}
Aresult
11
00
421 12 return $val;
422 } else {
423 13 my $ref_name = shift @parts;
424 13 my $new_ref = $ref->{ $ref_name };
425 13 ▶ return '' unless $new_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $new_ref 2 11 13
426 11 return $self->_get_default_val( $new_ref, @parts );
427 }
428 }
429  
430  
431  
432 7 1;
433 __END__
↑ Summary