Importer/MARC/Decoder.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 83.3% 10 / 12 Conditioncond 80.0% 8 / 10 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 86.5% 58 / 67 CC 13 SCAR 23.9
CC
13
Cov
91%
decode
13.2
BEGIN
1.0
BEGIN
1.0
CRAP 11.0
« Exporter/MARC/MARCMaker.pm ↑ Summary Fix/Inline/marc_map.pm »
1 package Catmandu::Importer::MARC::Decoder;
2  
3 34 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 34 our $VERSION = '1.33';
7  
8 166 ▶sub fake_marc_file {
Subroutine fake_marc_file: called CC=1 SCAR=0.0
Pod undocumented
9 166 my ($self,$fh,$class) = @_;
10  
11 166 my $obj = {
12 filename => scalar($fh),
13 fh => $fh,
14 recnum => 0,
15 warnings => [],
16 };
17  
18 166 return( bless $obj , $class );
19 }
20  
21 338 ▶sub decode {
Subroutine decode: called CC=13 SCAR=25.8
Pod undocumented
22 338 my ($self, $record, $id) = @_;
23 338 ▶ return unless eval { $record->isa('MARC::Record') };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $record->isa("MARC::Record") } } 20 318 338
24 318 my @result = ();
25  
26 318 push @result , [ 'LDR' , ' ', ' ' , '_' , $record->leader ];
27  
28 318 for my $field ($record->fields()) {
29 3883 my $tag = $field->tag;
30 3883 ▶ my $ind1 = $field->indicator(1) // ' ';
Condition100%2/2
$field->indicator(1) // " "
l!l
3221662
MC/DC100%1/1
$field->indicator(1) // " "
$field->indicator(1)
Truth table100%2/2
A
A= $field->indicator(1)
Aresult
11
00
31 3883 ▶ my $ind2 = $field->indicator(2) // ' ';
Condition100%2/2
$field->indicator(2) // " "
l!l
3221662
MC/DC100%1/1
$field->indicator(2) // " "
$field->indicator(2)
Truth table100%2/2
A
A= $field->indicator(2)
Aresult
11
00
32  
33 3883 my @sf = ();
34  
35 3883 ▶ if ($field->is_control_field) {
Branch: 1 branch
BranchTrueFalseTotal
if ($field->is_control_field) 662 3221 3883
36 662 push @sf , '_', $field->data;
37 }
38  
39 3883 for my $subfield ($field->subfields) {
40 5540 push @sf , @$subfield;
41 }
42  
43 3883 push @result, [$tag,$ind1,$ind2,@sf];
44 }
45  
46 318 my $sysid = undef;
47  
48 318 ▶ if ($id =~ /^00/ && $record->field($id)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($id =~ /^00/ and $record->field($id)) { } 179 139 318
elsif ($id =~ /^([0-9]{3})([[0-9a-zA-Z])$/) { } 10 129 139
elsif (defined $id and $record->field($id)) { } 0 129 129
Condition100%3/3
$id =~ /^00/ and $record->field($id)
!ll&&!rl&&r
10129179
MC/DC100%2/2
$id =~ /^00/ and $record->field($id)
$id =~ /^00/ $record->field($id)
Truth table100%3/3
A and B
A= $id =~ /^00/B= $record->field($id)
ABresult
0X0
100
111
49 179 $sysid = $record->field($id)->data();
50 }
51 elsif ($id =~ /^([0-9]{3})([[0-9a-zA-Z])$/) {
52 10 my $field = $record->field($1);
53 10 ▶ $sysid = $field->subfield($2) if ($field);
Branch: 1 branch
BranchTrueFalseTotal
if $field 10 0 10
54 }
55 ▶ elsif (defined $id && $record->field($id)) {
Condition33%1/3
defined $id and $record->field($id)
!ll&&!rl&&r
01290
MC/DC0%0/2
defined $id and $record->field($id)
defined $id $record->field($id)
Truth table33%1/3
A and B
A= defined $idB= $record->field($id)
ABresult
0X0
100
111
56 0 $sysid = $record->field($id)->subfield("a");
57 }
58  
59 318 return { _id => $sysid , record => \@result };
60 }
61  
62 34 1;
« Exporter/MARC/MARCMaker.pm ↑ Summary Fix/Inline/marc_map.pm »