PICA/Writer/JSON.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 94.7% 36 / 38 CC 4 SCAR 8.5
CC
4
Cov
94%
write_record
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« PICA/Parser/PPXML.pm ↑ Summary PICA/Parser/Patch.pm »
1 package PICA::Writer::JSON;
2 16 ▶use v5.14.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 16 our $VERSION = '2.12';
5  
6 16 ▶use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use JSON::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use PICA::Data;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 ▶use parent 'PICA::Writer::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶sub write_record {
Subroutine write_record: called CC=4 SCAR=14.0
Pod documented
13 2 my ($self, $record) = @_;
14  
15 2 my $json = $self->{json};
16 2 ▶ unless ($json) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($json) 2 0 2
17 2 $json = JSON::PP->new(%$self);
18 $json->$_($self->{$_})
19 2 for grep {exists $self->{$_}}
20 qw(pretty ascii latin1 utf8 indent space_before space_after canonical);
21 2 $self->{json} = $json;
22 }
23  
24 2 print {$self->{fh}} $json->encode(PICA::Data::TO_JSON($record));
25 2 ▶ print {$self->{fh}} "\n" unless $json->get_indent;
Branch: 1 branch
BranchTrueFalseTotal
unless $json->get_indent 2 0 2
26 }
27  
28 16 1;
29 __END__
« PICA/Parser/PPXML.pm ↑ Summary PICA/Parser/Patch.pm »