blib/lib/Text/Xslate/Bridge.pm

filter: Statementstmt 86.8% 53 / 61 Branchbran 58.3% 7 / 12 Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 88.8% 8 / 9 Podpod 25.0% 1 / 4 totaltotal 80.0% 76 / 95 CC 13 SCAR 16.1
CC
13
Cov
82%
methods
7.5
_functions
7.0
bridge
2.0
CRAP 5.0
« blib/lib/Text/Xslate/Parser.pm ↑ Summary builder/MyBuilder.pm »
1 package Text::Xslate::Bridge;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Text::Xslate::Util qw(p);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 my %storage;
8  
9 6 ▶sub bridge {
Subroutine bridge: called CC=2 SCAR=6.9
Pod documented
10 6 my $class = shift;
11 6 ▶ while(my($type, $table) = splice @_, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 18 6 24
12 18 $storage{$class}{$type} = $table;
13 }
14 6 return;
15 }
16  
17 12 ▶sub export_into_xslate {
Subroutine export_into_xslate: called CC=1 SCAR=0.0
Pod undocumented
18 12 my($class, $funcs_ref, @args) = @_;
19 12 push @{$funcs_ref}, $class->methods(@args);
20 12 return;
21 }
22  
23 12 ▶sub methods {
Subroutine methods: called CC=6 SCAR=20.1
Pod undocumented
24 12 my($class, %args) = @_;
25  
26 12 ▶ if(!exists $storage{$class}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $storage{$class}) 0 12 12
27 0 Carp::croak("$class has no methods (possibly not a bridge class)");
28 }
29  
30 12 ▶ if(exists $args{-exclude}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{'-exclude'}) { } 2 10 12
31 2 my $exclude = $args{-exclude};
32 2 my $methods = $class->_functions;
33 2 my @export;
34  
35 2 ▶ if(ref($exclude) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $exclude eq "ARRAY") 2 0 2
36 2 $exclude = { map { $_ => 1 } @{$exclude} };
37 }
38  
39 2 ▶ if(ref($exclude) eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $exclude eq 'HASH') { } 2 0 2
elsif (ref $exclude eq 'Regexp') { } 0 0 0
40 2 @export = grep { !$exclude->{$_} } keys %{$methods};
41 }
42 elsif(ref($exclude) eq 'Regexp'){
43 0 @export = grep { $_ !~ $exclude } keys %{$methods};
44 }
45 else {
46 0 @export = grep { $_ ne $exclude } keys %{$methods};
47 }
48 2 return map { $_ => $methods->{$_} } @export;
49 }
50 else {
51 10 return %{ $class->_functions };
52 }
53 }
54  
55 12 ▶sub _functions {
Subroutine _functions: called CC=7 SCAR=19.5
56 12 my($class) = @_;
57  
58 12 ▶ my $st = $storage{$class} ||= {};
Condition50%1/2
$storage{$class} ||= {}
l!l
120
MC/DC0%0/1
$storage{$class} ||= {}
$storage{$class}
Truth table50%1/2
A
A= $storage{$class}
Aresult
11
00
59 12 ▶ my $funcs = $st->{_funcs} ||= {};
Condition100%2/2
$st->{"_funcs"} ||= {}
l!l
66
MC/DC100%1/1
$st->{"_funcs"} ||= {}
$st->{"_funcs"}
Truth table100%2/2
A
A= $st->{"_funcs"}
Aresult
11
00
60  
61 # for methods
62 12 foreach my $type (qw(scalar hash array)) {
63 36 ▶ my $table = $st->{$type} || next;
Condition100%2/2
$st->{$type} || (next)
l!l
324
MC/DC100%1/1
$st->{$type} || (next)
$st->{$type}
Truth table100%2/2
A
A= $st->{$type}
Aresult
11
00
64  
65 32 foreach my $name(keys %{$table}) {
66 52 $funcs->{$type . '::' . $name} = $table->{$name};
67 }
68 }
69  
70 # for functions
71 12 my $table = $st->{function};
72 12 foreach my $name(keys %{$table}) {
73 22 $funcs->{$name} = $table->{$name};
74 }
75 12 return $funcs;
76 }
77  
78 0 ▶sub dump {
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
79 0 p(\%storage);
80 }
81  
82 4 1;
83 __END__
« blib/lib/Text/Xslate/Parser.pm ↑ Summary builder/MyBuilder.pm »