to.pm

filter: Statementstmt 100% 26 / 26 Branchbran 62.5% 5 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 81.8% 36 / 44 CC 6 SCAR 15.0
CC
6
Cov
86%
run
6.3
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
↑ Summary to/yaml.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::JSON::to;
5 # ABSTRACT: Convert JSON data to various formats
6  
7 1 our $VERSION = '1.000';
8  
9 1 ▶use JSON::MaybeXS qw<decode_json>;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub run
12 4 ▶{
Subroutine run: called CC=6 SCAR=18.3
Pod undocumented
13 4 my ($to, @args) = @_;
14 4 $to = lc $to;
15  
16 4 ▶ die "missing target format\n" unless defined $to;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $to 0 4 4
17 die "invalid target format '$to'\n"
18 4 ▶ unless $to =~ /\A[a-z]+\z/ && eval { require "App/JSON/to/$to.pm"; 1 };
Branch: 1 branch
BranchTrueFalseTotal
unless $to =~ /\A[a-z]+\z/ and eval { do { require "App/JSON/to/$to.pm"; 1 } } 0 4 4
Condition33%1/3
$to =~ /\A[a-z]+\z/ and eval { do { require "App/JSON/to/$to.pm"; 1 } }
!ll&&!rl&&r
004
MC/DC0%0/2
$to =~ /\A[a-z]+\z/ and eval { do { require "App/JSON/to/$to.pm"; 1 } }
$to =~ /\A[a-z]+\z/ eval { do { require "App/JSON/to/$to.pm"; 1 } }
Truth table33%1/3
A and B
A= $to =~ /\A[a-z]+\z/B= eval { do { require "App/JSON/to/$to.pm"; 1 } }
ABresult
0X0
100
111
19 4 my $class = __PACKAGE__ . '::' . $to;
20 4 ▶ my $obj = $class->can('new') ? $class->new : $class;
Branch: 1 branch
BranchTrueFalseTotal
$class->can('new') ? : 0 4 4
21  
22 # TODO parse options
23 # GetOptions($obj->options);
24  
25 4 binmode(STDIN, ':raw');
26 4 my $data = decode_json do { local $/; <STDIN> };
27  
28 4 ▶ if (my $enc_meth = $obj->can('encoding')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $enc_meth = $obj->can("encoding")) 2 2 4
29 2 binmode(STDOUT, ':encoding('.$obj->$enc_meth().')');
30 }
31  
32 4 print $obj->dump($data);
33 }
34  
35 1 1;
36 __END__
↑ Summary to/yaml.pm »