Pure/DataContext.pm

filter: Statementstmt 88.3% 38 / 43 Branchbran 68.7% 11 / 16 Conditioncond 62.5% 5 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 75.2% 64 / 85 CC 13 SCAR 20.6
CC
13
Cov
81%
at
14.2
new
3.1
BEGIN
1.0
CRAP 7.9
« Pure/ParseUtils.pm ↑ Summary Pure.pm »
1 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Template::Pure::DataContext;
5
6 14 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use Template::Pure::UndefObject;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 use overload
11 4 ▶ q{""} => sub { shift->value },
Subroutine __ANON__: called CC=1 SCAR=0.0
12 14 ▶ 'fallback' => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 116 ▶ my ($proto, $data_proto, $root) = @_;
Subroutine new: called CC=3 SCAR=11.3
Pod undocumented
16 116 ▶ my $class = ref($proto) || $proto;
Condition66%2/3
ref $proto || $proto
l!l&&r!l&&!r
75410
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
17 116 ▶ return bless +{
Condition66%2/3
$root || $data_proto
l!l&&r!l&&!r
11240
MC/DC0%0/2
$root || $data_proto
$root $data_proto
Truth table66%2/3
A || B
A= $rootB= $data_proto
ABresult
1X1
011
000
18 value => $data_proto,
19 root => ($root||$data_proto),
20 }, $class;
21 }
22  
23 95 ▶sub value { shift->{value} }
Subroutine value: called CC=1 SCAR=0.0
Pod undocumented
24
25 sub at {
26 75 ▶ my ($self, %at) = @_;
Subroutine at: called CC=11 SCAR=26.5
Pod undocumented
27 75 ▶ my $current = $at{absolute} ? $self->{root} : $self->{value};
Branch: 1 branch
BranchTrueFalseTotal
$at{'absolute'} ? : 2 73 75
28 75 foreach my $at(@{$at{path}}) {
29 117 ▶ my $key = $at->{key} || die "missing key";
Condition50%1/2
$at->{'key'} || die('missing key')
l!l
1170
MC/DC0%0/1
$at->{'key'} || die('missing key')
$at->{'key'}
Truth table50%1/2
A
A= $at->{'key'}
Aresult
11
00
30 117 ▶ if(blessed $current) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($current)) { } 17 100 117
elsif (ref $current eq 'HASH') { } 100 0 100
31 17 ▶ if($current->can($key)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($current->can($key)) { } 17 0 17
elsif ($at->{'optional'}) { } 0 0 0
32 17 $current = $current->$key;
33 } elsif($at->{optional}) {
34 0 $current = undef;
35 } else {
36 0 die "Missing path '$key'";
37 }
38 } elsif(ref $current eq 'HASH') {
39 100 ▶ if(exists $current->{$key}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $current->{$key}) { } 97 3 100
elsif ($at->{'optional'}) { } 3 0 3
40 97 $current = $current->{$key};
41 } elsif($at->{optional}) {
42 3 $current = undef;
43 } else {
44 0 warn Dumper $at;
45 0 die "Missing path '$key'";
46 }
47 } else {
48 0 die "Can't find path '$key' in ". Dumper $current;
49 }
50 117 ▶ if($at->{maybe}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($at->{"maybe"}) 1 116 117
51 1 $current = Template::Pure::UndefObject->maybe($current);
52 }
53 }
54 75 return $self->new($current, $self->{root});
55 }
56  
57 14 1;
58  
« Pure/ParseUtils.pm ↑ Summary Pure.pm »