Exporter/MARC.pm

filter: Statementstmt 84.8% 28 / 33 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 3 totaltotal 75.5% 37 / 49 CC 4 SCAR 9.2
CC
4
Cov
79%
add
5.3
BUILD
2.0
__ANON__
1.1
CRAP 2.5
« Fix/marc_map.pm ↑ Summary Exporter/MARC/ISO.pm »
1 package Catmandu::Exporter::MARC;
2 8 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use Catmandu::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '1.33';
7  
8 0 ▶has type => (is => 'ro' , default => sub { 'ISO' });
Subroutine __ANON__: not called CC=1 SCAR=1.2
9 2 has skip_errors => (is => 'ro');
10 2 has _exporter => (is => 'ro');
11  
12 2 with 'Catmandu::Exporter';
13  
14 9 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
15 9 my ($self,$args) = @_;
16  
17 9 my $type = $self->type;
18  
19 # keep USMARC temporary as alias for ISO, remove in future version
20 # print deprecation warning
21 9 ▶ if ($type eq 'USMARC') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "USMARC") 1 8 9
22 1 $type = 'ISO';
23 1 warn( "deprecated", "Oops! Exporter \"USMARC\" is deprecated. Use \"ISO\" instead." );
24 }
25  
26 9 my $pkg = Catmandu::Util::require_package($type,'Catmandu::Exporter::MARC');
27  
28 9 delete $args->{file};
29 9 delete $args->{fix};
30  
31 9 $self->{_exporter} = $pkg->new(file => $self->file, %$args);
32 }
33  
34 18 ▶sub add {
Subroutine add: called CC=3 SCAR=16.7
Pod undocumented
35 18 my ($self) = @_;
36  
37 18 ▶ if ($self->skip_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->skip_errors) { } 0 18 18
38 0 eval {
39 0 $self->_exporter->add($_[1]);
40 };
41  
42 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
43 0 $self->log->error("error at record " . $self->count . " : $@");
44 }
45 }
46 else {
47 18 $self->_exporter->add($_[1]);
48 }
49 }
50  
51 8 ▶sub commit {
Subroutine commit: called CC=1 SCAR=0.0
Pod undocumented
52 9 $_[0]->_exporter->commit;
53 }
54  
55 2 1;
56  
57 __END__
« Fix/marc_map.pm ↑ Summary Exporter/MARC/ISO.pm »