File Coverage

blib/lib/Error/Pure/Output/JSON.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Error::Pure::Output::JSON;
2              
3 3     3   70604 use base qw(Exporter);
  3         18  
  3         373  
4 3     3   21 use strict;
  3         6  
  3         79  
5 3     3   17 use warnings;
  3         5  
  3         112  
6              
7 3     3   2035 use JSON;
  3         37863  
  3         18  
8 3     3   1885 use Readonly;
  3         10783  
  3         505  
9              
10             # Constants.
11             Readonly::Array our @EXPORT_OK => qw(err_json);
12              
13             # Global variables.
14             our $PRETTY = 0;
15              
16             our $VERSION = 0.11;
17              
18             # JSON print of backtrace.
19             sub err_json {
20 2     2 1 866 my @errors = @_;
21 2         4 my $ret_json;
22 2         18 my $json = JSON->new;
23 2 100       7 if ($PRETTY) {
24 1         12 $ret_json = $json->pretty->encode(@errors);
25             } else {
26 1         15 $ret_json = $json->encode(@errors);
27             }
28 2         12 return $ret_json;
29             }
30              
31             1;
32              
33             __END__