Obj2HTML/Plugin/DB2PO.pm

filter: Statementstmt 21.1% 11 / 52 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 2 totaltotal 16.4% 14 / 85 SCAR 49.1
CC
14
Cov
15%
__ANON__
90.0
deepreplace
42.0
shallowreplace
2.0
CRAP 135.8
« Obj2HTML/Plugin/SemanticUIBase.pm ↑ Summary Obj2HTML/Plugin/SemanticUITabs.pm »
1 1 ▶use Storable 'dclone';
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 HTML::Obj2HTML::register_extension("dbtable", {
7 tag => "table",
8 before => sub {
9 0 ▶ my $obj = shift;
Subroutine __ANON__: not called CC=9 SCAR=45.0
10 # we should have: hdl, the db handle to use;
11 0 ▶ if ($obj->{header}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"header"}) 0 0 0
12 0 push(@{$obj->{_}}, thead => [ tr => HTML::Obj2HTML::iterate("th", $obj->{header}) ]);
13 0 delete($obj->{header});
14 }
15 0 ▶ if ($obj->{hdl} && $obj->{map}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{"hdl"} and $obj->{"map"}) 0 0 0
Condition0%0/3
$obj->{"hdl"} and $obj->{"map"}
!ll&&!rl&&r
000
MC/DC0%0/2
$obj->{"hdl"} and $obj->{"map"}
$obj->{"hdl"} $obj->{"map"}
Truth table0%0/3
A and B
A= $obj->{"hdl"}B= $obj->{"map"}
ABresult
0X0
100
111
16 0 my @rows = ();
17 0 ▶ while (my $r = $obj->{hdl}->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = $obj->{"hdl"}->next) 0 0 0
18 0 my @cols = ();
19 0 foreach my $c (@{$obj->{map}}) {
20 0 ▶ if (!ref $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $c) { } 0 0 0
21 0 ▶ if (exists $r->{$c}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$c}) { } 0 0 0
22 0 push(@cols, td => $r->{$c});
23 } else {
24 0 push(@cols, td => $c);
25 }
26 } else {
27 0 ▶ if (ref $c eq "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $c eq 'CODE') { } 0 0 0
28 0 my $coderet = &$c($r);
29 0 push(@cols, td => $coderet );
30 } else {
31 0 my $newc = dclone $c;
32 0 push(@cols, td => deepreplace($newc, $r) );
33 }
34 }
35 }
36 0 push(@rows, tr => \@cols);
37 }
38 0 push(@{$obj->{_}}, tbody => \@rows);
39 0 delete($obj->{hdl});
40 0 delete($obj->{map});
41 }
42 0 return "";
43 },
44 1 attr => { class => 'ui celled table' }
45 });
46  
47 sub deepreplace {
48 0 ▶ my $target = shift;
Subroutine deepreplace: not called CC=6 SCAR=37.4
Pod undocumented
49 0 my $record = shift;
50 0 ▶ if (ref $target eq "ARRAY") {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $target eq 'ARRAY') { } 0 0 0
elsif (ref $target eq 'HASH') { } 0 0 0
elsif (not ref $target) { } 0 0 0
51 0 ▶ for (my $i=0; $i<=$#{$target}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$target;}) 0 0 0
52 0 $target->[$i] = deepreplace($target->[$i], $record);
53 }
54 } elsif (ref $target eq "HASH") {
55 0 foreach my $k (keys %{$target}) {
56 0 $target->{$k} = deepreplace($target->{$k}, $record);
57 }
58  
59 } elsif (!ref $target) {
60 0 $target = shallowreplace($target, $record);
61 }
62 0 return $target;
63 }
64 sub shallowreplace {
65 0 ▶ my $str = shift;
Subroutine shallowreplace: not called CC=1 SCAR=6.9
Pod undocumented
66 0 my $record = shift;
67 0 $str =~ s/\$\$([a-zA-Z0-9]+)/$record->{$1}/g;
68 0 return $str;
69 }
70  
71 1 1;
« Obj2HTML/Plugin/SemanticUIBase.pm ↑ Summary Obj2HTML/Plugin/SemanticUITabs.pm »