lib/Egg/Component.pm

filter: Statementstmt 96.6% 87 / 90 Branchbran 73.0% 19 / 26 Conditioncond 60.8% 14 / 23 MC/DCmcdc 15.3% 2 / 13 Subroutinesub 90.0% 18 / 20 Podpod 100% 5 / 5 totaltotal 81.9% 145 / 177 CC 25 SCAR 17.9
CC
25
Cov
86%
_get_args
14.2
__ANON__
5.2
initialize
5.1
CRAP 6.0
« lib/Egg/Plugin/File/Rotate.pm ↑ Summary lib/Egg/Helper/Build/Module.pm »
1 package Egg::Component;
2 #
3 # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4 #
5 # $Id: Component.pm 337 2008-05-14 12:30:09Z lushe $
6 #
7 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 37 ▶use UNIVERSAL::require;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 37 ▶use Class::C3;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 37 ▶use Tie::Hash::Indexed;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 37 ▶use Carp qw/ croak /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 37 ▶use base qw/ Class::Data::Inheritable /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 37 ▶use Egg::Component::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 37 our $VERSION= '3.02';
17  
18 207 ▶sub initialize {
Subroutine initialize: called CC=5 SCAR=16.2
Pod documented
19 207 ▶ my $class= ref($_[0]) || $_[0];
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
02070
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
20 207 for my $method (qw/ namespace regists config /) {
21 621 ▶ next if $class->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $class->can($method) 347 274 621
22 274 $class->mk_classdata($method);
23 }
24 207 ▶ unless ($class->namespace) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->namespace) 137 70 207
25 137 $class->namespace($class);
26 137 $class->regists($class->ixhash);
27 ## $class->config({}) unless $class->config;
28 }
29 37 ▶ no strict 'refs'; ## no critic.
Subroutine BEGIN: called CC=1 SCAR=0.0
30 37 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 207 ▶ *{"${class}::___add_regists"}= sub {
Subroutine __ANON__: called CC=5 SCAR=16.6
32 28 my $self = shift;
33 28 ▶ my $label= shift || die q{I want label name.};
Condition50%1/2
shift() || die('I want label name.')
l!l
280
MC/DC0%0/1
shift() || die('I want label name.')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
34 28 ▶ my $pkg = shift || die q{I want package name.};
Condition50%1/2
shift() || die('I want package name.')
l!l
280
MC/DC0%0/1
shift() || die('I want package name.')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
35 28 ▶ my $conf = shift || undef;
Condition50%1/2
shift() || undef
l!l
028
MC/DC0%0/1
shift() || undef
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
36 28 ▶ $self->regists->{$label}= [$pkg, ($pkg->VERSION || '0.00'), $conf];
Condition100%2/2
$pkg->VERSION || '0.00'
l!l
271
MC/DC100%1/1
$pkg->VERSION || '0.00'
$pkg->VERSION
Truth table100%2/2
A
A= $pkg->VERSION
Aresult
11
00
37 207 };
38 207 $class;
39 }
40 28 ▶sub isa_register {
Subroutine isa_register: called CC=2 SCAR=7.0
Pod documented
41 28 my($proto, $label, $pkg)= _get_args(@_);
42 28 ▶ $proto= ref($proto) if ref($proto);
Branch: 1 branch
BranchTrueFalseTotal
if ref $proto 0 28 28
43 37 ▶ no strict 'refs'; ## no critic.
Subroutine BEGIN: called CC=1 SCAR=0.0
44 28 push @{"${proto}::ISA"}, $pkg;
45 28 $proto->___add_regists($label, $pkg);
46 }
47 0 ▶sub add_register {
Subroutine add_register: not called CC=1 SCAR=6.9
Pod documented
48 0 my($proto, $label, $pkg, $conf)= _get_args(@_);
49 0 $proto->___add_regists($label, $pkg, $conf);
50 }
51 207 ▶sub isa_terminator {
Subroutine isa_terminator: called CC=4 SCAR=13.9
Pod documented
52 207 my $proto= shift;
53 207 ▶ $proto= ref($proto) if ref($proto);
Branch: 1 branch
BranchTrueFalseTotal
if ref $proto 0 207 207
54 37 ▶ no strict 'refs'; ## no critic.
Subroutine BEGIN: called CC=1 SCAR=0.0
55 207 my $isa= \@{"${proto}::ISA"};
56 207 ▶ if (my $base= shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $base = shift()) 69 138 207
57 69 my $regex= quotemeta($base);
58 69 @$isa= grep !/^$regex$/, @$isa;
59 69 push @$isa, $base;
60 }
61 207 ▶ return $proto if ($isa->[$#{$isa}] eq 'Egg::Component::Base');
Branch: 1 branch
BranchTrueFalseTotal
if $$isa[$#{$isa;}] eq "Egg::Component::Base" 66 141 207
62 141 @$isa= grep !/^Egg\:+Component\:+Base/, @$isa;
63 141 push @$isa, 'Egg::Component::Base';
64 141 $proto;
65 }
66 140 ▶sub ixhash {
Subroutine ixhash: called CC=2 SCAR=6.9
Pod documented
67 140 shift;
68 140 tie my %hash, 'Tie::Hash::Indexed';
69 140 ▶ %hash= @_ if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 139 140
70 140 \%hash;
71 }
72 28 ▶sub _get_args {
Subroutine _get_args: called CC=12 SCAR=26.6
73 28 my $proto = shift;
74 28 ▶ $proto = ref($proto) if ref($proto);
Branch: 1 branch
BranchTrueFalseTotal
if ref $proto 0 28 28
75 28 ▶ my $load = shift || 0;
Condition50%1/2
shift() || 0
l!l
280
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
76 28 ▶ my $label = shift || croak q{ I want label name. };
Condition50%1/2
shift() || croak(' I want label name. ')
l!l
280
MC/DC0%0/1
shift() || croak(' I want label name. ')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
77 28 ▶ my $pkg = shift || $label;
Condition66%2/3
shift() || $label
l!l&&r!l&&!r
4240
MC/DC0%0/2
shift() || $label
shift() $label
Truth table66%2/3
A || B
A= shift()B= $label
ABresult
1X1
011
000
78 28 ▶ my $config= shift || undef;
Condition100%2/2
shift() || undef
l!l
325
MC/DC100%1/1
shift() || undef
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
79 28 ▶ if ($load) {
Branch: 1 branch
BranchTrueFalseTotal
if ($load) 28 0 28
80 2 ▶ $load > 1 ? do { $pkg->use or croak "$proto - $@" }
Branch: 1 branch
BranchTrueFalseTotal
$pkg->use or croak("$proto - $@") 2 0 2
81 28 ▶ : do { $pkg->require or croak "$proto - $@" };
Branch: 2 branches
BranchTrueFalseTotal
$load > 1 ? : 2 26 28
$pkg->require or croak("$proto - $@") 26 0 26
82 }
83 28 ▶ $pkg->config($config) if ($config and $pkg->can('config'));
Branch: 1 branch
BranchTrueFalseTotal
if $config and $pkg->can("config") 0 28 28
Condition66%2/3
$config and $pkg->can("config")
!ll&&!rl&&r
2530
MC/DC0%0/2
$config and $pkg->can("config")
$config $pkg->can("config")
Truth table66%2/3
A and B
A= $configB= $pkg->can("config")
ABresult
0X0
100
111
84 28 ($proto, lc($label), $pkg, $config, @_);
85 }
86 0 ▶sub ___add_regists { $_[0] }
Subroutine ___add_regists: not called CC=1 SCAR=6.9
87  
88 37 1;
89  
90 __END__
« lib/Egg/Plugin/File/Rotate.pm ↑ Summary lib/Egg/Helper/Build/Module.pm »