NAB/CSV.pm

filter: Statementstmt 95.2% 40 / 42 Branchbran 75.0% 3 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 2 totaltotal 89.0% 57 / 64 CC 5 SCAR 6.0
CC
5
Cov
94%
new_from_record
3.0
to_record
3.0
_record_type
2.0
CRAP 1.8
« NAB/BPAY/Payments/Results/DetailRecord.pm ↑ Summary NAB/Acknowledgement/Issue.pm »
1 package Business::NAB::CSV;
2 8 $Business::NAB::CSV::VERSION = '0.11';
3 # undocument abstract class for parsing/creating CSV lines
4 # mostly delegated to Text::CSV_XS
5  
6 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use feature qw/ signatures /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use autodie qw/ :all /;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use Carp qw/ croak /;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 8 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 ▶no warnings qw/ experimental::signatures /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 8 ▶use Text::CSV_XS qw/ csv /;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 0 ▶sub _record_type { croak( "You must define the _record_type method" ) }
Subroutine _record_type: not called CC=1 SCAR=6.9
19  
20 0 ▶sub _attributes { croak( "You must define the _attributes method" ) }
Subroutine _attributes: not called CC=1 SCAR=6.9
21  
22 24 ▶sub new_from_record ( $class, $line ) {
Subroutine new_from_record: called CC=3 SCAR=11.0
Pod undocumented
23  
24 24 ▶ my $aoh = csv(
Branch: 1 branch
BranchTrueFalseTotal
my $aoh = csv("in", \$line, "headers", ["record_type", $class->_attributes]) or croak("Text::CSV"->error_diag) 24 0 24
25 in => \$line,
26 headers => [ 'record_type', $class->_attributes ],
27 ) or croak( Text::CSV->error_diag );
28  
29 24 my $self = $class->new( my %record = $aoh->[ 0 ]->%* );
30  
31 22 ▶ if ( $record{ record_type } ne $self->_record_type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record{"record_type"} ne $self->_record_type) 5 17 22
32 5 croak( "unsupported record type (@{[ $record{record_type} ]})" );
33 }
34  
35 17 return $self;
36 }
37  
38 38 ▶sub to_record ( $self, $aoa = undef ) {
Subroutine to_record: called CC=3 SCAR=11.0
Pod undocumented
39  
40 $aoa //= [ [
41 38 ▶ map { $self->$_ }
Condition100%2/2
$aoa //= [[map({$self->$_;} "_record_type", $self->_attributes)]]
l!l
434
MC/DC100%1/1
$aoa //= [[map({$self->$_;} "_record_type", $self->_attributes)]]
$aoa
Truth table100%2/2
A
A= $aoa
Aresult
11
00
42 '_record_type', $self->_attributes,
43 ] ];
44  
45 38 csv(
46 in => $aoa,
47 out => \my $data,
48 quote_space => 0,
49 eol => '',
50 );
51  
52 38 return $data;
53 }
54  
55 8 1;
« NAB/BPAY/Payments/Results/DetailRecord.pm ↑ Summary NAB/Acknowledgement/Issue.pm »