File Coverage

blib/lib/Config/INI/Reader/Multiline.pm
Criterion Covered Total %
statement 23 23 100.0
branch 8 8 100.0
condition 4 6 66.6
subroutine 7 7 100.0
pod 4 4 100.0
total 46 48 95.8


line stmt bran cond sub pod time code
1             package Config::INI::Reader::Multiline;
2             $Config::INI::Reader::Multiline::VERSION = '1.002';
3 3     3   420203 use strict;
  3         7  
  3         131  
4 3     3   15 use warnings;
  3         5  
  3         211  
5              
6 3     3   1856 use Config::INI::Reader 0.024;
  3         96868  
  3         1651  
7             our @ISA = qw( Config::INI::Reader );
8              
9             # preprend the buffer if any
10             sub preprocess_line {
11 53     53 1 345816 my ( $self, $line ) = @_;
12             $$line = delete( $self->{__buffer} ) . $$line
13 53 100 66     274 if exists $self->{__buffer} && $$line =~ s/^\s*//;
14 53         168 return $self->SUPER::preprocess_line($line);
15             }
16              
17             sub parse_value_assignment {
18 34     34 1 842 my ( $self, $line ) = @_;
19 34 100       182 return if $line =~ /\s*\\\s*\z/; # handle_unparsed_line does continuations
20 16         49 return $self->SUPER::parse_value_assignment($line);
21             }
22              
23             sub handle_unparsed_line {
24 19     19 1 108 my ( $self, $line, $handle ) = @_; # order changed in CIR 0.024
25 19 100 66     386 return $self->{__buffer} .= "$line " # buffer continuations
26             if $line =~ s/\s*\\\s*\z// && $line =~ s/\A\s*//;
27 1         8 return $self->SUPER::handle_unparsed_line( $line, $handle );
28             }
29              
30             sub finalize {
31 7     7 1 204 my ($self) = @_;
32              
33             # if there's stuff in the buffer,
34             # we had a continuation on the last line
35 7 100       27 if ( exists $self->{__buffer} ) {
36 3         11 my $line = delete $self->{__buffer};
37 3         519 Carp::croak "Continuation on the last line: '$line\\'";
38             }
39              
40 4         16 return $self->SUPER::finalize;
41             }
42              
43             1;
44              
45             __END__