Tabular/Row.pm

filter: Statementstmt 89.6% 52 / 58 Branchbran 45.0% 9 / 20 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.2% 15 / 17 Podpod 0.0% 0 / 13 totaltotal 68.1% 77 / 113 CC 14 SCAR 14.0
CC
14
Cov
77%
new
10.5
headers
4.0
cells
3.0
CRAP 4.0
« Tabular/Row/Data.pm ↑ Summary Tabular/Extra.pm »
1 # Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 package
5 Data::Tabular::Row;
6  
7 6 ▶use Data::Tabular::Cell;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 ▶use overload '@{}' => \&array,
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 '""' => \&str;
12  
13 sub new
14 209 ▶{
Subroutine new: called CC=7 SCAR=23.6
Pod undocumented
15 209 my $caller = shift;
16 209 ▶ my $class = ref($caller) || $caller;
Condition33%1/3
ref $caller || $caller
l!l&&r!l&&!r
02090
MC/DC0%0/2
ref $caller || $caller
ref $caller $caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
ABresult
1X1
011
000
17 209 my $self = { @_ };
18 209 ▶ if (ref($caller)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $caller) 0 209 209
19 0 ▶ croak(q|Don't know how to copy object: | . $class)
Branch: 1 branch
BranchTrueFalseTotal
unless $caller->isa(__PACKAGE__) 0 0 0
20 unless $caller->isa(__PACKAGE__);
21 0 $self = $caller->clone();
22 }
23 209 $self = bless $self, $class;
24  
25 209 ▶ die caller unless $self->table->headers;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->table->headers 0 209 209
26 209 ▶ croak 'need table' unless $self->table->headers;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->table->headers 0 209 209
27 209 ▶ croak 'need table' unless $self->table;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->table 0 209 209
28  
29 209 $self;
30 }
31  
32 sub str
33 2272 ▶{
Subroutine str: called CC=1 SCAR=0.0
Pod undocumented
34 2272 my $self = shift;
35 2272 'Row : '. $self->{input_row} . ';';
36 }
37  
38 sub headers
39 129 ▶{
Subroutine headers: called CC=4 SCAR=14.0
Pod undocumented
40 129 my $self = shift;
41 129 my @list1 = $self->table->headers;
42 129 my @list2 = $self->output->headers;
43  
44 129 my %tmp;
45
46 129 $tmp{$_} = 1 for (@list1);
47  
48 129 my @list3 = grep({$tmp{$_}} @list2);
49  
50 129 ▶warn 'bug' unless @list3;
Branch: 1 branch
BranchTrueFalseTotal
unless @list3 0 129 129
51 129 ▶ return @list1 unless @list3;
Branch: 1 branch
BranchTrueFalseTotal
unless @list3 0 129 129
52  
53 129 return @list3;
54 }
55  
56 sub html_attribute_string
57 44 ▶{
Subroutine html_attribute_string: called CC=1 SCAR=0.0
Pod undocumented
58 44 my $self = shift;
59 44 my $ret = ' class="ende"';
60  
61 44 $ret;
62 }
63  
64 sub cells
65 189 ▶{
Subroutine cells: called CC=3 SCAR=11.0
Pod undocumented
66 189 my $self = shift;
67 189 my @ret = ();
68  
69 189 my @headers = $self->headers(@_);
70  
71 189 my $x = 0;
72 189 for my $header (@headers) {
73 1125 ▶ next unless $header;
Branch: 1 branch
BranchTrueFalseTotal
unless $header 0 1125 1125
74 1125 push(@ret,
75 Data::Tabular::Cell->new(
76 row => $self,
77 cell => $header,
78 colspan => $self->colspan($header),
79 id => $x++,
80 )
81 );
82 }
83 189 @ret;
84 }
85  
86 sub output
87 311 ▶{
Subroutine output: called CC=2 SCAR=7.2
Pod undocumented
88 311 my $self = shift;
89  
90 311 ▶ $self->{output} || die;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"output"} or die 311 0 311
91 }
92  
93 sub colspan
94 1045 ▶{
Subroutine colspan: called CC=1 SCAR=0.0
Pod undocumented
95 1045 1;
96 }
97  
98 sub table
99 3838 ▶{
Subroutine table: called CC=1 SCAR=0.0
Pod undocumented
100 3838 shift->{table};
101 }
102  
103 sub hdr
104 271 ▶{
Subroutine hdr: called CC=1 SCAR=0.0
Pod undocumented
105 }
106  
107 sub id
108 850 ▶{
Subroutine id: called CC=2 SCAR=7.2
Pod undocumented
109 850 my $self = shift;
110  
111 850 ▶ $self->{row_id} || 'No ID available';
Branch: 1 branch
BranchTrueFalseTotal
$self->{"row_id"} or "No ID available" 850 0 850
112 }
113  
114 sub cell_html_attributes
115 0 ▶{
Subroutine cell_html_attributes: not called CC=1 SCAR=6.9
Pod undocumented
116 {
117 0 align => undef,
118 };
119 }
120  
121 sub type
122 0 ▶{
Subroutine type: not called CC=1 SCAR=6.9
Pod undocumented
123 0 my $self = shift;
124 0 warn 'No type for ' . ref($self);
125 0 'unknown';
126 }
127  
128 64 ▶sub is_title { 0 };
Subroutine is_title: called CC=1 SCAR=0.0
Pod undocumented
129  
130 6 1;
131 __END__
« Tabular/Row/Data.pm ↑ Summary Tabular/Extra.pm »