Tabular/Table.pm

filter: Statementstmt 62.7% 32 / 51 Branchbran 40.0% 4 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 100% 4 / 4 totaltotal 59.4% 47 / 79 CC 10 SCAR 20.7
CC
10
Cov
58%
header_offset
20.0
new
7.7
headers
2.0
CRAP 7.9
« Tabular/Output/HTML.pm ↑ Summary Tabular/Table/Data.pm »
1 # Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Tabular::Table;
6  
7 8 ▶use Data::Tabular::Column;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Carp qw (croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use Data::Tabular::Config::Output;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub new
13 27 ▶{
Subroutine new: called CC=7 SCAR=20.4
Pod documented
14 27 my $caller = shift;
15 27 ▶ my $class = ref($caller) || $caller;
Condition33%1/3
ref $caller || $caller
l!l&&r!l&&!r
0270
MC/DC0%0/2
ref $caller || $caller
ref $caller $caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
ABresult
1X1
011
000
16 27 my $self = {};
17 27 my $args = { @_ };
18 27 my $old = {};
19  
20 27 ▶ if (my $table = $args->{table}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $table = $args->{"table"}) 18 9 27
21 18 for my $key (keys %$table) {
22 36 $old->{$key} = $table->{$key};
23 }
24 18 delete $args->{table};
25 }
26  
27 27 ▶ if (ref($caller)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $caller) 0 27 27
28 0 for my $key (keys %$caller) {
29 0 $old->{$key} = $caller->{$key};
30 }
31 }
32 27 $self = { %$old, %$args };
33 27 bless $self, $class;
34  
35 27 ▶ die unless $self->{data};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"data"} 0 27 27
36  
37 27 $self;
38 }
39  
40 sub headers
41 0 ▶{
Subroutine headers: not called CC=1 SCAR=6.9
Pod documented
42 0 my $self = shift;
43  
44 0 $self->{headers};
45 }
46  
47 sub columns
48 5 ▶{
Subroutine columns: called CC=1 SCAR=0.0
Pod documented
49 5 my $self = shift;
50  
51 5 my @headers = $self->headers;
52  
53 5 my $x = 0;
54 map({
55 5 Data::Tabular::Column->new(
56 @_,
57 offset => $x++,
58 name => $_,
59 );
60 } @headers);
61 }
62  
63 sub _title
64 0 ▶{
Subroutine _title: not called CC=1 SCAR=6.9
65 0 my $self = shift;
66 0 my $column_name = shift;
67 0 my $title = q|/|. $column_name . q|/|;
68  
69 0 warn "FIXME";
70 0 $title;
71 }
72  
73 sub header_offset
74 0 ▶{
Subroutine header_offset: not called CC=4 SCAR=30.0
Pod documented
75 0 my $self = shift;
76 0 my $column = shift;
77 0 my $count = 0;
78 0 ▶ unless ($self->{_header_off}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_header_off"}) 0 0 0
79 0 for my $header ($self->headers) {
80 0 $self->{_header_off}->{$header} = $count++;
81 }
82 }
83 0 my $ret = $self->{_header_off}->{$column};
84 croak "column '$column' not found in [",
85 join(" ",
86 0 ▶ sort keys(%{$self->{_header_off}})
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ret 0 0 0
87 ), ']' unless defined $ret;
88 0 $ret;
89 }
90  
91  
92 8 1;
93 __END__
« Tabular/Output/HTML.pm ↑ Summary Tabular/Table/Data.pm »