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 82     82   1950 use v5.26;
  82         240  
3 82     82   351 use strict;
  82         134  
  82         3652  
4 82     82   286 use warnings;
  82         592  
  82         4396  
5 82     82   2089 use JSON;
  82         21671  
  82         711  
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 1493     1493 0 3375 my $class = shift;
12 1493 50 50     6078 my $argvs = shift // return ""; return "" if ref $argvs ne 'Sisimai::Fact';
  1493         5993  
13              
14 1493         3476 my $jsonstring = "";
15 1493         2556 eval { $jsonstring = JSON->new->space_after(1)->encode($argvs->damn) };
  1493         24015  
16 1493 50       35195 warn sprintf(" ***warning: Something is wrong in JSON encoding: %s", $@) if $@;
17 1493         7719 return $jsonstring;
18             }
19              
20             1;
21             __END__