| 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} ||= []
MC/DC0%0/1
$component_of{$class} ||= []
$component_of{$class}
Truth table0%0/2
A
A= $component_of{$class}
| |||||||||||||||||||||||||||||
| 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} ||= []
MC/DC0%0/1
$requires{$class} ||= []
$requires{$class}
Truth table0%0/2
A
A= $requires{$class}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 21 | 1 | my $field = shift; | |||||||||||||||||||||||||||
| 22 | 1 | ▶ | my $default = ref $_[0] eq 'CODE' ? shift : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 33 | 0 | my @args = @{ $components }; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | while ( @args ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | my $component = shift; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $config = ref $args[0] eq 'HASH' ? shift @args : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $caller->add_component( $component => $config ); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( my $requires = $requires{$class} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( my @methods = grep { !$caller->can($_) } @{$requires} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | while ( my ($field, $default) = each %{$attribute} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ( defined *{$glob}{CODE} and $name ne 'init' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined *{$glob;}{"CODE"} and $name ne "init"
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"
| |||||||||||||||||||||||||||||
| 57 | 0 | $caller->add_method( $name => *{$glob}{CODE} ); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | return; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | 1; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||