File Coverage

blib/lib/TOON.pm
Criterion Covered Total %
statement 48 64 75.0
branch 0 2 0.0
condition 3 6 50.0
subroutine 11 14 78.5
pod 10 10 100.0
total 72 96 75.0


line stmt bran cond sub pod time code
1             package TOON;
2              
3 6     6   1081660 use v5.40;
  6         20  
4 6     6   59 use feature 'signatures';
  6         10  
  6         1214  
5              
6 6     6   45 use Exporter 'import';
  6         32  
  6         331  
7 6     6   3625 use TOON::PP ();
  6         17  
  6         3013  
8              
9             our $VERSION = '0.1.0';
10             our @EXPORT_OK = qw(
11             encode_toon decode_toon
12             to_toon from_toon
13             );
14              
15 1     1 1 156975 sub encode_toon ($data, %opts) {
  1         2  
  1         9  
  1         1  
16 1         8 return TOON::PP->new(%opts)->encode($data);
17             }
18              
19 1     1 1 846 sub decode_toon ($text, %opts) {
  1         2  
  1         2  
  1         1  
20 1         4 return TOON::PP->new(%opts)->decode($text);
21             }
22              
23 0     0 1 0 sub to_toon ($data, %opts) { return encode_toon($data, %opts) }
  0         0  
  0         0  
  0         0  
  0         0  
24 0     0 1 0 sub from_toon ($text, %opts) { return decode_toon($text, %opts) }
  0         0  
  0         0  
  0         0  
  0         0  
25              
26 3     3 1 479158 sub new ($class, %opts) {
  3         8  
  3         12  
  3         12  
27             return bless {
28             pretty => $opts{pretty} // 0,
29             canonical => $opts{canonical} // 0,
30 3   50     58 indent => $opts{indent} // 2,
      50        
      50        
31             }, $class;
32             }
33              
34 2     2 1 10 sub encode ($self, $data) {
  2         4  
  2         4  
  2         4  
35 2         14 return TOON::PP->new(%$self)->encode($data);
36             }
37              
38 3     3 1 1178 sub decode ($self, $text) {
  3         6  
  3         5  
  3         10  
39 3         34 return TOON::PP->new(%$self)->decode($text);
40             }
41              
42 1     1 1 1 sub pretty ($self, $value = 1) {
  1         2  
  1         1  
  1         5  
43 1         4 $self->{pretty} = $value;
44 1         23 return $self;
45             }
46              
47 1     1 1 2 sub canonical ($self, $value = 1) {
  1         1  
  1         1  
  1         1  
48 1         2 $self->{canonical} = $value;
49 1         2 return $self;
50             }
51              
52 0     0 1   sub indent ($self, $value) {
  0            
  0            
  0            
53 0 0         $self->{indent} = $value if defined $value;
54 0           return $self;
55             }
56              
57             1;
58              
59             __END__