blib/lib/Package/Subroutine.pm

filter: Statementstmt 67.6% 46 / 68 Branchbran 33.3% 6 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 10 / 15 Podpod 100% 10 / 10 totaltotal 64.8% 72 / 111 CC 11 SCAR 13.6
CC
11
Cov
60%
version
12.0
__ANON__
6.0
export
6.0
CRAP 3.9
« Build ↑ Summary blib/lib/Package/Subroutine/Namespace.pm »
1 package Package::Subroutine;
2 # **************************
3 6 $VERSION = '0.22.001';
4 # ****************
5 6 ; no strict 'refs'
6  
7 6 ▶; use Class::ISA ()
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶; sub export_to_caller
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶ { my ($self,$level) = @_
Subroutine export_to_caller: called CC=1 SCAR=0.0
Pod documented
11 1 ; my $namespace = (caller($level))[0]
12 ; return sub
13 1 ▶ { my ($from,@methods) = @_
Subroutine __ANON__: called CC=2 SCAR=7.1
14 1 ▶ ; $from = caller if $from eq '_'
Branch: 1 branch
BranchTrueFalseTotal
if $from eq "_" 1 0 1
15 1 ; exporter($namespace,$from,@methods)
16 }
17 1 }
18  
19 ; sub export_to
20 0 ▶ { my ($self,$namespace) = @_
Subroutine export_to: not called CC=1 SCAR=6.9
Pod documented
21 ; return sub
22 0 ▶ { my ($from,@methods) = @_
Subroutine __ANON__: not called CC=2 SCAR=17.9
23 0 ▶ ; $from = caller if $from eq '_'
Branch: 1 branch
BranchTrueFalseTotal
if $from eq "_" 0 0 0
24 0 ; exporter($namespace,$from,@methods)
25 }
26 0 }
27  
28 ; sub export
29 0 ▶ { my $ns = (caller(1))[0]
Subroutine export: not called CC=2 SCAR=17.9
Pod documented
30 ; shift() # rm package
31 # working shortcut for __PACKAGE__
32 0 ▶ ; splice(@_,0,1,"".caller) if $_[0] eq '_'
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq "_" 0 0 0
33 0 ; exporter($ns,@_)
34 }
35  
36 ; sub import
37 7 ▶ { my $ns = (caller(0))[0]
Subroutine import: called CC=1 SCAR=0.0
38 ; shift() # rm package
39 7 ; exporter($ns,@_)
40 }
41  
42 ; sub mixin
43 1 ▶ { my $ns = (caller(0))[0]
Subroutine mixin: called CC=2 SCAR=7.0
Pod documented
44 1 ; my $pkg = shift()
45 1 ▶ ; if(@_==1)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 1 0 1
46 1 { push @_, $pkg->findsubs($_[0])
47 }
48 1 ; exporter($ns,@_)
49 }
50  
51 ; sub exporter
52 9 ▶ { my $namespace = shift
Subroutine exporter: called CC=3 SCAR=11.0
Pod documented
53 9 ; my $from = shift
54 9 ; my @methods = @_
55 9 ; local $_
56  
57 9 ; for ( @methods )
58 25 { my $srcm = my $trgm = $_
59 25 ▶ ; ($srcm,$trgm) = @$_ if ref eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "ARRAY" 0 25 25
60 25 ; my $target = "${namespace}::${trgm}"
61 25 ; my $source = "${from}::${srcm}"
62 25 ; *$target = \&$source
63 }
64 }
65  
66 ; sub version
67 0 ▶ { my ($f,$pkg,$num)=@_
Subroutine version: not called CC=3 SCAR=24.8
Pod documented
68 0 ▶ ; if( defined($num) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $num) 0 0 0
69 0 { $num=eval { UNIVERSAL::VERSION($pkg,$num) }
70 0 ▶ ; return $@ ? undef : $num
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
71 }
72 0 ; eval { UNIVERSAL::VERSION($pkg) }
73 }
74  
75 ; sub install
76 0 ▶ { my ($pkg,$target,$name,$coderef)=@_
Subroutine install: not called CC=1 SCAR=6.9
Pod documented
77 0 ; $target="${target}::${name}"
78 0 ; *$target = $coderef
79 }
80  
81 ; sub isdefined
82 2 ▶ { my ($pkg,$namespace,$subname)=@_
Subroutine isdefined: called CC=3 SCAR=12.3
Pod documented
83 2 ▶ ; unless($subname)
Branch: 1 branch
BranchTrueFalseTotal
unless ($subname) 0 2 2
84 0 { my @ns = split /\'|\:\:/, $namespace
85 0 ; $subname = pop @ns
86 0 ; $namespace = join "::",@ns
87 }
88 2 ; *{"${namespace}::${subname}"}{CODE} || undef
89 2 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
*{"${namespace}::$subname";}{"CODE"} or undef 1 1 2
90  
91 ; sub findsubs
92 7 ▶ { my ($self,$class)=@_
Subroutine findsubs: called CC=1 SCAR=0.0
Pod documented
93 7 ; grep { *{"${class}::${_}"}{CODE} } keys %{"${class}::"}
94 }
95  
96 ; sub findmethods
97 2 ▶ { my ($self,$class)=@_
Subroutine findmethods: called CC=1 SCAR=0.0
Pod documented
98 34 ; my %methods = map { $_ => 1 }
99 2 map { $self->findsubs($_) }
100 reverse (Class::ISA::self_and_super_path($class),'UNIVERSAL')
101 2 ; return keys %methods
102 }
103  
104 6 ; 1
105  
106 __END__
« Build ↑ Summary blib/lib/Package/Subroutine/Namespace.pm »