blib/lib/PICA/Writer/Fields.pm

filter: Statementstmt 46.4% 13 / 28 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 36.0% 18 / 50 CC 9 SCAR 41.4
CC
9
Cov
31%
write_record
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 62.6
« blib/lib/PICA/Writer/PPXML.pm ↑ Summary blib/lib/PICA/Schema.pm »
1 package PICA::Writer::Fields;
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 parent 'PICA::Writer::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use PICA::Schema qw(clean_pica field_identifier);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub write_record {
12 0 ▶ my ($self, $record) = @_;
Subroutine write_record: not called CC=9 SCAR=45.0
Pod documented
13 0 ▶ $record = clean_pica($record) or return;
Branch: 1 branch
BranchTrueFalseTotal
$record = clean_pica($record) or return 0 0 0
14  
15 0 my $fh = $self->{fh};
16 0 ▶ my $seen = $self->{seen} // ($self->{seen} = {});
Condition0%0/2
$self->{"seen"} // ($self->{"seen"} = {})
l!l
00
MC/DC0%0/1
$self->{"seen"} // ($self->{"seen"} = {})
$self->{"seen"}
Truth table0%0/2
A
A= $self->{"seen"}
Aresult
11
00
17 0 my $schema = $self->{schema};
18  
19 0 foreach my $field (@$record) {
20 0 ▶ my $id = field_identifier($schema ? $schema : (), $field);
Branch: 1 branch
BranchTrueFalseTotal
$schema ? : 0 0 0
21  
22 0 ▶ next if $seen->{$id};
Branch: 1 branch
BranchTrueFalseTotal
if $seen->{$id} 0 0 0
23 0 $seen->{$id} = 1;
24  
25 0 $fh->print($id);
26  
27 0 ▶ if ($schema) {
Branch: 1 branch
BranchTrueFalseTotal
if ($schema) 0 0 0
28 0 my $def = $schema->{fields}{$id};
29 0 ▶ my $label = $def ? $def->{label} // '' : '?';
Branch: 1 branch
BranchTrueFalseTotal
$def ? : 0 0 0
Condition0%0/2
$def->{"label"} // ""
l!l
00
MC/DC0%0/1
$def->{"label"} // ""
$def->{"label"}
Truth table0%0/2
A
A= $def->{"label"}
Aresult
11
00
30 0 $fh->print("\t" . $label =~ s/[\r\n]+/ /mgr);
31 }
32  
33 0 $fh->print("\n");
34 }
35 }
36  
37 8 1;
38 __END__
« blib/lib/PICA/Writer/PPXML.pm ↑ Summary blib/lib/PICA/Schema.pm »