Catmandu/Importer/TSV.pm

filter: Statementstmt 81.0% 30 / 37 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 75.0% 39 / 52 CC 3 SCAR 13.2
CC
3
Cov
73%
__ANON__
12.0
__ANON__
1.0
BEGIN
1.0
CRAP 3.8
« Catmandu/Cmd.pm ↑ Summary Catmandu/Store/Multi/Bag.pm »
1 package Catmandu::Importer::TSV;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.2025';
6  
7 1 ▶use Catmandu::Importer::CSV;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with 'Catmandu::Importer';
12  
13 1 ▶has header => (is => 'ro', default => sub {1});
Subroutine __ANON__: called CC=1 SCAR=0.0
14 has sep_char => (
15 is => 'ro',
16 2 ▶ default => sub {"\t"},
Subroutine __ANON__: called CC=1 SCAR=0.0
17 3 ▶ coerce => sub {
Subroutine __ANON__: called CC=1 SCAR=0.2
18 3 my $sep_char = $_[0];
19 0 $sep_char =~ s/(\\[abefnrt])/"qq{$1}"/gee;
20 3 return $sep_char;
21 }
22 1 );
23 has fields => (
24 is => 'rwp',
25 0 ▶ coerce => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
26 0 my $fields = $_[0];
27 0 ▶ if (ref $fields eq 'ARRAY') {return $fields}
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fields eq "ARRAY") 0 0 0
28 0 ▶ if (ref $fields eq 'HASH') {return [sort keys %$fields]}
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fields eq "HASH") 0 0 0
29 0 return [split ',', $fields];
30 },
31 1 );
32  
33 1 has csv => (is => 'lazy');
34  
35 3 ▶sub _build_csv {
Subroutine _build_csv: called CC=1 SCAR=0.0
36 3 my ($self) = @_;
37 3 my $csv = Catmandu::Importer::CSV->new(
38 header => $self->header,
39 sep_char => $self->sep_char,
40 quote_char => undef,
41 escape_char => undef,
42 file => $self->file,
43 );
44 3 $csv->{fields} = $self->fields;
45 3 $csv;
46 }
47  
48 3 ▶sub generator {
Subroutine generator: called CC=1 SCAR=0.0
Pod undocumented
49 3 my ($self) = @_;
50 3 $self->csv->generator;
51 }
52  
53 1 1;
54  
55 __END__
« Catmandu/Cmd.pm ↑ Summary Catmandu/Store/Multi/Bag.pm »