File Coverage

blib/lib/JSON/LD.pm
Criterion Covered Total %
statement 33 33 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 2 2 100.0
total 45 45 100.0


line stmt bran cond sub pod time code
1 1     1   232280 use warnings;
  1         3  
  1         61  
2 1     1   20 use 5.020;
  1         5  
3 1     1   585 use experimental qw( signatures );
  1         5029  
  1         5  
4 1     1   767 use stable qw( postderef );
  1         558  
  1         9  
5 1     1   664 use true;
  1         10351  
  1         7  
6              
7             package JSON::LD 0.02 {
8              
9             # ABSTRACT: Load and dump JSON files
10              
11              
12 1     1   1160 use Exporter qw( import );
  1         2  
  1         36  
13 1     1   1014 use Path::Tiny ();
  1         18729  
  1         43  
14 1     1   695 use JSON::MaybeXS ();
  1         9168  
  1         250  
15              
16             our @EXPORT = qw( LoadFile DumpFile );
17              
18 1     1 1 9171 sub LoadFile ($filename) {
  1         3  
  1         2  
19 1         8 return JSON::MaybeXS::decode_json(Path::Tiny->new($filename)->slurp_raw);
20             }
21              
22 1     1 1 359742 sub DumpFile ($filename, $data) {
  1         3  
  1         3  
  1         2  
23 1         5 Path::Tiny->new($filename)->spew_raw(JSON::MaybeXS::encode_json($data));
24 1         6073 return undef;
25             }
26              
27             }
28              
29             __END__