| 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
| |||||||||||
| 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
| |||||||||||
| 38 | 0 | eval { | |||||||||
| 39 | 0 | $self->_exporter->add($_[1]); | |||||||||
| 40 | }; | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||