CGI/Application/Plus/Util.pm

filter: Statementstmt 10.0% 4 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 25.0% 1 / 4 Podpod 0.0% 0 / 3 totaltotal 7.8% 5 / 64 CC 11 SCAR 35.0
CC
11
Cov
7%
load_tmpl
56.0
dump
12.0
dump_html
12.0
CRAP 33.2
↑ Summary CGI/Application/Plus.pm »
1 8 ▶use strict ;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 # This file uses the "Perlish" coding style
4 # please read http://perl.4pro.net/perlish_coding_style.html
5  
6 ; package CGI::Application::Plus::Util
7  
8 # same as the original, here just for compatibility
9 ; sub load_tmpl
10 0 ▶ { my $s = shift
Subroutine load_tmpl: not called CC=7 SCAR=40.3
Pod undocumented
11 0 ; my ($tmpl_file, @extra_params) = @_
12 # add tmpl_path to path array of one is set, otherwise add a path arg
13 0 ▶ ; if (my $tmpl_path = $s->tmpl_path)
Branch: 1 branch
BranchTrueFalseTotal
if (my $tmpl_path = $s->tmpl_path) 0 0 0
14 0 { my $found = 0
15 0 ▶ ; for( my $x = 0
Branch: 1 branch
BranchTrueFalseTotal
if ($x < @extra_params) 0 0 0
16 ; $x < @extra_params
17 ; $x += 2
18 )
19 0 ▶ { if ( $extra_params[$x] eq 'path'
Branch: 1 branch
BranchTrueFalseTotal
if ($extra_params[$x] eq "path" and ref $extra_params[$x + 1] and ref $extra_params[$x + 1] eq "ARRAY") 0 0 0
Condition0%0/6
$extra_params[$x] eq "path" and ref $extra_params[$x + 1] and ref $extra_params[$x + 1] eq "ARRAY"
!ll&&!rl&&r
000
$extra_params[$x] eq "path" and ref $extra_params[$x + 1]
!ll&&!rl&&r
000
MC/DC0%0/3
$extra_params[$x] eq "path" and ref $extra_params[$x + 1] and ref $extra_params[$x + 1] eq "ARRAY"
$extra_params[$x] eq "path" ref $extra_params[$x + 1] ref $extra_params[$x + 1] eq "ARRAY"
Truth table0%0/4
A and B and C
A= $extra_params[$x] eq "path"B= ref $extra_params[$x + 1]C= ref $extra_params[$x + 1] eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
20 and ref $extra_params[$x+1]
21 and ref $extra_params[$x+1] eq 'ARRAY'
22 )
23 0 { unshift @{$extra_params[$x+1]}, $tmpl_path
24 0 ; $found = 1
25 ; last
26 0 }
27 }
28 0 ▶ ; push ( @extra_params
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
29 , path => [ $tmpl_path ]
30 )
31 unless $found
32 }
33 ; require HTML::Template
34 0 ; my $t = HTML::Template->new_file( $tmpl_file
35 , @extra_params
36 )
37 0 ; return $t
38 }
39  
40  
41 # statements from now on are needed just when testing
42 # and they are never used in real job
43  
44 ; sub dump
45 0 ▶ { my $s = shift
Subroutine dump: not called CC=3 SCAR=24.8
Pod undocumented
46 0 ; $s->page .= qq(Run-mode: "${\$s->runmode}"\n)
47 0 ; $s->page .= "\nQuery Parameters:\n"
48 0 ; foreach my $p ( sort $s->query->param() )
49 0 { my $data_str = "'"
50 . join "', '" , $s->query->param($p)
51 ."'"
52 0 ; $s->page .= "\t$p => $data_str\n"
53 }
54 0 ; $s->page .= "\nQuery Environment:\n"
55 0 ; foreach my $k ( sort keys %ENV )
56 0 { $s->page .= "\t$k => '".$ENV{$k}."'\n"
57 }
58 }
59  
60 ; sub dump_html
61 0 ▶ { my $s = shift
Subroutine dump_html: not called CC=3 SCAR=24.8
Pod undocumented
62 0 ; $s->page .= qq(<P><B>Run-mode:</B> ${\$s->runmode}</P>\n)
63 0 ; $s->page .= "<P><B>\nQuery Parameters:<B><BR>\n<OL>\n"
64 0 ; foreach my $p ( sort $s->query->param() )
65 0 { my $data_str = "'"
66 . join "', '" , $s->query->param($p)
67 ."'"
68 0 ; $s->page .= "<LI> $p => $data_str\n"
69 }
70 0 ; $s->page .= "</OL>\n</P>\n";
71 0 ; $s->page .= "<P><B>\nQuery Environment:</B><BR>\n<OL>\n"
72 0 ; foreach my $ek ( sort keys %ENV )
73 0 { $s->page .= "<LI> <B>$ek</B> => ".$ENV{$ek}."\n"
74 }
75 0 ; $s->page .= "</OL>\n</P>\n";
76 }
77  
78  
79  
80 8 ; 1
81  
82 __END__
↑ Summary CGI/Application/Plus.pm »