| 1 | # Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | package | ||||||||||||||||||||||||||||||||||||||||||
| 5 | Data::Tabular::Row::Function; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use base 'Data::Tabular::Row'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Carp qw(croak carp); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 20 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 20 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 20 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | ▶ | die unless $self->table; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 20 | ▶ | die "Need sum_list" unless $self->{sum_list}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 20 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | sub cells | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 20 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cells: called CC=20 SCAR=30.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 20 | my @ret = (); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 20 | my @headers = $self->headers(); | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 20 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 20 | my $hash; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 20 | ▶ | for my $x ( @{$self->{sum_list} || []} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'sum_list'} || []
MC/DC0%0/1
$self->{'sum_list'} || []
$self->{'sum_list'}
Truth table50%1/2
A
A= $self->{'sum_list'}
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 94 | $hash->{$x} = { sum => 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 20 | my $start; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 20 | my $x = 0; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 20 | my $state = 0; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 20 | my $cols = 1; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 20 | ▶ | while (my $column_name = shift @headers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 222 | ▶ | if ($state == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 30 | ▶ | if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name and $hash->{$column_name}
MC/DC33%1/3
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name
$hash->{$column_name}
$hash->{$column_name}{"sum"}
Truth table50%2/4
A and B and C
A= $column_nameB= $hash->{$column_name}C= $hash->{$column_name}{"sum"}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 10 | push(@ret, | |||||||||||||||||||||||||||||||||||||||||
| 42 | Data::Tabular::Cell->new( | ||||||||||||||||||||||||||||||||||||||||||
| 43 | row => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | cell => $column_name, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | colspan => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | id => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 20 | $state++; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 222 | ▶ | if ($state == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 80 | ▶ | if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name and $hash->{$column_name}
MC/DC33%1/3
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name
$hash->{$column_name}
$hash->{$column_name}{"sum"}
Truth table50%2/4
A and B and C
A= $column_nameB= $hash->{$column_name}C= $hash->{$column_name}{"sum"}
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 20 | push(@ret, | |||||||||||||||||||||||||||||||||||||||||
| 56 | Data::Tabular::Cell->new( | ||||||||||||||||||||||||||||||||||||||||||
| 57 | row => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | cell => '_description', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | colspan => $cols - 1, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | id => $x - ($cols - 1), | ||||||||||||||||||||||||||||||||||||||||||
| 61 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 20 | $cols = 1; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 20 | $state++; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 60 | $cols++; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 222 | ▶ | if ($state == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 152 | ▶ | if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name and $hash->{$column_name}
MC/DC33%1/3
$column_name and $hash->{$column_name} and $hash->{$column_name}{"sum"}
$column_name
$hash->{$column_name}
$hash->{$column_name}{"sum"}
Truth table50%2/4
A and B and C
A= $column_nameB= $hash->{$column_name}C= $hash->{$column_name}{"sum"}
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 84 | ▶ | if ($cols > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 18 | push(@ret, | |||||||||||||||||||||||||||||||||||||||||
| 73 | Data::Tabular::Cell->new( | ||||||||||||||||||||||||||||||||||||||||||
| 74 | row => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | cell => '_filler', | ||||||||||||||||||||||||||||||||||||||||||
| 76 | colspan => $cols - 1, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | id => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 18 | $cols = 1; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 84 | push(@ret, | |||||||||||||||||||||||||||||||||||||||||
| 83 | Data::Tabular::Cell->new( | ||||||||||||||||||||||||||||||||||||||||||
| 84 | row => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | cell => $column_name, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | colspan => $cols, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | id => $x, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 84 | $cols = 1; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 68 | $cols++; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 222 | ▶ | die if ($state >= 3); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 222 | $x++; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 20 | ▶ | if ($cols > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | push(@ret, | |||||||||||||||||||||||||||||||||||||||||
| 100 | Data::Tabular::Cell->new( | ||||||||||||||||||||||||||||||||||||||||||
| 101 | row => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | cell => '_filler', | ||||||||||||||||||||||||||||||||||||||||||
| 103 | colspan => $cols, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | id => $x - 1, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | $cols = 1; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 20 | ▶ | die $cols if $cols > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 20 | @ret; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | sub sum_list | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 114 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sum_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 114 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 114 | $self->{sum_list}; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | sub get_column | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_column: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | die 'Virtual'; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | sub extra_column | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extra_column: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $row = shift; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | die "EXTRA"; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $extra = $self->{extra}->{columns}; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $ret = undef; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $x = $self->extra_package->new(row => $row, table => $self); | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (ref($extra->{$key}) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $ret = $extra->{$key}->($x); | |||||||||||||||||||||||||||||||||||||||||
| 140 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | die $@; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | die 'only know how to deal with code'; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $ret; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||||||||||||||||||