blib/lib/Plack/Middleware/Debug/Dancer/TemplateVariables.pm

filter: Statementstmt 52.6% 20 / 38 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 45.4% 5 / 11 Podpod 66.6% 2 / 3 totaltotal 45.7% 27 / 59 CC 4 SCAR 14.7
CC
4
Cov
45%
vardump
12.0
__ANON__
6.0
prepare_app
2.0
CRAP 4.4
↑ Summary
1 package Plack::Middleware::Debug::Dancer::TemplateVariables;
2 {
3 1 $Plack::Middleware::Debug::Dancer::TemplateVariables::VERSION = '0.002';
4 }
5 # ABSTRACT: Debug and inspect your template variables for Dancer
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use parent qw(Plack::Middleware::Debug::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Dancer;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Data::Dumper ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my $env_key = 'debug.dancer.templatevariables';
15  
16 0 ▶sub prepare_app {
Subroutine prepare_app: not called CC=1 SCAR=6.9
Pod documented
17 0 ▶ Dancer::Hook->new('before_layout_render' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 0 my $tokens = shift;
19 0 Dancer::SharedData->request->env->{$env_key} = $tokens;
20 0 });
21 }
22  
23 1 my $list_template_dumped = __PACKAGE__->build_template(<<'EOTMPL');
24 <table>
25 <thead>
26 <tr>
27 <th>Key</th>
28 <th>Value</th>
29 </tr>
30 </thead>
31 <tbody>
32 % my $i;
33 % while (@{$_[0]->{list}}) {
34 % my($key, $value) = splice(@{$_[0]->{list}}, 0, 2);
35 <tr class="<%= ++$i % 2 ? 'plDebugOdd' : 'plDebugEven' %>">
36 <td><%= $key %></td>
37 <td><pre><%= vardump($value) %></pre></td>
38 </tr>
39 % }
40 </tbody>
41 </table>
42 EOTMPL
43  
44 0 ▶sub vardump {
Subroutine vardump: not called CC=3 SCAR=24.8
Pod undocumented
45 0 my $scalar = shift;
46 0 ▶ return '(undef)' unless defined $scalar;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scalar 0 0 0
47 0 ▶ return "$scalar" unless ref $scalar;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $scalar 0 0 0
48 0 scalar Data::Dump::dump($scalar);
49 }
50  
51 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
52 0 my ( $self, $env, $panel ) = @_;
53
54 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 my $res = shift;
56 0 $panel->title('Dancer::TemplateVariables');
57 0 $panel->nav_subtitle('Dancer::TemplateVariables');
58 0 ▶ $panel->content( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
59 0 ▶ my %vars = %{ $env->{$env_key} || {} };
Condition0%0/2
$env->{$env_key} || {}
l!l
00
MC/DC0%0/1
$env->{$env_key} || {}
$env->{$env_key}
Truth table0%0/2
A
A= $env->{$env_key}
Aresult
11
00
60 0 my @var_list = map { $_ => $vars{$_} } sort keys %vars;
61 0 $self->render( $list_template_dumped, { list => \@var_list } );
62 0 } );
63 0 };
64 }
65  
66 1 1;
67  
68  
69 __END__
↑ Summary