File Coverage

blib/lib/HTML/Tested/List/Table.pm
Criterion Covered Total %
statement 41 41 100.0
branch 6 6 100.0
condition n/a
subroutine 7 7 100.0
pod 0 3 0.0
total 54 57 94.7


line stmt bran cond sub pod time code
1 19     19   105 use strict;
  19         32  
  19         734  
2 19     19   128 use warnings FATAL => 'all';
  19         35  
  19         1060  
3              
4             package HTML::Tested::List::Table;
5 19     19   113 use Carp;
  19         35  
  19         1525  
6 19     19   122 use Data::Dumper;
  19         58  
  19         11883  
7              
8 3     3 0 14 sub new { bless {}, shift(); }
9              
10             sub init {
11 3     3 0 7 my ($self, $the_list, $parent) = @_;
12 3         11 my $c = $the_list->containee;
13 3         4 my (@cols, @names);
14 3         5 for my $w (@{ $c->Widgets_List }) {
  3         12  
15 5         46 my $n = $w->name;
16 5         31 my $ct = $c->ht_get_widget_option($n, "column_title");
17 5 100       19 next unless defined($ct);
18 3         6 push @cols, $ct;
19 3         8 push @names, $n;
20             }
21 3 100       220 confess "No columns found!" unless @cols;
22 2         9 $self->{_cols} = \@cols;
23 2         10 $self->{_names} = \@names;
24             }
25              
26             sub render {
27 3     3 0 7 my ($self, $the_list, $caller, $stash, $id) = @_;
28 3         9 my ($cols, $names) = ($self->{_cols}, $self->{_names});
29 3         11 my $ln = $the_list->name;
30 3         7 my $res = "\n\n"; \n"; \n\n"; \n"; \n
31 3         7 for my $t (@$cols) {
32 4         13 $res .= "$t
33             }
34 3         7 for my $r (@{ $stash->{ $ln } }) {
  3         17  
35 5         9 $res .= "
36 5         8 for my $n (@$names) {
37 7         10 my $td = $r->{$n};
38 7 100       22 confess "# No $n found in " . Dumper($r)
39             unless defined($td);
40 6         20 $res .= "$td
41             }
42             }
43              
44 2         5 $res .= "
\n";
45 2         19 $stash->{"$ln\_table"} = $res;
46             }
47              
48             1;