line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::Debug::Base; |
2
|
2
|
|
|
2
|
|
974
|
use 5.008; |
|
2
|
|
|
|
|
7
|
|
3
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
5
|
2
|
|
|
2
|
|
19
|
use parent qw(Plack::Middleware); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
6
|
2
|
|
|
2
|
|
129
|
use Plack::Util::Accessor qw(renderer); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
7
|
2
|
|
|
2
|
|
100
|
use Text::MicroTemplate; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
8
|
2
|
|
|
2
|
|
957
|
use Data::Dumper::Concise; |
|
2
|
|
|
|
|
13777
|
|
|
2
|
|
|
|
|
145
|
|
9
|
2
|
|
|
2
|
|
16
|
use Scalar::Util; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1465
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub call { |
14
|
20
|
|
|
20
|
1
|
932
|
my($self, $env) = @_; |
15
|
|
|
|
|
|
|
|
16
|
20
|
|
|
|
|
181
|
my $panel = $self->default_panel; |
17
|
20
|
|
|
|
|
139
|
my $after = $self->run($env, $panel); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$self->response_cb($self->app->($env), sub { |
20
|
20
|
|
|
14
|
|
1552
|
my $res = shift; |
21
|
20
|
100
|
66
|
|
|
246
|
$after->($res) if $after && ref $after eq 'CODE'; |
22
|
20
|
|
|
|
|
631
|
push @{$env->{'plack.debug.panels'}}, $panel; |
|
20
|
|
|
|
|
146
|
|
23
|
20
|
|
|
|
|
273
|
}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
0
|
1
|
|
sub run { } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub panel_id { |
29
|
20
|
|
|
20
|
0
|
37
|
my $self = shift; |
30
|
20
|
|
|
|
|
184
|
(my $name = ref $self) =~ s/.*:://; |
31
|
20
|
|
|
|
|
153
|
$name . Scalar::Util::refaddr($self); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub panel_name { |
35
|
20
|
|
|
20
|
0
|
41
|
my $self = shift; |
36
|
20
|
|
|
|
|
110
|
(my $name = ref $self) =~ s/.*:://; |
37
|
20
|
|
|
|
|
99
|
$name =~ s/(?<=[a-z])(?=[A-Z])/ /g; |
38
|
20
|
|
|
|
|
62
|
$name; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub default_panel { |
42
|
20
|
|
|
20
|
0
|
52
|
my($self, $env) = @_; |
43
|
|
|
|
|
|
|
|
44
|
20
|
|
|
|
|
115
|
my $id = $self->panel_id; |
45
|
20
|
|
|
|
|
91
|
my $name = $self->panel_name; |
46
|
|
|
|
|
|
|
|
47
|
20
|
|
|
|
|
475
|
my $panel = Plack::Middleware::Debug::Panel->new; |
48
|
20
|
|
|
|
|
131
|
$panel->dom_id("plDebug${id}Panel"); |
49
|
20
|
|
|
|
|
204
|
$panel->url('#'); |
50
|
20
|
|
|
|
|
160
|
$panel->title($name); |
51
|
20
|
|
|
|
|
147
|
$panel->nav_title($name); |
52
|
20
|
|
|
|
|
153
|
$panel->nav_subtitle(''); |
53
|
20
|
|
|
|
|
145
|
$panel->content(''); |
54
|
|
|
|
|
|
|
|
55
|
20
|
|
|
|
|
134
|
$panel; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub vardump { |
59
|
91
|
|
|
91
|
0
|
5681
|
my $scalar = shift; |
60
|
91
|
50
|
|
|
|
225
|
return '(undef)' unless defined $scalar; |
61
|
91
|
100
|
|
|
|
1962
|
return "$scalar" unless ref $scalar; |
62
|
6
|
|
|
|
|
60
|
return scalar Dumper( $scalar ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub build_template { |
66
|
6
|
|
|
6
|
0
|
15
|
my $class = shift; |
67
|
6
|
|
|
|
|
30
|
Text::MicroTemplate->new( |
68
|
|
|
|
|
|
|
template => $_[0], |
69
|
|
|
|
|
|
|
tag_start => '<%', |
70
|
|
|
|
|
|
|
tag_end => '%>', |
71
|
|
|
|
|
|
|
line_start => '%', |
72
|
|
|
|
|
|
|
)->build; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub render { |
76
|
12
|
|
|
12
|
0
|
59
|
my ($self, $template, $vars) = @_; |
77
|
12
|
|
|
|
|
581
|
$template->($vars); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $list_section_template = __PACKAGE__->build_template(<<'EOTMPL'); |
81
|
|
|
|
|
|
|
% foreach my $s (@{$_[0]->{sections}}) { |
82
|
|
|
|
|
|
|
<%= ucfirst $s %> |
83
|
|
|
|
|
|
|
% if (scalar @{$_[0]->{list}->{$s}}) { |
84
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
| Key |
88
|
|
|
|
|
|
|
| Value |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
| |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
% my $i; |
93
|
|
|
|
|
|
|
% while (@{$_[0]->{list}->{$s}}) { |
94
|
|
|
|
|
|
|
% my($key, $value) = splice(@{$_[0]->{list}->{$s}}, 0, 2); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
| <%= $key %> |
97
|
|
|
|
|
|
|
| <%= vardump($value) %> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
% } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
| |
102
|
|
|
|
|
|
|
% } |
103
|
|
|
|
|
|
|
% } |
104
|
|
|
|
|
|
|
EOTMPL |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $list_template = __PACKAGE__->build_template(<<'EOTMPL'); |
107
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
EOTMPL |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my $line_template = __PACKAGE__->build_template(<<'EOTMPL'); |
128
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
% my $i; |
131
|
|
|
|
|
|
|
% if (defined $_[0]->{lines}) { |
132
|
|
|
|
|
|
|
% my @lines = ref $_[0]->{lines} eq 'ARRAY' ? @{$_[0]->{lines}} : split /\r?\n/, $_[0]->{lines}; |
133
|
|
|
|
|
|
|
% for my $line (@lines) { |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
| <%= $line %> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
% } |
138
|
|
|
|
|
|
|
% } |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
| |
141
|
|
|
|
|
|
|
EOTMPL |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub render_lines { |
144
|
0
|
|
|
0
|
0
|
0
|
my ($self, $lines) = @_; |
145
|
0
|
|
|
|
|
0
|
$self->render($line_template, { lines => $lines }); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub render_list_pairs { |
149
|
9
|
|
|
9
|
0
|
54
|
my ($self, $list, $sections) = @_; |
150
|
9
|
50
|
|
|
|
45
|
if ($sections) { |
151
|
0
|
|
|
|
|
0
|
$self->render($list_section_template, { list => $list, sections => $sections }); |
152
|
|
|
|
|
|
|
}else{ |
153
|
9
|
|
|
|
|
142
|
$self->render($list_template, { list => $list }); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub render_hash { |
158
|
3
|
|
|
3
|
0
|
16
|
my ( $self, $hash, $sections ) = @_; |
159
|
3
|
50
|
|
|
|
16
|
if ($sections) { |
160
|
0
|
|
|
|
|
0
|
my %hash; |
161
|
0
|
|
|
|
|
0
|
foreach my $section ( keys %$hash ) { |
162
|
0
|
|
|
|
|
0
|
push @{ $hash{$section} }, |
163
|
0
|
|
|
|
|
0
|
map { $_ => $hash->{$section}->{$_} } |
164
|
0
|
|
|
|
|
0
|
sort keys %{ $hash->{$section} }; |
|
0
|
|
|
|
|
0
|
|
165
|
|
|
|
|
|
|
} |
166
|
0
|
|
|
|
|
0
|
$self->render( $list_section_template, |
167
|
|
|
|
|
|
|
{ sections => $sections, list => \%hash } ); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
else { |
170
|
3
|
|
|
|
|
129
|
my @hash = map { $_ => $hash->{$_} } sort keys %$hash; |
|
67
|
|
|
|
|
304
|
|
171
|
3
|
|
|
|
|
31
|
$self->render( $list_template, { list => \@hash } ); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
__END__ |