« 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 ||= {}
MC/DC0%0/1
$conf ||= {}
$conf
Truth table50%1/2
A
A= $conf
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | return unless $conf->{urchin}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$c->res->code and $c->res->code == 200
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
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | my $body = $c->res->body; | |||||||||||||||||||||||||||
| 25 | 1 | ▶ | return unless $body; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||