| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 27 | 0 | Carp::croak("$class has no methods (possibly not a bridge class)"); | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | 12 | ▶ | if(exists $args{-exclude}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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
| |||||||||||||||
| 36 | 2 | $exclude = { map { $_ => 1 } @{$exclude} }; | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 2 | ▶ | if(ref($exclude) eq 'HASH') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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} ||= {}
MC/DC0%0/1
$storage{$class} ||= {}
$storage{$class}
Truth table50%1/2
A
A= $storage{$class}
| |||||||||||||||
| 59 | 12 | ▶ | my $funcs = $st->{_funcs} ||= {}; | ||||||||||||
|
Condition100%2/2
$st->{"_funcs"} ||= {}
MC/DC100%1/1
$st->{"_funcs"} ||= {}
$st->{"_funcs"}
Truth table100%2/2
A
A= $st->{"_funcs"}
| |||||||||||||||
| 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)
MC/DC100%1/1
$st->{$type} || (next)
$st->{$type}
Truth table100%2/2
A
A= $st->{$type}
| |||||||||||||||
| 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__ | ||||||||||||||