Tested/List/Table.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 94.8% 55 / 58 CC 8 SCAR 11.9
CC
8
Cov
100%
render
5.0
init
4.0
BEGIN
1.0
CRAP 3.3
« Tested/Value/Link.pm ↑ Summary Tested/Test/DateTime.pm »
1 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 20 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package HTML::Tested::List::Table;
5 20 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 20 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶sub new { bless {}, shift(); }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
9  
10 3 ▶sub init {
Subroutine init: called CC=4 SCAR=13.9
Pod undocumented
11 3 my ($self, $the_list, $parent) = @_;
12 3 my $c = $the_list->containee;
13 3 my (@cols, @names);
14 3 for my $w (@{ $c->Widgets_List }) {
15 5 my $n = $w->name;
16 5 my $ct = $c->ht_get_widget_option($n, "column_title");
17 5 ▶ next unless defined($ct);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ct 2 3 5
18 3 push @cols, $ct;
19 3 push @names, $n;
20 }
21 3 ▶ confess "No columns found!" unless @cols;
Branch: 1 branch
BranchTrueFalseTotal
unless @cols 1 2 3
22 2 $self->{_cols} = \@cols;
23 2 $self->{_names} = \@names;
24 }
25  
26 3 ▶sub render {
Subroutine render: called CC=5 SCAR=16.1
Pod undocumented
27 3 my ($self, $the_list, $caller, $stash, $id) = @_;
28 3 my ($cols, $names) = ($self->{_cols}, $self->{_names});
29 3 my $ln = $the_list->name;
30 3 my $res = "<table>\n<tr>\n";
31 3 for my $t (@$cols) {
32 4 $res .= "<th>$t</th>\n";
33 }
34 3 for my $r (@{ $stash->{ $ln } }) {
35 5 $res .= "</tr>\n<tr>\n";
36 5 for my $n (@$names) {
37 7 my $td = $r->{$n};
38 7 ▶ confess "# No $n found in " . Dumper($r)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $td 1 6 7
39 unless defined($td);
40 6 $res .= "<td>$td</td>\n";
41 }
42 }
43  
44 2 $res .= "</tr>\n</table>\n";
45 2 $stash->{"$ln\_table"} = $res;
46 }
47  
48 20 1;
« Tested/Value/Link.pm ↑ Summary Tested/Test/DateTime.pm »