blib/lib/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
« blib/lib/PICA/Writer/Generic.pm ↑ Summary blib/lib/PICA/Writer/Plus.pm »
1 package PICA::Writer::JSON;
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 Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use JSON::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use PICA::Data;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use parent 'PICA::Writer::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub write_record {
13 1 ▶ my ($self, $record) = @_;
Subroutine write_record: called CC=4 SCAR=14.0
Pod documented
14  
15 1 my $json = $self->{json};
16 1 ▶ unless ($json) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($json) 1 0 1
17 1 $json = JSON::PP->new(%$self);
18 $json->$_($self->{$_})
19 1 for grep {exists $self->{$_}}
20 qw(pretty ascii latin1 utf8 indent space_before space_after canonical);
21 1 $self->{json} = $json;
22 }
23  
24 1 print {$self->{fh}} $json->encode(PICA::Data::TO_JSON($record));
25 1 ▶ print {$self->{fh}} "\n" unless $json->get_indent;
Branch: 1 branch
BranchTrueFalseTotal
unless $json->get_indent 1 0 1
26 }
27  
28 8 1;
29 __END__
« blib/lib/PICA/Writer/Generic.pm ↑ Summary blib/lib/PICA/Writer/Plus.pm »