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             # Pragmas.
4 4     4   23511 use base qw(Exporter);
  4         8  
  4         417  
5 4     4   22 use strict;
  4         6  
  4         119  
6 4     4   17 use warnings;
  4         8  
  4         118  
7              
8             # Modules.
9 4     4   2110 use JSON qw(encode_json);
  4         37903  
  4         26  
10 4     4   2660 use Readonly;
  4         9450  
  4         629  
11              
12             # Constants.
13             Readonly::Array our @EXPORT_OK => qw(err_json);
14              
15             # Global variables.
16             our $PRETTY = 0;
17              
18             # Version.
19             our $VERSION = 0.09;
20              
21             # JSON print of backtrace.
22             sub err_json {
23 2     2 1 885 my @errors = @_;
24 2         2 my $ret_json;
25 2         14 my $json = JSON->new;
26 2 100       5 if ($PRETTY) {
27 1         12 $ret_json = $json->pretty->encode(@errors);
28             } else {
29 1         16 $ret_json = $json->encode(@errors);
30             }
31 2         12 return $ret_json;
32             }
33              
34             1;
35              
36             __END__