File Coverage

blib/lib/Devel/Trace/Subs/HTML.pm
Criterion Covered Total %
statement 46 46 100.0
branch 16 22 72.7
condition 5 6 83.3
subroutine 8 8 100.0
pod 1 1 100.0
total 76 83 91.5


line stmt bran cond sub pod time code
1             package Devel::Trace::Subs::HTML;
2 4     4   66658 use 5.008;
  4         26  
3 4     4   18 use strict;
  4         6  
  4         79  
4 4     4   23 use warnings;
  4         6  
  4         85  
5              
6 4     4   16 use Data::Dumper;
  4         8  
  4         151  
7 4     4   18 use Exporter;
  4         6  
  4         112  
8 4     4   3639 use HTML::Template;
  4         47254  
  4         1470  
9              
10             our $VERSION = '0.23';
11              
12             our @ISA = qw(Exporter);
13             our @EXPORT_OK = qw(html);
14              
15             my (@stack_tpl, @flow_tpl, @all_tpl);
16              
17             sub html {
18              
19 9     9 1 7710 my %p = @_;
20              
21 9         19 my $file = $p{file};
22 9         13 my $want = $p{want};
23 9         18 my $data = $p{data};
24              
25 9 100 100     45 if ($want && $want eq 'stack') {
    100 66        
26              
27 3         22 my $template = HTML::Template->new(arrayref => \@stack_tpl);
28              
29 3         4750 $template->param(STACK => $data);
30              
31 3 100       113 if ($file) {
32 2 50       202 open my $wfh, '>', $file
33             or die "Can't open the output file, $file: $!";
34              
35 2         19 print $wfh $template->output;
36 2 50       1457 close $wfh or die $!;
37             }
38             else {
39 1         4 print $template->output;
40             }
41             }
42             elsif ($want && $want eq 'flow') {
43              
44 3         28 my $template = HTML::Template->new(arrayref => \@flow_tpl);
45              
46 3         2444 $template->param(FLOW => $data);
47              
48 3 100       89 if ($file) {
49 2 50       135 open my $wfh, '>', $file
50             or die "Can't open the output file, $file: $!";
51              
52 2         14 print $wfh $template->output;
53 2 50       1043 close $wfh or die $!;
54             }
55             else {
56 1         4 print $template->output;
57             }
58             }
59             else {
60 3         18 my $template = HTML::Template->new(arrayref => \@all_tpl);
61              
62             $template->param(
63             FLOW => $data->{flow},
64             STACK => $data->{stack},
65 3         5672 );
66 3 100       120 if ($file) {
67 2 50       119 open my $wfh, '>', $file
68             or die "Can't open the output file, $file: $!";
69              
70 2         21 print $wfh $template->output;
71 2 50       3047 close $wfh or die $!;
72             }
73             else {
74 1         3 print $template->output;
75             }
76             }
77             }
78              
79             BEGIN {
80              
81 4     4   18 @stack_tpl = <
82            
83            
84             Devel::Trace::Subs
85            
86              
87            
88              
89            

90              
91            

Stack trace:

92              
93            
94            
95            
in:  
96            
97            
sub:  
98            
99            
file:  
100            
101            
line:  
102            
103            
package:  
104            
105            
 
106            
107              
108            
109            
110            
111             EOF
112              
113 4         8 @flow_tpl = <
114            
115            
116             Devel::Trace::Subs
117            
118              
119            
120              
121            

122              
123            

Code Subs:

124              
125            
126            
127            
 
128            
129            
130              
131            
132            
133            
134             EOF
135              
136 4         100 @all_tpl = <
137            
138            
139             Devel::Trace::Subs
140            
141              
142            
143              
144            
145              
146            

Code Subs:

147              
148            
149            
150            
:
151              
152            
153              
154            
155              
156            
157              
158            

Stack trace:

159              
160            
161            
162            
in:  
163            
164            
sub:  
165            
166            
file:  
167            
168            
line:  
169            
170            
package:  
171            
172            
 
173            
174              
175            
176              
177            
178              
179            
180             EOF
181             }
182              
183             __END__