lib/MAB2/Writer/Disk.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 51 / 51 CC 6 SCAR 13.2
CC
6
Cov
100%
_write_record
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« lib/MAB2/Writer/RAW.pm ↑ Summary lib/MAB2/Writer/Handle.pm »
1 package MAB2::Writer::Disk;
2  
3 3 our $VERSION = '0.24';
4  
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use charnames ':full';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 with 'MAB2::Writer::Handle';
11  
12 has subfield_indicator => (
13 is => 'rw',
14 2 ▶ default => sub { qq{\N{INFORMATION SEPARATOR ONE}} }
Subroutine __ANON__: called CC=1 SCAR=0.0
15 3 );
16  
17  
18 3 Readonly my $END_OF_FIELD => qq{\N{LINE FEED}};
19 3 Readonly my $END_OF_RECORD => qq{\N{LINE FEED}};
20  
21  
22 6 ▶sub _write_record {
Subroutine _write_record: called CC=6 SCAR=17.9
23 6 my ( $self, $record ) = @_;
24 6 my $fh = $self->fh;
25 6 my $SUBFIELD_INDICATOR = $self->subfield_indicator;
26  
27 6 ▶ if ( $record->[0][0] eq 'LDR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->[0][0] eq 'LDR') { } 2 4 6
28 2 my $leader = $record->[0];
29 2 print $fh "### ", $leader->[3], $END_OF_FIELD;
30 }
31 else {
32 # set default record leader
33 4 print $fh "### 99999nM2.01200024 h", $END_OF_FIELD;
34 }
35  
36 6 foreach my $field (@$record) {
37 14 ▶ next if $field->[0] eq 'LDR';
Branch: 1 branch
BranchTrueFalseTotal
if $field->[0] eq "LDR" 2 12 14
38 12 ▶ if ( $field->[2] eq '_' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($field->[2] eq '_') { } 6 6 12
39 6 print $fh $field->[0], $field->[1], $field->[3], $END_OF_FIELD;
40 }
41 else {
42 6 print $fh $field->[0], $field->[1];
43 6 ▶ for ( my $i = 2; $i < scalar @$field; $i += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$field) 9 6 15
44 9 my $subfield_code = $field->[ $i ];
45 9 my $value = $field->[ $i + 1 ];
46 9 print $fh $SUBFIELD_INDICATOR, $subfield_code, $value;
47 }
48 6 print $fh $END_OF_FIELD;
49 }
50 }
51 6 print $fh $END_OF_RECORD;
52 }
53  
54  
55 3 1;
56  
57 __END__
« lib/MAB2/Writer/RAW.pm ↑ Summary lib/MAB2/Writer/Handle.pm »