blib/lib/Mojolicious/Plugin/Debugbar.pm

filter: Statementstmt 36.3% 8 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 100% 1 / 1 totaltotal 34.3% 11 / 32 CC 3 SCAR 17.9
CC
3
Cov
31%
__ANON__
12.0
register
2.0
__ANON__
2.0
CRAP 6.0
↑ Summary
1 package Mojolicious::Plugin::Debugbar;
2 2 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 ▶use Mojo::Debugbar;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.1.2';
7  
8 =head2 register
9  
10 =cut
11  
12 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod documented
13 0 my ($self, $app, $config) = @_;
14  
15 0 my $debugbar = Mojo::Debugbar->new(app => $app, config => $config);
16  
17 0 ▶ $app->hook(around_dispatch => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 0 my ($next, $c) = @_;
19  
20 # Start recording
21 0 $debugbar->start;
22  
23 0 $next->();
24  
25 # Stop recording
26 0 $debugbar->stop;
27 0 });
28  
29 0 ▶ $app->hook(after_render => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
30 0 my ($c, $output, $format) = @_;
31  
32 0 ▶ return unless $format eq 'html';
Branch: 1 branch
BranchTrueFalseTotal
unless $format eq "html" 0 0 0
33  
34 # if there is a </body> tag, inject the debugbar
35 0 ▶ if ($$output =~ m/<\/body>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$output =~ m[</body>]u) { } 0 0 0
36 # Render the debugbar html
37 0 my $html = $debugbar->render;
38  
39 # Append text before the closing </body> tag
40 0 $$output =~ s!(</body>)!$html$1!;
41 } else {
42 # Append text at the end of the output
43 0 $$output .= $debugbar->inject;
44 }
45 0 });
46 }
47  
48 2 1;
↑ Summary