Catmandu/Importer/DKVP.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 40 CC 2 SCAR 12.0
CC
2
Cov
0%
generator
6.0
_build__re
2.0
BEGIN
2.0
CRAP 3.3
1 package Catmandu::Importer::DKVP;
2  
3 use Catmandu::Sane;
4  
5 our $VERSION = '1.2025';
6  
7 use Moo;
8 use namespace::clean;
9  
10 with 'Catmandu::Importer';
11  
12 has pair_sep_char => (is => 'ro', default => sub {'='});
13 has sep_char => (is => 'ro', default => sub {','});
14 has _re => (is => 'lazy');
15  
16 sub _build__re {
17 my ($self) = @_;
18 my $sep_char = $self->sep_char;
19 my $pair_sep_char = $self->pair_sep_char;
20 qr/([^$pair_sep_char]+)$pair_sep_char([^$sep_char]+)(?:$sep_char|$)/;
21 }
22  
23 sub generator {
24 my ($self) = @_;
25  
26 return sub {
27 state $fh = $self->fh;
28 state $re = $self->_re;
29 if (defined(my $line = <$fh>)) {
30 chomp $line;
31 my %rec = $line =~ /$re/g;
32 return \%rec;
33 }
34 return;
35 };
36 }
37  
38 1;
39  
40 __END__