Tabular/Extra.pm

filter: Statementstmt 83.3% 35 / 42 Branchbran 58.3% 7 / 12 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 71.4% 5 / 7 Podpod 80.0% 4 / 5 totaltotal 75.3% 52 / 69 CC 11 SCAR 13.5
CC
11
Cov
77%
new
6.4
sum
3.1
get
3.0
CRAP 3.9
« Tabular/Row.pm ↑ Summary Tabular/Config/Extra.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 package
5 Data::Tabular::Extra;
6  
7 sub new
8 418 ▶{
Subroutine new: called CC=6 SCAR=18.6
Pod documented
9 418 my $class = shift;
10 418 my $args = {@_};
11 418 my $self = bless {}, $class;
12  
13 418 for my $arg (qw (row table)) {
14 836 ▶ $self->{$arg} = $args->{$arg} || die 'No ' . $arg;
Condition50%1/2
$args->{$arg} || die('No ' . $arg)
l!l
8360
MC/DC0%0/1
$args->{$arg} || die('No ' . $arg)
$args->{$arg}
Truth table50%1/2
A
A= $args->{$arg}
Aresult
11
00
15 836 delete $args->{$arg};
16 }
17 418 ▶ die q|Unknown argumet(s): |. join(' ', keys(%$args)) if keys(%$args);
Branch: 1 branch
BranchTrueFalseTotal
if keys %$args 0 418 418
18  
19 418 ▶ die unless $self->{row};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"row"} 0 418 418
20 418 ▶ die unless $self->{table};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"table"} 0 418 418
21  
22 418 $self;
23 }
24  
25 sub get
26 16 ▶{
Subroutine get: called CC=3 SCAR=11.0
Pod documented
27 16 my $self = shift;
28  
29 16 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 4 12 16
30 4 map({$self->{row}->get_column($_)} @_);
31 } else {
32 12 ▶ carp("only one column allowed in scalar context.") if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 12 12
33 12 $self->{row}->get_column(shift);
34 }
35 }
36  
37 sub sum
38 33 ▶{
Subroutine sum: called CC=3 SCAR=11.4
Pod documented
39 33 my $self = shift;
40 33 my $total = 0;
41  
42 33 for my $column (@_) {
43 66 my $data = $self->{row}->get_column($column);
44 66 ▶ if (ref($data) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "HASH") 0 66 66
45 0 die;
46 0 $data = $data->{html};
47 }
48  
49 66 $total += $data;
50 }
51  
52 33 require Data::Tabular::Type::Formula;
53  
54 33 Data::Tabular::Type::Formula->new(
55 data => $total,
56 columns => [ @_ ],
57 type => 'sum',
58 );
59 }
60  
61 sub average
62 33 ▶{
Subroutine average: called CC=2 SCAR=6.9
Pod documented
63 33 my $self = shift;
64 33 my $count = scalar(@_);
65  
66 33 my $total = 0;
67  
68 33 for my $column (@_) {
69 66 $total += $self->{row}->get_column($column);
70 }
71  
72 33 require Data::Tabular::Type::Formula;
73  
74 33 Data::Tabular::Type::Formula->new(
75 data => $total / $count,
76 columns => [ @_ ],
77 type => 'average',
78 );
79 }
80  
81 sub row_id
82 0 ▶{
Subroutine row_id: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my $self = shift;
84  
85 0 $self->{row}{row_id};
86 }
87  
88 sub _new_cell
89 0 ▶{
Subroutine _new_cell: not called CC=1 SCAR=6.9
90 0 my $self = shift;
91 0 my $args = { @_ };
92  
93 0 $args
94 }
95  
96 8 1;
97 __END__
« Tabular/Row.pm ↑ Summary Tabular/Config/Extra.pm »