Catmandu/Fix/to_json.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 34 / 34 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Catmandu/Fix/set_hash.pm ↑ Summary Catmandu/Fix/uniq.pm »
1 package Catmandu::Fix::to_json;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.2025';
6  
7 1 ▶use Cpanel::JSON::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 with 'Catmandu::Fix::Builder';
14  
15 1 has path => (fix_arg => 1);
16  
17 2 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=1 SCAR=0.0
18 2 my ($self) = @_;
19 2 my $json = Cpanel::JSON::XS->new->utf8(0)->pretty(0)->allow_nonref(1);
20 as_path($self->path)->updater(
21 if => [
22 3 ▶ [qw(maybe_value array_ref hash_ref)] => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 3 $json->encode($_[0]);
24 }
25 2 ]
26 );
27 }
28  
29 1 1;
30  
31 __END__
« Catmandu/Fix/set_hash.pm ↑ Summary Catmandu/Fix/uniq.pm »