lib/Spreadsheet/Reader/ExcelXML/Row.pm

filter: Statementstmt 100% 66 / 66 Branchbran 85.7% 12 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 100% 3 / 3 totaltotal 97.9% 94 / 96 CC 9 SCAR 10.4
CC
9
Cov
98%
get_the_column
6.0
get_the_next_value_position
3.0
get_row_all
2.0
CRAP 2.8
« lib/Spreadsheet/Reader/ExcelXML/Cell.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/Types.pm »
1 package Spreadsheet::Reader::ExcelXML::Row;
2 19 our $AUTHORITY = 'cpan:JANDREW';
3 19 ▶use version; our $VERSION = version->declare('v0.16.8');
Subroutine BEGIN: called CC=1 SCAR=0.0
4 ###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::ExcelXML::Row-$VERSION";
5  
6 19 $| = 1;
7 19 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 19 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 19 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 19 ▶use MooseX::HasDefaults::RO;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 19 ▶use Carp qw( confess );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 19 ▶use Clone qw( clone );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 19 ▶use Types::Standard qw( ArrayRef Int Bool HashRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 19 ▶use lib '../../../../../lib';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 ###LogSD use Log::Shiras::Telephone;
16  
17 ###LogSD with 'Log::Shiras::LogSpace';
18 ###LogSD sub get_class_space{ 'Row' }
19  
20 #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9
21  
22 19 has row_number =>(
23 isa => Int,
24 reader => 'get_row_number',
25 required => 1,
26 );
27  
28 19 has row_span =>(
29 isa => ArrayRef[ Int ],
30 traits => ['Array'],
31 writer => 'set_row_span',
32 predicate => 'has_row_span',
33 required => 1,
34 handles =>{
35 get_row_start => [ 'get' => 0 ],
36 get_row_end => [ 'get' => 1 ],
37 },
38 );
39  
40 19 has row_last_value_column =>(
41 isa => Int,
42 reader => 'get_last_value_column',
43 );
44  
45 19 has row_formats =>(
46 isa => HashRef,
47 traits => ['Hash'],
48 writer => 'set_row_formts',
49 handles =>{
50 get_row_format => 'get',
51 },
52 );
53  
54 19 has column_to_cell_translations =>(
55 isa => ArrayRef,
56 traits =>[ 'Array' ],
57 handles =>{
58 get_position_for_column => 'get',
59 },
60 );
61  
62 19 has row_value_cells =>(
63 isa => ArrayRef,
64 traits =>[ 'Array' ],
65 reader => 'get_row_value_cells',
66 handles =>{
67 get_cell_position => 'get',
68 total_cell_positions => 'count',
69 },
70 );
71  
72 #########1 Public Methods 3#########4#########5#########6#########7#########8#########9
73  
74 295 ▶sub get_the_column{
Subroutine get_the_column: called CC=6 SCAR=18.0
Pod documented
75 295 my ( $self, $desired_column ) = @_;
76 295 ▶ confess "Desired column required" if !defined $desired_column;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $desired_column 0 295 295
77 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
78 ###LogSD ($self->get_all_space . '::get_the_column' ), );
79 ###LogSD $phone->talk( level => 'debug', message =>[
80 ###LogSD "Getting the cell value at column: $desired_column", ] );
81 295 my $max_column = $self->get_row_end;
82 295 ▶ if( $desired_column > $max_column ){
Branch: 1 branch
BranchTrueFalseTotal
if ($desired_column > $max_column) 13 282 295
83 ###LogSD $phone->talk( level => 'debug', message =>[
84 ###LogSD "Requested column -$desired_column- is past the end of the row", ] );
85 13 return 'EOR';
86 }
87 282 my $value_position = $self->get_position_for_column( $desired_column );
88 282 ▶ if( !defined $value_position ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value_position) 92 190 282
89 ###LogSD $phone->talk( level => 'debug', message =>[
90 ###LogSD "No cell value stored for column: $desired_column",
91 ###LogSD "..against final column: " . $self->get_row_end,
92 ###LogSD "..and last data column: " . $self->get_last_value_column ] );
93 92 ▶ my $return =
Branch: 2 branches
BranchTrueFalseTotal
$desired_column > $self->get_row_end ? : 0 92 92
$desired_column > $self->get_last_value_column ? : 58 34 92
94 $desired_column > $self->get_row_end ? 'EOR' :
95 $desired_column > $self->get_last_value_column ? 'EOD' : undef;
96 92 return $return;
97 }
98 190 my $return_cell = $self->get_cell_position( $value_position );
99 ###LogSD $phone->talk( level => 'warn', message =>[
100 ###LogSD "Returning the cell position: $value_position", $return_cell, ] );
101 190 $self->_set_reported_position( $value_position );
102 190 return clone( $return_cell );
103 }
104  
105 101 ▶sub get_the_next_value_position{
Subroutine get_the_next_value_position: called CC=3 SCAR=11.0
Pod documented
106 101 my ( $self, ) = @_;
107 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
108 ###LogSD ($self->get_all_space . '::get_the_next_value_column' ), );
109 ###LogSD $phone->talk( level => 'debug', message =>[
110 ###LogSD "Returning the next value position in this row as available", ] );
111 101 ▶ my $next_position = defined $self->_get_reported_position ? ($self->_get_reported_position + 1) : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->_get_reported_position ? : 73 28 101
112 ###LogSD $phone->talk( level => 'debug', message =>[
113 ###LogSD "Searching for position: $next_position" ] );
114 101 ▶ if( $next_position == $self->total_cell_positions ){# Counting from zero vs counting from 1
Branch: 1 branch
BranchTrueFalseTotal
if ($next_position == $self->total_cell_positions) 28 73 101
115 ###LogSD $phone->talk( level => 'debug', message =>[
116 ###LogSD "Already reported the last value position" ] );
117 28 return 'EOR';
118 }
119 73 my $return_cell = $self->get_cell_position( $next_position );
120 73 $self->_set_reported_position( $next_position );
121 #~ $self->_set_reported_column( $return_cell->{cell_col} );
122 #~ $self->_set_reported_position( $next_position );
123 ###LogSD $phone->talk( level => 'debug', message =>[
124 ###LogSD "Returning the cell:", $return_cell, ] );
125 73 return clone( $return_cell );
126 }
127  
128 111 ▶sub get_row_all{
Subroutine get_row_all: called CC=2 SCAR=6.9
Pod documented
129 111 my ( $self, ) = @_;
130 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
131 ###LogSD ($self->get_all_space . '::get_row_all' ), );
132 ###LogSD $phone->talk( level => 'debug', message =>[
133 ###LogSD "Getting an array ref of all the cells in the row by column position - counting from 0", ] );
134  
135 111 my $return_ref;
136 111 for my $cell ( @{$self->get_row_value_cells} ){
137 354 $return_ref->[$cell->{cell_col} - 1] = clone $cell;
138 }
139 ###LogSD $phone->talk( level => 'debug', message =>[
140 ###LogSD "Returning the row ref:", $return_ref, ] );
141 111 return $return_ref;
142 }
143  
144 #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9
145  
146 19 has _reported_position =>(
147 isa => Int,
148 reader => '_get_reported_position',
149 writer => '_set_reported_position',
150 );
151  
152 #########1 Private Methods 3#########4#########5#########6#########7#########8#########9
153  
154  
155  
156 #########1 Phinish 3#########4#########5#########6#########7#########8#########9
157  
158 19 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
159 19 __PACKAGE__->meta->make_immutable;
160  
161 19 1;
162  
163 #########1 Documentation 3#########4#########5#########6#########7#########8#########9
164 __END__
« lib/Spreadsheet/Reader/ExcelXML/Cell.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/Types.pm »