| 1 | package Catmandu::Importer::MAB2; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 1 | our $VERSION = '0.24'; | |||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | 5 | ▶ | use Catmandu::Sane; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | 5 | ▶ | use Moo; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 5 | ▶ | use MAB2::Parser::Disk; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 5 | ▶ | use MAB2::Parser::RAW; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 5 | ▶ | use MAB2::Parser::XML; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | 1 | with 'Catmandu::Importer'; | |||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 0 | ▶ | has type => ( is => 'ro', default => sub {'RAW'} ); | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||
| 14 | 7 | ▶ | has id => ( is => 'ro', default => sub {'001'} ); | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | 6 | ▶ | sub mab_generator { | ||||||||||||||||
|
Subroutine
mab_generator: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||
| 17 | 6 | my $self = shift; | |||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | 6 | my $file; | |||||||||||||||||
| 20 | 6 | my $type = lc($self->type); | |||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 6 | ▶ | if ( $type eq 'raw' ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 23 | 2 | $file = MAB2::Parser::RAW->new( $self->fh ); | |||||||||||||||||
| 24 | } | ||||||||||||||||||
| 25 | elsif ( $type eq 'xml' ) { | ||||||||||||||||||
| 26 | 3 | $self->{encoding} = ':raw'; # set encoding to :raw to drop PerlIO layers, as required by libxml2 | |||||||||||||||||
| 27 | 3 | $file = MAB2::Parser::XML->new( $self->fh ); | |||||||||||||||||
| 28 | } | ||||||||||||||||||
| 29 | elsif ( $type eq 'disk' ) { | ||||||||||||||||||
| 30 | 1 | $file = MAB2::Parser::Disk->new( $self->fh ); | |||||||||||||||||
| 31 | } | ||||||||||||||||||
| 32 | else { | ||||||||||||||||||
| 33 | 0 | Catmandu::Error->throw('unknown type'); | |||||||||||||||||
| 34 | } | ||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 6 | my $id = $self->id; | |||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | 86 | ▶ | sub { | ||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||
| 39 | 86 | my $record = $file->next(); | |||||||||||||||||
| 40 | 86 | ▶ | return unless $record; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 41 | 82 | return $record; | |||||||||||||||||
| 42 | 6 | }; | |||||||||||||||||
| 43 | } | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | 7 | ▶ | sub generator { | ||||||||||||||||
|
Subroutine
generator: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 46 | 7 | my ($self) = @_; | |||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | 7 | my $type = lc($self->type); | |||||||||||||||||
| 49 | 7 | ▶ | if ( $type =~ /raw|xml|disk$/ ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 50 | 6 | return $self->mab_generator; | |||||||||||||||||
| 51 | } | ||||||||||||||||||
| 52 | else { | ||||||||||||||||||
| 53 | 1 | Catmandu::Error->throw('unknown type (suppported types: Disk, RAW, XML)'); | |||||||||||||||||
| 54 | } | ||||||||||||||||||
| 55 | } | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | 1 | 1; | |||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||