Recall/Base.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 75.0% 15 / 20 Conditioncond 50.0% 6 / 12 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 73.0% 57 / 78 CC 15 SCAR 20.7
CC
15
Cov
80%
render
9.0
trim
8.6
BEGIN
1.0
CRAP 7.9
« Recall.pm ↑ Summary
1 package Template::Recall::Base;
2
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6
7 6 our $VERSION='0.07';
8
9
10 sub render {
11
12 12 ▶ my ( $class, $template, $hash_ref, $delims ) = @_;
Subroutine render: called CC=8 SCAR=22.0
Pod undocumented
13
14 12 ▶ if ( not defined ($template) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $template) 0 12 12
15 0 return "Template::Recall::Base::render() 'template' parameter not present";
16 }
17
18 12 ▶ my $user_delims = ref($delims) && $#{$delims} == 1 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $delims && $#{$delims;} == 1 ? : 12 0 12
Condition33%1/3
ref $delims and $#{$delims;} == 1
!ll&&!rl&&r
0012
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 12 ▶ if ( ref($hash_ref) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash_ref) 11 1 12
20
21 11 ▶ while ( my ($key, $value) = each %$hash_ref) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$hash_ref) 11 11 22
22 11 ▶ if ( $user_delims ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user_delims) { } 11 0 11
23 11 my $d = $delims->[0] . '\s*' . $key . '\s*' . $delims->[1];
24 11 $template =~ s/$d/$value/g;
25 }
26 else { # exactly specified delims
27 0 $template =~ s/$key/$value/g;
28 }
29 } # while
30
31 } # if
32
33
34 # Do trimming, if so flagged
35 12 ▶ return trim($class->{'trim'}, $template) if defined($class->{'trim'});
Branch: 1 branch
BranchTrueFalseTotal
if defined $class->{"trim"} 4 8 12
36
37
38 8 return $template;
39
40 } # render()
41
42
43
44
45 # Trim output if directed to do so
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
68 } # trim()
69
70
71 6 1;
« Recall.pm ↑ Summary