Recall/Base.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 70.0% 14 / 20 Conditioncond 50.0% 6 / 12 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 71.7% 56 / 78 SCAR 28.5
CC
15
Cov
78%
render
9.5
trim
8.6
BEGIN
1.0
CRAP 17.4
« Recall.pm ↑ Summary
1 package Template::Recall::Base;
2
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6
7 4 our $VERSION='0.08';
8
9
10 sub render {
11
12 8 ▶ my ( $class, $template, $hash_ref, $delims ) = @_;
Subroutine render: called CC=8 SCAR=22.5
Pod undocumented
13
14 8 ▶ if ( not defined ($template) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $template) 0 8 8
15 0 die "Template::Recall::Base::render() 'template' parameter not present";
16 }
17
18 8 ▶ my $user_delims = ref $delims && $#{$delims} == 1 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $delims && $#{$delims;} == 1 ? : 8 0 8
Condition33%1/3
ref $delims and $#{$delims;} == 1
!ll&&!rl&&r
008
MC/DC0%0/2
ref $delims and $#{$delims;} == 1
ref $delims $#{$delims;} == 1
Truth table33%1/3
A and B
A= ref $delimsB= $#{$delims;} == 1
ABresult
0X0
100
111
19
20 8 ▶ if (ref $hash_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash_ref) 8 0 8
21
22 8 ▶ while ( my ($key, $value) = each %$hash_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$hash_ref) 8 8 16
23 8 ▶ if ( $user_delims ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user_delims) { } 8 0 8
24 8 my $d = $delims->[0] . '\s*' . $key . '\s*' . $delims->[1];
25 8 $template =~ s/$d/$value/g;
26 }
27 else { # exactly specified delims
28 0 $template =~ s/$key/$value/g;
29 }
30 } # while
31
32 } # if
33
34
35 # Do trimming, if so flagged
36 8 ▶ return trim($class->{'trim'}, $template) if defined $class->{'trim'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $class->{"trim"} 4 4 8
37
38 4 return $template;
39
40 } # render()
41
42
43
44
45 # Trim output if specified
46
47 sub trim {
48 4 ▶ my ($trim, $template) = @_;
Subroutine trim: called CC=8 SCAR=21.6
Pod undocumented
49
50 4 ▶ return $template if !defined($trim);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $trim 0 4 4
51
52 4 ▶ if ($trim eq 'left' or $trim eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($trim eq "left" or $trim eq "l") 1 3 4
Condition66%2/3
$trim eq "left" or $trim eq "l"
l!l&&r!l&&!r
013
MC/DC50%1/2
$trim eq "left" or $trim eq "l"
$trim eq "left" $trim eq "l"
Truth table66%2/3
A or B
A= $trim eq "left"B= $trim eq "l"
ABresult
1X1
011
000
53 1 $template =~ s/^\s+//g;
54 1 return $template;
55 }
56
57 3 ▶ if ($trim eq 'right' or $trim eq 'r') {
Branch: 1 branch
BranchTrueFalseTotal
if ($trim eq "right" or $trim eq "r") 1 2 3
Condition66%2/3
$trim eq "right" or $trim eq "r"
l!l&&r!l&&!r
102
MC/DC50%1/2
$trim eq "right" or $trim eq "r"
$trim eq "right" $trim eq "r"
Truth table66%2/3
A or B
A= $trim eq "right"B= $trim eq "r"
ABresult
1X1
011
000
58 1 $template =~ s/\s+$//g;
59 1 return $template;
60 }
61
62 2 ▶ if ($trim eq 'both' or $trim eq 'b') {
Branch: 1 branch
BranchTrueFalseTotal
if ($trim eq "both" or $trim eq "b") 2 0 2
Condition33%1/3
$trim eq "both" or $trim eq "b"
l!l&&r!l&&!r
200
MC/DC0%0/2
$trim eq "both" or $trim eq "b"
$trim eq "both" $trim eq "b"
Truth table33%1/3
A or B
A= $trim eq "both"B= $trim eq "b"
ABresult
1X1
011
000
63 2 $template =~ s/^\s+|\s+$//g;
64 2 return $template;
65 }
66
67 } # trim()
68
69 4 1;
« Recall.pm ↑ Summary