DebugScreen/TT.pm

filter: Statementstmt 100% 28 / 28 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 81.6% 40 / 49 CC 5 SCAR 11.7
CC
5
Cov
87%
as_html
5.5
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« DebugScreen/HTML/Template.pm ↑ Summary
1 package CGI::Carp::DebugScreen::TT;
2
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 2 our $VERSION = '0.15';
8
9 2 my $DebugTemplate =<<'EOT';
10 <html>
11 <head>
12 <title>Debug Screen</title>
13 [%- IF style %]
14 [%- style %]
15 [%- END %]
16 </head>
17 <body>
18 <a name="top"></a>
19 <div id="page">
20 <h1>[% error_at | html %]</h1>
21 [%- IF show_raw_error %]
22 <pre class="raw_error">[% raw_error %]</pre>
23 [%- ELSE %]
24 <div class="box">
25 [%- error_message %]
26 </div>
27 [%- END %]
28 [%- BLOCK navi %]
29 <div class="navi">
30 [<a href="#top">top</a>]
31 [<a href="#stacktraces">stacktraces</a>]
32 [%- IF watchlist.0 %]
33 [<a href="#watch">watchlist</a>]
34 [%- END %]
35 [%- IF modules.0 %]
36 [<a href="#modules">modules</a>]
37 [%- END %]
38 [%- IF environment.0 %]
39 [<a href="#environment">environment</a>]
40 [%- END %]
41 </div>
42 [%- END %]
43 [%- INCLUDE navi %]
44 <div class="box">
45 <h2><a name="stacktraces">Stacktraces</a></h2>
46 <ul id="stacktraces">
47 [%- FOREACH stacktrace = stacktraces %]
48 <li>[% stacktrace.caller | html %] LINE : [% stacktrace.line %]</li>
49 <table class="code">
50 [%- FOREACH context = stacktrace.context %]
51 [%- IF context.hit %]<tr class="hit">[% ELSE %]<tr>[% END %]
52 <td class="num">[% context.no | html %]:</td><td>[% context.line | html %]</td>
53 </tr>
54 [%- END %]
55 </table>
56 [%- END %]
57 </ul>
58 </div>
59 [%- IF watchlist.0 %]
60 [%- INCLUDE navi %]
61 <div class="box">
62 <h2><a name="watch">Watch List</a></h2>
63 <ul id="watch">
64 [%- FOREACH watch = watchlist %]
65 <li>
66 <b>[% watch.key | html %]</b>
67 <div class="scrollable">
68 [%- watch.value %]
69 </div>
70 </li>
71 [%- END %]
72 </ul>
73 </div>
74 [%- END %]
75 [%- IF modules.0 %]
76 [%- INCLUDE navi %]
77 <div class="box">
78 <h2><a name="modules">Included Modules</a></h2>
79 <ul id="modules">
80 [%- FOREACH module = modules %]
81 <li>[% module.package | html %] ([% module.file | html %])</li>
82 [%- END %]
83 </ul>
84 </div>
85 [%- END %]
86 [%- IF environment.0 %]
87 [%- INCLUDE navi %]
88 <div class="box">
89 <h2><a name="environment">Environmental Variables</a></h2>
90 <table id="environment">
91 [%- FOREACH env = environment %]
92 <tr>
93 <td>[% env.key | html %]</td><td><div class="scrollable">[% env.value | html %]</div><//td>
94 </tr>
95 [%- END %]
96 </table>
97 </div>
98 [%- END %]
99 <p class="footer">CGI::Carp::DebugScreen [% version %]. Output via [% view %]</p>
100 </div>
101 </body>
102 </html>
103 EOT
104
105 2 my $ErrorTemplate =<<'EOT';
106 <html>
107 <head>
108 <title>An unexpected error has been detected</title>
109 [%- IF style %]
110 [%- style %]
111 [%- END %]
112 </head>
113 <body>
114 <div id="page">
115 <h1>An unexpected error has been detected</h1>
116 <p>Sorry for inconvenience.</p>
117 </div>
118 </body>
119 </html>
120 EOT
121
122 629 ▶sub _escape {
Subroutine _escape: called CC=1 SCAR=0.0
123 629 my $str = shift;
124
125 629 $str =~ s/&/&amp;/g;
126 629 $str =~ s/>/&gt;/g;
127 629 $str =~ s/</&lt;/g;
128 629 $str =~ s/"/&quot;/g;
129
130 629 $str;
131 }
132
133 6 ▶sub as_html {
Subroutine as_html: called CC=5 SCAR=17.0
Pod documented
134 6 my ($pkg, %options) = @_;
135
136 6 ▶ $options{error_tmpl} ||= $ErrorTemplate;
Condition33%1/3
$options{"error_tmpl"} ||= $ErrorTemplate
l!l&&r!l&&!r
060
MC/DC0%0/2
$options{"error_tmpl"} ||= $ErrorTemplate
$options{"error_tmpl"} $ErrorTemplate
Truth table33%1/3
A ||= B
A= $options{"error_tmpl"}B= $ErrorTemplate
ABresult
1X1
011
000
137 6 ▶ $options{debug_tmpl} ||= $DebugTemplate;
Condition33%1/3
$options{"debug_tmpl"} ||= $DebugTemplate
l!l&&r!l&&!r
060
MC/DC0%0/2
$options{"debug_tmpl"} ||= $DebugTemplate
$options{"debug_tmpl"} $DebugTemplate
Truth table33%1/3
A ||= B
A= $options{"debug_tmpl"}B= $DebugTemplate
ABresult
1X1
011
000
138
139 6 ▶ my $tmpl = $options{debug} ? $options{debug_tmpl} : $options{error_tmpl};
Branch: 1 branch
BranchTrueFalseTotal
$options{'debug'} ? : 5 1 6
140
141 my $t = Template->new(
142 629 ▶ FILTERS => { html => sub { _escape(@_) } }
Subroutine __ANON__: called CC=1 SCAR=0.0
143 6 );
144
145 6 my $html;
146 6 ▶ $t->process(\$tmpl, \%options, \$html) or $html = $t->error();
Branch: 1 branch
BranchTrueFalseTotal
$t->process(\$tmpl, \%options, \$html) or $html = $t->error 6 0 6
147
148 6 return $html;
149 }
150
151 2 1;
152
153 __END__
« DebugScreen/HTML/Template.pm ↑ Summary