File Coverage

blib/lib/Config/INI/Reader/LibIni.pm
Criterion Covered Total %
statement 22 24 91.6
branch 4 6 66.6
condition n/a
subroutine 6 7 85.7
pod 4 4 100.0
total 36 41 87.8


line stmt bran cond sub pod time code
1             package Config::INI::Reader::LibIni;
2             {
3             $Config::INI::Reader::LibIni::VERSION = '0.002';
4             }
5              
6 2     2   819 use strict;
  2         3  
  2         63  
7 2     2   11 use warnings;
  2         3  
  2         54  
8              
9 2     2   10 use base 'Config::INI::Reader';
  2         3  
  2         1786  
10              
11             sub new {
12 10     10 1 37518 my ($class) = @_;
13 10         60 return bless { data => [] }, $class;
14             }
15              
16             sub change_section {
17 15     15 1 1846 my ($self, $section) = @_;
18 15         22 push @{ $self->{data} }, [ $section => {} ];
  15         74  
19             }
20              
21             sub set_value {
22 8     8 1 870 my ($self, $name, $value) = @_;
23              
24 8 100       34 if ( exists $self->{data}[-1][1]{$name} ) {
25 3         9 my $existing = $self->{data}[-1][1]{$name};
26              
27 3 100       13 if (ref $existing eq 'ARRAY') {
28 1         3 push @{ $self->{data}[-1][1]{$name} }, $value;
  1         8  
29             } else {
30 2         13 $self->{data}[-1][1]{$name} = [$existing, $value];
31             }
32             } else {
33 5         26 $self->{data}[-1][1]{$name} = $value;
34             }
35             }
36              
37             sub current_section {
38 0     0 1   my ($self) = @_;
39 0 0         exists $self->{data}[-1] ? $self->{data}[-1][0] : $self->starting_section;
40             }
41              
42             1;
43              
44             __END__