File Coverage

lib/Sisimai/Fact/JSON.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 4 50.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 0 1 0.0
total 27 31 87.1


line stmt bran cond sub pod time code
1             package Sisimai::Fact::JSON;
2 81     81   2585 use v5.26;
  81         339  
3 81     81   918 use strict;
  81         215  
  81         3075  
4 81     81   411 use warnings;
  81         161  
  81         5930  
5 81     81   2074 use JSON;
  81         20680  
  81         909  
6              
7             sub dump {
8             # Data dumper(JSON)
9             # @param [Sisimai::Fact] argvs Object
10             # @return [String] Dumped data or an empty string if the argument is missing
11 1485     1485 0 4563 my $class = shift;
12 1485 50 50     8002 my $argvs = shift // return ""; return "" if ref $argvs ne 'Sisimai::Fact';
  1485         9168  
13              
14 1485         4253 my $jsonstring = "";
15 1485         4439 eval { $jsonstring = JSON->new->space_after(1)->encode($argvs->damn) };
  1485         37368  
16 1485 50       44841 warn sprintf(" ***warning: Something is wrong in JSON encoding: %s", $@) if $@;
17 1485         10207 return $jsonstring;
18             }
19              
20             1;
21             __END__