| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$obj->{"hdl"} and $obj->{"map"}
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"}
| |||||||||||||||||||||||||||||
| 16 | 0 | my @rows = (); | |||||||||||||||||||||||||||
| 17 | 0 | ▶ | while (my $r = $obj->{hdl}->next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 0 | my @cols = (); | |||||||||||||||||||||||||||
| 19 | 0 | foreach my $c (@{$obj->{map}}) { | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | if (!ref $c) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if (exists $r->{$c}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | for (my $i=0; $i<=$#{$target}; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||