Component.pm

filter: Statementstmt 35.1% 19 / 54 Branchbran 13.6% 3 / 22 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 62.5% 5 / 8 Podpod 75.0% 3 / 4 totaltotal 30.3% 30 / 99 CC 15 SCAR 40.6
CC
15
Cov
27%
init
112.6
load_components
6.0
requires
6.0
CRAP 58.0
↑ Summary Plugin.pm »
1 package Blosxom::Component;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 my ( %attribute_of, %requires, %component_of );
7  
8 0 ▶sub load_components {
Subroutine load_components: not called CC=2 SCAR=17.9
Pod undocumented
9 0 my ( $class, @components ) = @_;
10 0 ▶ push @{ $component_of{$class} ||= [] }, @_;
Condition0%0/2
$component_of{$class} ||= []
l!l
00
MC/DC0%0/1
$component_of{$class} ||= []
$component_of{$class}
Truth table0%0/2
A
A= $component_of{$class}
Aresult
11
00
11 }
12  
13 0 ▶sub requires {
Subroutine requires: not called CC=2 SCAR=17.9
Pod documented
14 0 my ( $class, @methods ) = @_;
15 0 ▶ push @{ $requires{$class} ||= [] }, @methods;
Condition0%0/2
$requires{$class} ||= []
l!l
00
MC/DC0%0/1
$requires{$class} ||= []
$requires{$class}
Truth table0%0/2
A
A= $requires{$class}
Aresult
11
00
16 }
17  
18 1 ▶sub mk_accessors {
Subroutine mk_accessors: called CC=3 SCAR=11.0
Pod documented
19 1 my $class = shift;
20 1 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
21 1 my $field = shift;
22 1 ▶ my $default = ref $_[0] eq 'CODE' ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'CODE' ? : 1 0 1
23 1 $attribute_of{ $class }{ $field } = $default;
24 }
25 }
26  
27 0 ▶sub init {
Subroutine init: not called CC=11 SCAR=47.2
Pod documented
28 0 my $class = shift;
29 0 my $caller = shift;
30 0 ▶ my $stash = do { no strict 'refs'; \%{"$class\::"} };
Subroutine BEGIN: called CC=1 SCAR=1.2
31  
32 0 ▶ if ( my $components = $component_of{$class} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $components = $component_of{$class}) 0 0 0
33 0 my @args = @{ $components };
34 0 ▶ while ( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
35 0 my $component = shift;
36 0 ▶ my $config = ref $args[0] eq 'HASH' ? shift @args : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $args[0] eq 'HASH' ? : 0 0 0
37 0 $caller->add_component( $component => $config );
38 }
39 }
40  
41 0 ▶ if ( my $requires = $requires{$class} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $requires = $requires{$class}) 0 0 0
42 0 ▶ if ( my @methods = grep { !$caller->can($_) } @{$requires} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@methods) = grep({not $caller->can($_);} @{$requires;})) 0 0 0
43 0 my $methods = join ', ', @methods;
44 0 croak "Can't apply '$class' to '$caller' - missing $methods";
45 }
46 }
47  
48 0 ▶ if ( my $attribute = $attribute_of{$class} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $attribute = $attribute_of{$class}) 0 0 0
49 0 ▶ while ( my ($field, $default) = each %{$attribute} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$attribute;}) 0 0 0
50 0 $caller->add_attribute( $field, $default );
51 }
52 }
53  
54 # NOTE: use keys() instead
55 0 ▶ while ( my ($name, $glob) = each %{$stash} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$stash;}) 0 0 0
56 0 ▶ if ( defined *{$glob}{CODE} and $name ne 'init' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *{$glob;}{"CODE"} and $name ne "init") 0 0 0
Condition0%0/3
defined *{$glob;}{"CODE"} and $name ne "init"
!ll&&!rl&&r
000
MC/DC0%0/2
defined *{$glob;}{"CODE"} and $name ne "init"
defined *{$glob;}{"CODE"} $name ne "init"
Truth table0%0/3
A and B
A= defined *{$glob;}{"CODE"}B= $name ne "init"
ABresult
0X0
100
111
57 0 $caller->add_method( $name => *{$glob}{CODE} );
58 }
59 }
60  
61 0 return;
62 }
63  
64 1 1;
65  
66 __END__
↑ Summary Plugin.pm »