blib/lib/Mojolicious/Plugin/Mango.pm

filter: Statementstmt 83.6% 41 / 49 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 69.2% 9 / 13 Podpod 100% 1 / 1 totaltotal 73.0% 57 / 78 CC 9 SCAR 15.3
CC
9
Cov
77%
register
9.7
__ANON__
2.0
__ANON__
2.0
CRAP 4.6
↑ Summary
1 package Mojolicious::Plugin::Mango;
2 2 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Mango;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.0.2'; # VERSION
8 # ABSTRACT: provide mango helpers to Mojolicious
9  
10 1 ▶sub register {
Subroutine register: called CC=8 SCAR=22.7
Pod documented
11 1 my $self = shift;
12 1 my $app = shift;
13 1 ▶ my $conf = shift || {};
Condition50%1/2
shift() || {}
l!l
10
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14 1 ▶ $conf->{helper} ||= 'db';
Condition50%1/2
$conf->{"helper"} ||= "db"
l!l
01
MC/DC0%0/1
$conf->{"helper"} ||= "db"
$conf->{"helper"}
Truth table50%1/2
A
A= $conf->{"helper"}
Aresult
11
00
15 1 ▶ $conf->{default_db} ||= 'test';
Condition50%1/2
$conf->{"default_db"} ||= "test"
l!l
01
MC/DC0%0/1
$conf->{"default_db"} ||= "test"
$conf->{"default_db"}
Truth table50%1/2
A
A= $conf->{"default_db"}
Aresult
11
00
16 1 ▶ $app->attr('_mango' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
17 1 my $m = Mango->new($conf->{mango});
18 1 $m->default_db($conf->{default_db});
19 1 ▶ $m->hosts($conf->{hosts}) if $conf->{hosts};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"hosts"} 0 1 1
20 1 $m;
21 }
22 1 );
23 1 ▶ $app->helper('mango' => sub { shift; Mango->new(@_) });
Subroutine __ANON__: called CC=1 SCAR=0.0
24 3 ▶ $app->helper($conf->{helper} => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 3 my $self = shift;
26 3 return $self->app->_mango->db(@_);
27 }
28 1 );
29 0 ▶ $app->helper('hosts' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 my $self = shift;
31 0 return $self->app->_mango->hosts(@_);
32 1 });
33 0 ▶ $app->helper('default_db' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 0 my $self = shift;
35 0 return $self->app->_mango->default_db(@_);
36 1 });
37 1 ▶ $app->helper('coll' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
38 1 my $self = shift;
39 1 return $self->app->_mango->db->collection(@_);
40 1 });
41 1 for my $helper (qw/get_more kill_cursors query/) {
42 3 ▶ next if (defined ($conf->{"no_$helper"}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $$conf{"no_$helper"} 0 3 3
43 0 ▶ $app->helper($helper => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 0 my $self = shift;
45 0 $self->app->_mango->$helper(@_);
46 })
47 3 }
48 1 for my $helper (qw/collection collection_names command dereference gridfs stats/) {
49 6 ▶ next if (defined ($conf->{"no_$helper"}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $$conf{"no_$helper"} 0 6 6
50 0 ▶ $app->helper($helper => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 my $self = shift;
52 0 $self->app->_mango->db->$helper(@_);
53 })
54 6 }
55 }
56  
57 2 1;
58  
59 __END__
↑ Summary