Sprocket/Local.pm

filter: Statementstmt 84.6% 33 / 39 Branchbran 40.0% 4 / 10 Conditioncond 22.2% 2 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 80.0% 8 / 10 Podpod 0.0% 0 / 3 totaltotal 61.0% 47 / 77 CC 9 SCAR 15.0
CC
9
Cov
67%
get_connection
12.0
import
5.3
new
3.3
CRAP 4.5
« Sprocket/Connection.pm ↑ Summary Sprocket.pm »
1 package Sprocket::Local;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Sprocket qw( Local::Connection );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use vars qw( $sprocket_local );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶sub import {
Subroutine import: called CC=5 SCAR=16.7
12 5 my ( $class, $args ) = @_;
13 5 my $package = caller();
14  
15 5 ▶ croak "Sprocket::Local expects its arguments in a hash ref"
Branch: 1 branch
BranchTrueFalseTotal
if $args and ref $args ne "HASH" 0 5 5
Condition33%1/3
$args and ref $args ne "HASH"
!ll&&!rl&&r
500
MC/DC0%0/2
$args and ref $args ne "HASH"
$args ref $args ne "HASH"
Truth table33%1/3
A and B
A= $argsB= ref $args ne "HASH"
ABresult
0X0
100
111
16 if ( $args && ref( $args ) ne 'HASH' );
17  
18 5 ▶ unless ( delete $args->{no_auto_export} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (delete $args->{"no_auto_export"}) 5 0 5
19 {
20 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 *{ $package . '::sprocket_local' } = \$sprocket_local;
22 }
23 }
24  
25 5 ▶ return if ( delete $args->{no_auto_bootstrap} );
Branch: 1 branch
BranchTrueFalseTotal
if delete $args->{"no_auto_bootstrap"} 0 5 5
26  
27 # bootstrap
28 5 Sprocket::Local->new( %$args );
29
30 5 return;
31 }
32  
33 5 ▶sub new {
Subroutine new: called CC=3 SCAR=12.0
Pod undocumented
34 5 ▶ return $sprocket_local if ( $sprocket_local );
Branch: 1 branch
BranchTrueFalseTotal
if $Sprocket::Local::sprocket_local 0 5 5
35 5 my $class = shift;
36
37 5 ▶ my $self = $sprocket_local = bless({
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
050
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
38 @_,
39 pak => { }, # hash of hashes, packages => ids => objects
40 }, ref $class || $class );
41
42 5 return $self;
43 }
44  
45 0 ▶sub new_connection {
Subroutine new_connection: not called CC=1 SCAR=6.9
Pod undocumented
46 0 my ( $self, $obj, $id ) = @_;
47
48 0 my $con = $self->{pak}->{$obj}->{$id} =
49 Sprocket::Local::Connection->new(
50 # parent_id => $self->{session_id},
51 __parent_plugin => $obj,
52 __id => $id,
53 );
54  
55 0 return $con;
56 }
57  
58 0 ▶sub get_connection {
Subroutine get_connection: not called CC=3 SCAR=24.8
Pod undocumented
59 0 my ( $self, $obj, $id ) = @_;
60 0 my $pk = $self->{pak}->{ $obj };
61 0 ▶ return ( $pk && $pk->{ $id } ) ? $pk->{ $id } : $self->new_connection( $obj, $id );
Branch: 1 branch
BranchTrueFalseTotal
$pk && $pk->{$id} ? : 0 0 0
Condition0%0/3
$pk and $pk->{$id}
!ll&&!rl&&r
000
MC/DC0%0/2
$pk and $pk->{$id}
$pk $pk->{$id}
Truth table0%0/3
A and B
A= $pkB= $pk->{$id}
ABresult
0X0
100
111
62 }
63  
64 5 1;
65  
« Sprocket/Connection.pm ↑ Summary Sprocket.pm »