Debugbar/Monitor/Request.pm

filter: Statementstmt 26.0% 6 / 23 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 20.0% 1 / 5 Podpod 100% 3 / 3 totaltotal 29.4% 10 / 34 CC 3 SCAR 18.2
CC
3
Cov
24%
rows
12.0
render
2.0
start
2.0
CRAP 6.1
« Debugbar/Monitors.pm ↑ Summary Debugbar/Monitor/Template.pm »
1 package Mojo::Debugbar::Monitor::Request;
2 1 ▶use Mojo::Base "Mojo::Debugbar::Monitor";
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 has 'icon' => '<i class="icon-tag"></i>';
5 1 has 'name' => 'Request';
6  
7 =head2 render
8  
9 Returns the html
10  
11 =cut
12  
13 0 ▶sub render {
Subroutine render: not called CC=1 SCAR=6.9
Pod documented
14 0 my $self = shift;
15  
16 0 return sprintf(
17 '<table class="debugbar-templates table" data-debugbar-ref="%s">
18 <thead>
19 <tr>
20 <th width="30%%">Key</th>
21 <th>Value</th>
22 </tr>
23 </thead>
24 <tbody>
25 %s
26 </tbody>
27 </table>',
28 ref($self), $self->rows
29 );
30 }
31  
32 =head2 rows
33  
34 Build the rows
35  
36 =cut
37  
38 0 ▶sub rows {
Subroutine rows: not called CC=3 SCAR=24.8
Pod documented
39 0 my $self = shift;
40  
41 0 my $time = time;
42 0 my ($sec, $min, $hour) = localtime($time);
43  
44 0 my $rows = sprintf('<tr><td colspan="2">Request at %s:%s:%s (%s)</td></tr>', $hour, $min, $sec, scalar @{ $self->items });
45  
46 0 foreach my $item (@{ $self->items }) {
47 $rows .= sprintf(
48 '<tr>
49 <td>%s</td>
50 <td>%s</td>
51 </tr>',
52 0 ▶ $item->{ key }, $item->{ value } || ''
Condition0%0/2
$item->{'value'} || ''
l!l
00
MC/DC0%0/1
$item->{'value'} || ''
$item->{'value'}
Truth table0%0/2
A
A= $item->{'value'}
Aresult
11
00
53 );
54 }
55  
56 0 return $rows;
57 }
58  
59 =head2 start
60  
61 Listen for "after_dispatch" event and push:
62 - request method
63 - request params as string
64 - controller package name
65 - current action name
66  
67 =cut
68  
69 0 ▶sub start {
Subroutine start: not called CC=1 SCAR=6.9
Pod documented
70 0 my $self = shift;
71  
72 0 my @items;
73  
74 0 ▶ $self->app->hook(after_dispatch => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
75 0 my $c = shift;
76  
77 0 push(@items, (
78 { key => 'Method', value => $c->req->method },
79 { key => 'Params', value => $c->req->params->to_string },
80 { key => 'Controller', value => ref $c },
81 { key => 'Action', value => $c->stash('action') },
82 ));
83 0 });
84  
85 0 $self->items(\@items);
86 }
87  
88 1 1;
« Debugbar/Monitors.pm ↑ Summary Debugbar/Monitor/Template.pm »