lib/Badger.pm

filter: Statementstmt 84.7% 39 / 46 Branchbran 25.0% 3 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 9 / 12 Podpod 100% 5 / 5 totaltotal 71.2% 57 / 80 CC 9 SCAR 17.3
CC
9
Cov
70%
hub
20.0
init
3.1
lib
3.0
CRAP 5.6
« blib/lib/Badger/Data/Facet.pm ↑ Summary blib/lib/Badger/Codec/Unicode.pm »
1 package Badger;
2  
3 70 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 70 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 70 ▶use lib;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 70 ▶use Badger::Hub;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 use Badger::Class
8 debug => 0,
9 base => 'Badger::Base',
10 import => 'class',
11 words => 'HUB',
12 constants => 'PKG ARRAY DELIMITER',
13 filesystem => 'Bin',
14 exports => {
15 hooks => {
16 70 ▶ lib => [ sub { $_[0]->lib($_[3]) }, 1],
Subroutine __ANON__: called CC=1 SCAR=0.0
17 },
18 fail => \&_export_handler,
19 70 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 70 our $VERSION = 0.14;
22 70 our $HUB = 'Badger::Hub::Badger';
23 70 our $AUTOLOAD;
24  
25  
26 sub _export_handler {
27 # TODO: we should be able to refactor this down, now that Badger::Exporter
28 # can handle this argument shifting
29 13 ▶ my ($class, $target, $key, $symbols) = @_;
Subroutine _export_handler: called CC=2 SCAR=7.0
30 13 ▶ croak "You didn't specify a value for the '$key' load option."
Branch: 1 branch
BranchTrueFalseTotal
unless @$symbols 0 13 13
31 unless @$symbols;
32 13 my $module = join(PKG, $class, $key);
33 13 my $option = shift @$symbols;
34 13 class($module)->load;
35 13 $module->export($target, $option);
36 13 return 1;
37 }
38  
39  
40 sub init {
41 1 ▶ my ($self, $config) = @_;
Subroutine init: called CC=3 SCAR=11.4
Pod documented
42 1 ▶ my $hub = $config->{ hub } || $self->class->any_var(HUB);
Condition33%1/3
$config->{'hub'} || $self->class->any_var('HUB')
l!l&&r!l&&!r
010
MC/DC0%0/2
$config->{'hub'} || $self->class->any_var('HUB')
$config->{'hub'} $self->class->any_var('HUB')
Truth table33%1/3
A || B
A= $config->{'hub'}B= $self->class->any_var('HUB')
ABresult
1X1
011
000
43 1 ▶ unless (ref $hub) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $hub) 1 0 1
44 1 class($hub)->load;
45 1 $hub = $hub->new($config);
46 }
47 1 $self->{ hub } = $hub;
48 1 return $self;
49 }
50  
51 sub lib {
52 7 ▶ my ($self, $lib) = @_;
Subroutine lib: called CC=3 SCAR=11.0
Pod documented
53 7 ▶ $lib = [split(DELIMITER, $lib)]
Branch: 1 branch
BranchTrueFalseTotal
unless ref $lib eq "ARRAY" 7 0 7
54 unless ref $lib eq ARRAY;
55 7 foreach (@$lib) {
56 # resolve directories relative to current working directory so that
57 # relative paths Just Work[tm], e.g. ../perl/lib as well as absolute
58 # paths. e.g. /full/path/to/perl/lib
59 9 my $dir = Bin->dir($_)->must_exist;
60 9 $self->debug("adding lib: $dir") if DEBUG;
61 9 lib->import($dir->absolute);
62 }
63 }
64  
65 sub hub {
66 0 ▶ my $self = shift;
Subroutine hub: not called CC=4 SCAR=30.0
Pod documented
67  
68 0 ▶ if (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
69 return @_
70 ? ($self->{ hub } = shift)
71 0 ▶ : $self->{ hub };
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
72 }
73 else {
74 return @_
75 0 ▶ ? $self->class->var(HUB => shift)
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
76 : $self->class->var(HUB)
77 }
78 }
79  
80 sub codec {
81 0 ▶ shift->hub->codec(@_);
Subroutine codec: not called CC=1 SCAR=6.9
Pod documented
82 }
83  
84  
85 sub config {
86 0 ▶ my $self = shift;
Subroutine config: not called CC=1 SCAR=6.9
Pod documented
87 0 return $self->hub->config;
88 }
89  
90 # TODO: AUTOLOAD method which polls hub to see what it supports
91  
92 70 1;
93  
94 __END__
« blib/lib/Badger/Data/Facet.pm ↑ Summary blib/lib/Badger/Codec/Unicode.pm »