| 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
| |||||||||||
| 28 | 0 | ▶ | if (ref $fields eq 'HASH') {return [sort keys %$fields]} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||