File Coverage

lib/Sisimai/Data/JSON.pm
Criterion Covered Total %
statement 20 20 100.0
branch 3 4 75.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 0 1 0.0
total 29 32 90.6


line stmt bran cond sub pod time code
1             package Sisimai::Data::JSON;
2 4     4   1624 use feature ':5.10';
  4         8  
  4         358  
3 4     4   26 use strict;
  4         10  
  4         84  
4 4     4   18 use warnings;
  4         8  
  4         128  
5 4     4   1387 use JSON;
  4         17782  
  4         30  
6              
7             sub dump {
8             # Data dumper(JSON)
9             # @param [Sisimai::Data] argvs Object
10             # @return [String, Undef] Dumped data or Undef if the argument is
11             # missing
12 645     645 0 2412 my $class = shift;
13 645   50     1292 my $argvs = shift // return undef;
14 645 100       1420 return undef unless ref $argvs eq 'Sisimai::Data';
15              
16 644         945 my $jsonstring = '';
17 644         879 eval { $jsonstring = JSON->new->space_after(1)->encode($argvs->damn) };
  644         6138  
18 644 50       21306 warn sprintf(" ***warning: Something is wrong in JSON encoding: %s", $@) if $@;
19 644         3181 return $jsonstring;
20             }
21              
22             1;
23             __END__