File Coverage

blib/lib/YAML/Ordered/Conditional.pm
Criterion Covered Total %
statement 27 31 87.1
branch 4 10 40.0
condition 1 3 33.3
subroutine 9 12 75.0
pod 4 6 66.6
total 45 62 72.5


line stmt bran cond sub pod time code
1             package YAML::Ordered::Conditional;
2              
3 14     14   1735141 use 5.006; use strict; use warnings; our $VERSION = '0.04';
  14     14   58  
  14     14   108  
  14         38  
  14         493  
  14         107  
  14         70  
  14         1507  
4 14     14   8161 use YAML::As::Parsed qw/Dump DumpFile Load LoadFile/; use base 'Struct::Conditional';
  14     14   210057  
  14         1663  
  14         144  
  14         39  
  14         9003  
5 14     14   55557 use Tie::IxHash;
  14         33  
  14         4875  
6              
7             sub encode {
8 0     0 1 0 Dump($_[1]);
9             }
10              
11             sub encode_file {
12 0     0 0 0 DumpFile($_[1], $_[2]);
13             }
14              
15             sub decode {
16 15 50 33 15 1 143 if ($_[1] !~ m/\n/ && -f $_[1]) {
17 0         0 return $_[0]->decode_file($_[1]);
18             }
19 15         157 Load($_[1]);
20             }
21              
22             sub decode_file {
23 0     0 1 0 LoadFile($_[1], $_[2]);
24             }
25              
26             sub compile {
27 15     15 1 2845417 my ($self, $yaml, $params, $return_struct, $out_file) = @_;
28 15 50       143 $yaml = $self->decode($yaml) unless ref $yaml;
29 15 50       35935 $params = $self->decode($params) unless ref $params;
30 15         149 $yaml = $self->SUPER::compile($yaml, $params);
31 15 0       34209 return $return_struct
    50          
32             ? $yaml
33             : $out_file
34             ? $self->encode_file($out_file, $yaml)
35             : $self->encode($yaml);
36             }
37              
38             sub instantiate_hash {
39 2     2 0 1159 my %hash;
40 2         11 tie %hash, 'Tie::IxHash';
41 2         73 return %hash;
42             }
43              
44             1;
45              
46              
47             __END__