ODS/Storage/Base.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 10 / 12 Conditioncond 53.8% 7 / 13 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 3 totaltotal 76.6% 59 / 77 CC 14 SCAR 19.2
CC
14
Cov
85%
into_rows
8.1
into_storage
7.8
BEGIN
1.0
CRAP 6.8
« ODS/Table/Column/Array.pm ↑ Summary ODS/Table/Column/Hash.pm »
1 package ODS::Storage::Base;
2  
3 72 ▶use YAOO;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 72 ▶use ODS::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 72 auto_build;
8  
9 72 has table => isa(object);
10  
11 72 has serialize_class => isa(object);
12  
13 sub connect {
14 142 ▶ my ($self, %params) = @_;
Subroutine connect: called CC=1 SCAR=0.0
Pod undocumented
15 142 $self = $self->new(%params);
16 142 return $self;
17 }
18  
19 sub into_rows {
20 1765 ▶ my ($self, $data, $inflated) = @_;
Subroutine into_rows: called CC=8 SCAR=20.9
Pod undocumented
21  
22 1765 ▶ $data = $self->parse_data_format($data)
Branch: 1 branch
BranchTrueFalseTotal
if not ref $data and $self->can("parse_data_format") 4 1761 1765
Condition66%2/3
not ref $data and $self->can("parse_data_format")
!ll&&!rl&&r
176104
MC/DC50%1/2
not ref $data and $self->can("parse_data_format")
not ref $data $self->can("parse_data_format")
Truth table66%2/3
not(A) and B
A= not ref $dataB= $self->can("parse_data_format")
ABresult
0X0
100
111
23 if (not ref $data and $self->can('parse_data_format'));
24  
25 1765 ▶ if (ref $data eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $data eq 'ARRAY') { } 46 1719 1765
elsif (ref $data eq 'HASH') { } 1718 1 1719
26 46 my @rows;
27 46 for my $row ( @{ $data } ) {
28 922 ▶ push @rows, $self->table->row_class->new(
Condition50%1/2
$inflated || 0
l!l
0922
MC/DC0%0/1
$inflated || 0
$inflated
Truth table50%1/2
A
A= $inflated
Aresult
11
00
29 table => $self->table,
30 data => $row,
31 inflated => $inflated || 0,
32 serialize_class => $self->serialize_class
33 );
34 }
35 46 $self->table->rows(\@rows);
36  
37 46 return ODS::Iterator->new(table => $self->table);
38 } elsif (ref $data eq 'HASH') {
39 1718 ▶ return $self->table->row_class->new(
Condition50%1/2
$inflated || 0
l!l
17180
MC/DC0%0/1
$inflated || 0
$inflated
Truth table50%1/2
A
A= $inflated
Aresult
11
00
40 table => $self->table,
41 data => $data,
42 inflated => $inflated || 0,
43 serialize_class => $self->serialize_class
44 );
45 }
46  
47 1 return undef;
48 }
49  
50 sub into_storage {
51 1728 ▶ my ($self, $all) = @_;
Subroutine into_storage: called CC=7 SCAR=20.5
Pod undocumented
52  
53 1728 my $data;
54 1728 ▶ if ($all && !ref $all) {
Branch: 2 branches
BranchTrueFalseTotal
if ($all and not ref $all) { } 12 1716 1728
elsif ($all) { } 1716 0 1716
Condition66%2/3
$all and not ref $all
!ll&&!rl&&r
0171612
MC/DC50%1/2
$all and not ref $all
$all not ref $all
Truth table66%2/3
A and not(B)
A= $allB= not ref $all
ABresult
0X0
100
111
55 12 for my $row (@{ $self->table->rows }) {
56 44 my $val = $row->store_row();
57 44 push @{$data}, $val;
58 }
59 } elsif ($all) {
60 1716 $data = $all->store_row();
61 } else {
62 0 $data = $self->table->rows->[-1]->store_row();
63 }
64  
65 1728 ▶ $data = $self->stringify_data_format($data)
Branch: 1 branch
BranchTrueFalseTotal
if ref $data and $self->can("stringify_data_format") 1728 0 1728
Condition33%1/3
ref $data and $self->can("stringify_data_format")
!ll&&!rl&&r
001728
MC/DC0%0/2
ref $data and $self->can("stringify_data_format")
ref $data $self->can("stringify_data_format")
Truth table33%1/3
A and B
A= ref $dataB= $self->can("stringify_data_format")
ABresult
0X0
100
111
66 if (ref $data and $self->can('stringify_data_format'));
67  
68 1728 return $data;
69 }
70  
71 72 1;
72  
« ODS/Table/Column/Array.pm ↑ Summary ODS/Table/Column/Hash.pm »