File Coverage

blib/lib/App/JYJ.pm
Criterion Covered Total %
statement 18 30 60.0
branch 0 4 0.0
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 24 42 57.1


line stmt bran cond sub pod time code
1              
2             use strict;
3 1     1   835 use warnings;
  1         2  
  1         23  
4 1     1   4  
  1         2  
  1         30  
5             our $VERSION = '0.0.1';
6              
7             use JSON::PP;
8 1     1   641 use YAML::PP;
  1         13296  
  1         51  
9 1     1   484 use IO::All;
  1         56723  
  1         49  
10 1     1   456 use Mo;
  1         10119  
  1         7  
11 1     1   512  
  1         445  
  1         4  
12             my $input = io('-')->utf8->all;
13             my $output;
14 0     0 0   my $json = JSON::PP->new->pretty->indent_length(2);
15 0           my $yaml = YAML::PP->new;
16 0           if ($input =~ /\A[\{\[]/) {
17 0           my $data = $json->decode($input);
18 0 0         $output = $yaml->dump($data);
19 0           }
20 0           else {
21             my $data = $yaml->load_string($input);
22             $output = $json->encode($data);
23 0           }
24 0           $output .= "\n" unless $output =~ /\n\z/;
25             binmode(STDOUT, ":utf8");
26 0 0         print $output;
27 0           }
28 0            
29             1;