blib/lib/Bootylicious/Plugin/GoogleAnalytics.pm

filter: Statementstmt 100% 28 / 28 Branchbran 50.0% 3 / 6 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 81.6% 40 / 49 CC 6 SCAR 10.1
CC
6
Cov
85%
__ANON__
4.2
register
3.1
BEGIN
1.0
CRAP 2.8
« blib/lib/Bootylicious/ArticleArchiveMonthly.pm ↑ Summary blib/lib/Bootylicious/FileIteratorLoader.pm »
1 package Bootylicious::Plugin::GoogleAnalytics;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Mojo::ByteStream 'b';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub register {
11 1 ▶ my ($self, $app, $conf) = @_;
Subroutine register: called CC=3 SCAR=11.3
Pod documented
12  
13 1 ▶ $conf ||= {};
Condition50%1/2
$conf ||= {}
l!l
10
MC/DC0%0/1
$conf ||= {}
$conf
Truth table50%1/2
A
A= $conf
Aresult
11
00
14  
15 1 ▶ return unless $conf->{urchin};
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"urchin"} 0 1 1
16 1 push @{$app->renderer->classes}, __PACKAGE__;
17  
18 $app->plugins->on(
19 after_dispatch => sub {
20 1 ▶ my ($c) = @_;
Subroutine __ANON__: called CC=4 SCAR=14.5
21  
22 1 ▶ return unless $c->res->code && $c->res->code == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $c->res->code and $c->res->code == 200 0 1 1
Condition33%1/3
$c->res->code and $c->res->code == 200
!ll&&!rl&&r
001
MC/DC0%0/2
$c->res->code and $c->res->code == 200
$c->res->code $c->res->code == 200
Truth table33%1/3
A and B
A= $c->res->codeB= $c->res->code == 200
ABresult
0X0
100
111
23  
24 1 my $body = $c->res->body;
25 1 ▶ return unless $body;
Branch: 1 branch
BranchTrueFalseTotal
unless $body 0 1 1
26  
27 1 $c->stash(urchin => $conf->{urchin});
28  
29 1 my $ga_script = $c->render_to_string(
30 'template',
31 format => 'html'
32 );
33  
34 1 $ga_script = b($ga_script)->encode('UTF-8');
35  
36 1 $body =~ s{</body>}{$ga_script</body>};
37 1 $c->res->body($body);
38 }
39 1 );
40 }
41  
42 1 1;
43 __DATA__
« blib/lib/Bootylicious/ArticleArchiveMonthly.pm ↑ Summary blib/lib/Bootylicious/FileIteratorLoader.pm »