lib/Catmandu/Importer/MAB2.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 2 totaltotal 90.4% 57 / 63 CC 6 SCAR 7.3
CC
6
Cov
94%
mab_generator
4.0
__ANON__
2.0
generator
2.0
CRAP 2.1
« lib/Catmandu/Exporter/MAB2.pm ↑ Summary lib/Catmandu/MAB2.pm »
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
BranchTrueFalseTotal
if ($type eq 'raw') { } 2 4 6
elsif ($type eq 'xml') { } 3 1 4
elsif ($type eq 'disk') { } 1 0 1
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
BranchTrueFalseTotal
unless $record 4 82 86
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
BranchTrueFalseTotal
if ($type =~ /raw|xml|disk$/) { } 6 1 7
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__
« lib/Catmandu/Exporter/MAB2.pm ↑ Summary lib/Catmandu/MAB2.pm »