Subs/HTML.pm

filter: Statementstmt 100% 50 / 50 Branchbran 72.7% 16 / 22 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 91.2% 83 / 91 CC 14 SCAR 23.0
CC
14
Cov
91%
html
14.4
BEGIN
1.0
BEGIN
1.0
CRAP 10.0
↑ Summary Subs/Text.pm »
1 package Devel::Trace::Subs::HTML;
2 4 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use HTML::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '0.24';
11  
12 4 our @ISA = qw(Exporter);
13 4 our @EXPORT_OK = qw(html);
14  
15 4 my (@stack_tpl, @flow_tpl, @all_tpl);
16  
17 9 ▶sub html {
Subroutine html: called CC=14 SCAR=26.7
Pod documented
18  
19 9 my %p = @_;
20  
21 9 my $file = $p{file};
22 9 my $want = $p{want};
23 9 my $data = $p{data};
24  
25 9 ▶ if ($want && $want eq 'stack') {
Branch: 2 branches
BranchTrueFalseTotal
if ($want and $want eq 'stack') { } 3 6 9
elsif ($want and $want eq 'flow') { } 3 3 6
Condition100%3/3
$want and $want eq "stack"
!ll&&!rl&&r
333
MC/DC100%2/2
$want and $want eq "stack"
$want $want eq "stack"
Truth table100%3/3
A and B
A= $wantB= $want eq "stack"
ABresult
0X0
100
111
26  
27 3 my $template = HTML::Template->new(arrayref => \@stack_tpl);
28  
29 3 $template->param(STACK => $data);
30  
31 3 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 2 1 3
32 2 ▶ open my $wfh, '>', $file
Branch: 1 branch
BranchTrueFalseTotal
open my $wfh, ">", $file or die "Can't open the output file, ${file}: $!" 2 0 2
33 or die "Can't open the output file, $file: $!";
34  
35 2 print $wfh $template->output;
36 2 ▶ close $wfh or die $!;
Branch: 1 branch
BranchTrueFalseTotal
close $wfh or die $! 2 0 2
37 }
38 else {
39 1 print $template->output;
40 }
41 }
42 ▶ elsif ($want && $want eq 'flow') {
Condition66%2/3
$want and $want eq "flow"
!ll&&!rl&&r
303
MC/DC50%1/2
$want and $want eq "flow"
$want $want eq "flow"
Truth table66%2/3
A and B
A= $wantB= $want eq "flow"
ABresult
0X0
100
111
43  
44 3 my $template = HTML::Template->new(arrayref => \@flow_tpl);
45  
46 3 $template->param(FLOW => $data);
47  
48 3 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 2 1 3
49 2 ▶ open my $wfh, '>', $file
Branch: 1 branch
BranchTrueFalseTotal
open my $wfh, ">", $file or die "Can't open the output file, ${file}: $!" 2 0 2
50 or die "Can't open the output file, $file: $!";
51  
52 2 print $wfh $template->output;
53 2 ▶ close $wfh or die $!;
Branch: 1 branch
BranchTrueFalseTotal
close $wfh or die $! 2 0 2
54 }
55 else {
56 1 print $template->output;
57 }
58 }
59 else {
60 3 my $template = HTML::Template->new(arrayref => \@all_tpl);
61  
62 $template->param(
63 FLOW => $data->{flow},
64 STACK => $data->{stack},
65 3 );
66 3 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 2 1 3
67 2 ▶ open my $wfh, '>', $file
Branch: 1 branch
BranchTrueFalseTotal
open my $wfh, ">", $file or die "Can't open the output file, ${file}: $!" 2 0 2
68 or die "Can't open the output file, $file: $!";
69  
70 2 print $wfh $template->output;
71 2 ▶ close $wfh or die $!;
Branch: 1 branch
BranchTrueFalseTotal
close $wfh or die $! 2 0 2
72 }
73 else {
74 1 print $template->output;
75 }
76 }
77 }
78  
79 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
80  
81 4 @stack_tpl = <<EOF;
82 <html>
83 <head>
84 <title>Devel::Trace::Subs</title>
85 </head>
86  
87 <body>
88  
89 <br><br>
90  
91 <h3>Stack trace:</h3>
92  
93 <table id=error border=0 cellspacing=0>
94 <TMPL_LOOP NAME=STACK>
95 <tr><td>in:</td> <td>&nbsp;</td>
96 <td><TMPL_VAR NAME=in></td></tr>
97 <tr><td>sub:</td> <td>&nbsp;</td>
98 <td><TMPL_VAR NAME=sub></td></tr>
99 <tr><td>file:</td> <td>&nbsp;</td>
100 <td><TMPL_VAR NAME=filename></td></tr>
101 <tr><td>line:</td> <td>&nbsp;</td>
102 <td><TMPL_VAR NAME=line></td></tr>
103 <tr><td>package:</td> <td>&nbsp;</td>
104 <td><TMPL_VAR NAME=package></td></tr>
105 <tr><td colspan=3>&nbsp;</td></tr>
106 </TMPL_LOOP>
107  
108 </table>
109 </body>
110 </html>
111 EOF
112  
113 4 @flow_tpl = <<EOF;
114 <html>
115 <head>
116 <title>Devel::Trace::Subs</title>
117 </head>
118  
119 <body>
120  
121 <br><br>
122  
123 <h3>Code Subs:</h3>
124  
125 <table id=error border=0 cellspacing=0>
126 <TMPL_LOOP NAME=FLOW>
127 <tr><td><TMPL_VAR NAME=name></td> <td>&nbsp;</td>
128 <td><TMPL_VAR NAME=value></td></tr>
129 </TMPL_LOOP>
130  
131 </table>
132 </body>
133 </html>
134 EOF
135  
136 4 @all_tpl = <<EOF;
137 <html>
138 <head>
139 <title>Devel::Trace::Subs</title>
140 </head>
141  
142 <body>
143  
144 <br>
145  
146 <h3>Code Subs:</h3>
147  
148 <table id=error border=0 cellspacing=0>
149 <TMPL_LOOP NAME=FLOW>
150 <tr><td><TMPL_VAR NAME=name>:</td>
151 <td>&nbsp;</td> <td><TMPL_VAR NAME=value></td></tr>
152 </TMPL_LOOP>
153  
154 </table>
155  
156 <br>
157  
158 <h3>Stack trace:</h3>
159  
160 <table id=error border=0 cellspacing=0>
161 <TMPL_LOOP NAME=STACK>
162 <tr><td>in:</td> <td>&nbsp;</td>
163 <td><TMPL_VAR NAME=in></td></tr>
164 <tr><td>sub:</td> <td>&nbsp;</td>
165 <td><TMPL_VAR NAME=sub></td></tr>
166 <tr><td>file:</td> <td>&nbsp;</td>
167 <td><TMPL_VAR NAME=filename></td></tr>
168 <tr><td>line:</td> <td>&nbsp;</td>
169 <td><TMPL_VAR NAME=line></td></tr>
170 <tr><td>package:</td> <td>&nbsp;</td>
171 <td><TMPL_VAR NAME=package></td></tr>
172 <tr><td colspan=3>&nbsp;</td></tr>
173 </TMPL_LOOP>
174  
175 </table>
176  
177 </body>
178  
179 </html>
180 EOF
181 }
182  
183 __END__
↑ Summary Subs/Text.pm »