blib/lib/PICA/Parser/Plus.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 6 / 6 Conditioncond 100% 7 / 7 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 95.4% 63 / 66 CC 8 SCAR 15.5
CC
8
Cov
100%
_next_record
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.7
« blib/lib/PICA/Parser/PPXML.pm ↑ Summary blib/lib/PICA/Writer/Generic.pm »
1 package PICA::Parser::Plus;
2 8 ▶use v5.14.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 8 our $VERSION = '1.18';
5  
6 8 ▶use charnames qw(:full);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use parent 'PICA::Parser::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 64 ▶sub SUBFIELD_INDICATOR {"\N{INFORMATION SEPARATOR ONE}"}
Subroutine SUBFIELD_INDICATOR: called CC=1 SCAR=0.0
Pod undocumented
12 7 ▶sub END_OF_FIELD {"\N{INFORMATION SEPARATOR TWO}"}
Subroutine END_OF_FIELD: called CC=1 SCAR=0.0
Pod undocumented
13 9 ▶sub END_OF_RECORD {"\N{LINE FEED}"}
Subroutine END_OF_RECORD: called CC=1 SCAR=0.0
Pod undocumented
14  
15 sub _next_record {
16 17 ▶ my ($self) = @_;
Subroutine _next_record: called CC=8 SCAR=20.8
17  
18 # TODO: does only work if END_OF_RECORD is LINE FEED
19 17 local $/ = $self->END_OF_RECORD;
20 17 ▶ my $line = $self->{reader}->getline // return;
Condition100%2/2
$self->{"reader"}->getline // (return)
l!l
143
MC/DC100%1/1
$self->{"reader"}->getline // (return)
$self->{"reader"}->getline
Truth table100%2/2
A
A= $self->{"reader"}->getline
Aresult
11
00
21 14 chomp $line;
22  
23 14 my @fields = split $self->END_OF_FIELD, $line;
24 14 my @record;
25  
26 14 ▶ if (@fields and index($fields[0], $self->SUBFIELD_INDICATOR) == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@fields and index($fields[0], $self->SUBFIELD_INDICATOR) == -1) 8 6 14
Condition100%3/3
@fields and index($fields[0], $self->SUBFIELD_INDICATOR) == -1
!ll&&!rl&&r
338
MC/DC100%2/2
@fields and index($fields[0], $self->SUBFIELD_INDICATOR) == -1
@fields index($fields[0], $self->SUBFIELD_INDICATOR) == -1
Truth table100%3/3
A and B
A= @fieldsB= index($fields[0], $self->SUBFIELD_INDICATOR) == -1
ABresult
0X0
100
111
27  
28 # drop leader because usage is unclear
29 8 shift @fields;
30 }
31  
32 14 foreach my $field (@fields) {
33 116 my ($tag, $occurence, $data);
34 116 ▶ if ($field =~ m/^(\d{3}[A-Z@])(\/(\d{2,3}))?\s(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($field =~ m[^(\d{3}[A-Z\@])(/(\d{2,3}))?\s(.+)]u) { } 112 4 116
35 112 $tag = $1;
36 112 ▶ $occurence = $3 // '';
Condition100%2/2
$3 // ""
l!l
3973
MC/DC100%1/1
$3 // ""
$3
Truth table100%2/2
A
A= $3
Aresult
11
00
37 112 $data = $4;
38 }
39 else {
40 4 ▶ if ($self->{strict}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'strict'}) { } 1 3 4
41 1 croak "ERROR: no valid PICA field structure \"$field\"";
42 }
43 else {
44 3 carp
45 "WARNING: no valid PICA field structure \"$field\". Skipped field";
46 3 next;
47 }
48 }
49  
50 112 my @subfields = map {substr($_, 0, 1), substr($_, 1)}
51 split($self->SUBFIELD_INDICATOR, substr($data, 1));
52 112 push @record, [$tag, $occurence, @subfields];
53 }
54  
55 13 return \@record;
56 }
57  
58 8 1;
59 __END__
« blib/lib/PICA/Parser/PPXML.pm ↑ Summary blib/lib/PICA/Writer/Generic.pm »