Tabular/Cell.pm

filter: Statementstmt 40.7% 35 / 86 Branchbran 19.5% 9 / 46 Conditioncond 21.4% 3 / 14 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 64.7% 11 / 17 Podpod 0.0% 0 / 15 totaltotal 31.7% 59 / 186 CC 30 SCAR 34.1
CC
30
Cov
32%
html_attribute_string
90.0
xls_string
42.0
xls_type
30.0
CRAP 30.2
↑ Summary Tabular/Output/XLS.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::Cell;
6  
7 6 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #use overload '""' => \&str;
10  
11 sub new
12 1259 ▶{
Subroutine new: called CC=4 SCAR=15.0
Pod undocumented
13 1259 my $class = shift;
14  
15 1259 my $args = { @_ };
16  
17 1259 ▶ die "No row" unless ref $args->{row};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args->{"row"} 0 1259 1259
18 1259 ▶ die "No cell" unless ref $args->{cell} || defined $args->{cell};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args->{"cell"} or defined $args->{"cell"} 0 1259 1259
Condition33%1/3
ref $args->{"cell"} or defined $args->{"cell"}
l!l&&r!l&&!r
012590
MC/DC0%0/2
ref $args->{"cell"} or defined $args->{"cell"}
ref $args->{"cell"} defined $args->{"cell"}
Truth table33%1/3
A or B
A= ref $args->{"cell"}B= defined $args->{"cell"}
ABresult
1X1
011
000
19  
20 1259 my $self = bless($args, $class);
21  
22 1259 $self;
23 }
24  
25 sub row_id
26 440 ▶{
Subroutine row_id: called CC=1 SCAR=0.0
Pod undocumented
27 440 my $self = shift;
28 440 $self->row->id() - 1;
29 }
30  
31 sub col_id
32 1344 ▶{
Subroutine col_id: called CC=1 SCAR=0.0
Pod undocumented
33 1344 my $self = shift;
34 1344 $self->{id};
35 }
36  
37 sub row
38 440 ▶{
Subroutine row: called CC=1 SCAR=0.0
Pod undocumented
39 440 my $self = shift;
40 440 $self->{row};
41 }
42  
43 sub data
44 988 ▶{
Subroutine data: called CC=1 SCAR=0.0
Pod undocumented
45 988 my $self = shift;
46  
47 988 my $ret = $self->{row}->get_column($self->{cell});
48  
49 988 return $ret;
50 }
51  
52 sub str
53 0 ▶{
Subroutine str: not called CC=1 SCAR=6.9
Pod undocumented
54 0 my $self = shift;
55 0 die "STR " . caller;
56 0 'Cell : '. $self->{cell} . ' ' . $self->html_string;
57 }
58  
59 sub html_string
60 271 ▶{
Subroutine html_string: called CC=9 SCAR=27.2
Pod undocumented
61 271 my $self = shift;
62  
63 271 ▶ my $ret = $self->{row}->get_column($self->{cell}) || '';
Condition100%2/2
$self->{'row'}->get_column($self->{'cell'}) || ''
l!l
2674
MC/DC100%1/1
$self->{'row'}->get_column($self->{'cell'}) || ''
$self->{'row'}->get_column($self->{'cell'})
Truth table100%2/2
A
A= $self->{'row'}->get_column($self->{'cell'})
Aresult
11
00
64 271 ▶ if (my $type = ref($ret)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = ref $ret) { } 267 4 271
65 267 ▶ if ($type eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'HASH') { } 0 267 267
elsif ($type eq 'ARRAY') { } 0 267 267
66 0 ▶ $ret = $ret->{html} || $ret->{text} || $ret->{data};
Condition0%0/6
$ret->{'html'} || $ret->{'text'} || $ret->{'data'}
l!l&&r!l&&!r
000
$ret->{"html"} or $ret->{"text"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ret->{'html'} || $ret->{'text'} || $ret->{'data'}
$ret->{"html"} $ret->{"text"} $ret->{'data'}
Truth table0%0/4
A or B || C
A= $ret->{"html"}B= $ret->{"text"}C= $ret->{'data'}
ABCresult
1XX1
01X1
0011
0000
67 } elsif ($type eq 'ARRAY') {
68 0 die 'XXXXX';
69 } else {
70 267 ▶ if ($ret->can('bob')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->can('bob')) { } 0 267 267
71 # we just use it;
72 } else {
73 # we just use it;
74 }
75 }
76 } else {
77 # $ret;
78 }
79  
80 271 ▶ length($ret) ? $ret : ' '; # This is wrong FIXME
Branch: 1 branch
BranchTrueFalseTotal
length $ret ? : 267 4 271
81 }
82  
83 sub colspan
84 288 ▶{
Subroutine colspan: called CC=1 SCAR=0.0
Pod undocumented
85 288 my $self = shift;
86  
87 288 my $colspan = $self->{colspan};
88  
89 288 return $colspan;
90 }
91  
92 sub html_attribute_string
93 0 ▶{
Subroutine html_attribute_string: not called CC=9 SCAR=45.0
Pod undocumented
94 0 my $self = shift;
95 0 my $row = $self->{row};
96 0 my $header = $self->{cell};
97 0 my $data = $self->{row}->get_column($self->{cell});
98 0 my $colspan = $self->{colspan};
99 0 warn join ' ', caller;
100 0 my $attributes = $row->cell_html_attributes($self);
101  
102 0 ▶ if ($colspan > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($colspan > 1) 0 0 0
103 0 $attributes->{colspan} = $colspan,
104 }
105  
106 0 ▶ if (my $type = ref($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = ref $data) 0 0 0
107 0 ▶ if ({
Branch: 1 branch
BranchTrueFalseTotal
if ({'HASH', 1, 'ARRAY', 1, 'CODE', 1}->{$type}) { } 0 0 0
108 HASH => 1,
109 ARRAY => 1,
110 CODE => 1,
111 }->{$type}) {
112 0 ▶ if ($type eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "HASH") 0 0 0
113 0 $attributes->{bgcolor} = $data->{bgcolor};
114 }
115 # don't do anything
116 } else {
117 0 ▶ if ($data->can('attributes')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->can('attributes')) { } 0 0 0
118 $attributes = {
119 %$attributes,
120 0 %{$data->attributes()},
121 }
122 } else {
123 0 warn 'no attributes ', ref($data);
124 }
125 }
126 }
127 0 ▶ if ($self->{bgcolor}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"bgcolor"}) 0 0 0
128 0 $attributes->{bgcolor} = $self->{bgcolor};
129 }
130  
131 0 my $ret = ''; # FIXME
132 0 for my $attribute (sort keys %$attributes) {
133 0 ▶ next unless defined($attributes->{$attribute});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $attributes->{$attribute} 0 0 0
134 0 $ret .= qq| $attribute="| . $attributes->{$attribute} . qq|"|;
135 }
136  
137 0 $ret;
138 }
139  
140 sub hdr
141 288 ▶{
Subroutine hdr: called CC=1 SCAR=0.0
Pod undocumented
142 288 my $self = shift;
143 288 $self->{row}->hdr;
144 }
145  
146 sub name
147 0 ▶{
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
148 0 my $self = shift;
149 0 my $cell = $self->{cell};
150  
151 0 $cell;
152 }
153  
154 sub xls_type
155 0 ▶{
Subroutine xls_type: not called CC=5 SCAR=34.0
Pod undocumented
156 0 my $self = shift;
157  
158 0 my $cell = $self->{row}->get_column($self->{cell});
159 0 my $ret = 'text';
160 0 ▶ if (my $type = ref($cell)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = ref $cell) 0 0 0
161 0 ▶ if ($type eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'HASH') { } 0 0 0
elsif ($type eq 'ARRAY') { } 0 0 0
162 } elsif ($type eq 'ARRAY') {
163 } else {
164 0 ▶ if ($cell->can('type')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cell->can('type')) { } 0 0 0
165 0 $ret = $cell->type;
166 } else {
167 # we just use it;
168 }
169 }
170 }
171 0 $ret;
172 }
173  
174 sub xls_string
175 0 ▶{
Subroutine xls_string: not called CC=6 SCAR=37.4
Pod undocumented
176 0 my $self = shift;
177  
178 0 my $ret = $self->{row}->get_column($self->{cell});
179 0 ▶ if (my $type = ref($ret)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = ref $ret) 0 0 0
180 0 ▶ if ($type eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'HASH') { } 0 0 0
elsif ($type eq 'ARRAY') { } 0 0 0
181 0 ▶ $ret = $ret->{html} || $ret->{text};
Condition0%0/3
$ret->{'html'} || $ret->{'text'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ret->{'html'} || $ret->{'text'}
$ret->{'html'} $ret->{'text'}
Truth table0%0/3
A || B
A= $ret->{'html'}B= $ret->{'text'}
ABresult
1X1
011
000
182 } elsif ($type eq 'ARRAY') {
183 0 die 'XXXXX';
184 } else {
185 0 ▶ if ($ret->can('xls_data')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->can('xls_data')) { } 0 0 0
186 # we just use it;
187 0 $ret = $ret->xls_data();
188 } else {
189 # we just use it;
190 }
191 }
192 }
193 0 $ret;
194 }
195  
196 sub column_name
197 288 ▶{
Subroutine column_name: called CC=1 SCAR=0.0
Pod undocumented
198 288 my $self = shift;
199  
200 288 $self->{cell};
201 }
202  
203 sub type
204 0 ▶{
Subroutine type: not called CC=2 SCAR=17.9
Pod undocumented
205 0 my $self = shift;
206  
207 0 ▶ $self->{type} || 'normal';
Branch: 1 branch
BranchTrueFalseTotal
$self->{"type"} or "normal" 0 0 0
208 }
209  
210  
211 6 1;
212 __END__
↑ Summary Tabular/Output/XLS.pm »