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 6     6   37399 use 5.008;
  6         20  
3 6     6   33 use strict;
  6         11  
  6         130  
4 6     6   31 use warnings;
  6         11  
  6         177  
5              
6 6     6   32 use Data::Dumper;
  6         8  
  6         272  
7 6     6   31 use Exporter;
  6         9  
  6         1376  
8 6     6   10011 use HTML::Template;
  6         98881  
  6         3118  
9              
10             our $VERSION = '0.21';
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 8113 my %p = @_;
20              
21 9         24 my $file = $p{file};
22 9         20 my $want = $p{want};
23 9         16 my $data = $p{data};
24              
25 9 100 100     78 if ($want && $want eq 'stack') {
    100 66        
26              
27 3         32 my $template = HTML::Template->new(arrayref => \@stack_tpl);
28              
29 3         4970 $template->param(STACK => $data);
30              
31 3 100       107 if ($file) {
32 2 50       230 open my $wfh, '>', $file
33             or die "Can't open the output file, $file: $!";
34              
35 2         14 print $wfh $template->output;
36 2 50       1494 close $wfh or die $!;
37             }
38             else {
39 1         4 print $template->output;
40             }
41             }
42             elsif ($want && $want eq 'flow') {
43              
44 3         24 my $template = HTML::Template->new(arrayref => \@flow_tpl);
45              
46 3         2803 $template->param(FLOW => $data);
47              
48 3 100       95 if ($file) {
49 2 50       149 open my $wfh, '>', $file
50             or die "Can't open the output file, $file: $!";
51              
52 2         10 print $wfh $template->output;
53 2 50       1090 close $wfh or die $!;
54             }
55             else {
56 1         4 print $template->output;
57             }
58             }
59             else {
60 3         24 my $template = HTML::Template->new(arrayref => \@all_tpl);
61              
62             $template->param(
63             FLOW => $data->{flow},
64             STACK => $data->{stack},
65 3         6198 );
66 3 100       142 if ($file) {
67 2 50       146 open my $wfh, '>', $file
68             or die "Can't open the output file, $file: $!";
69              
70 2         11 print $wfh $template->output;
71 2 50       3503 close $wfh or die $!;
72             }
73             else {
74 1         5 print $template->output;
75             }
76             }
77             }
78              
79             BEGIN {
80              
81 6     6   21 @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 6         17 @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 6         136 @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__