| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::Exporter::MARC::MARCMaker - Exporter for MARC records to USMARC |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# From the command line |
|
8
|
|
|
|
|
|
|
$ catmandu convert MARC --type XML to MARC --type MARCMaker < /foo/data.mrc |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# From Perl |
|
11
|
|
|
|
|
|
|
use Catmandu; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $importer = Catmandu->importer('MARC', file => "/foo/bar.mrc" , type => 'XML'); |
|
14
|
|
|
|
|
|
|
my $exporter = Catmandu->exporter('MARC', file => "marc.xml", type => 'MARCMaker' ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$exporter->add($importer); |
|
17
|
|
|
|
|
|
|
$exporter->commit; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=over |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=item file |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Write output to a local file given by its path or file handle. Alternatively a |
|
26
|
|
|
|
|
|
|
scalar reference can be passed to write to a string and a code reference can be |
|
27
|
|
|
|
|
|
|
used to write to a callback function. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item fh |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Write the output to an L<IO::Handle>. If not specified, |
|
32
|
|
|
|
|
|
|
L<Catmandu::Util::io|Catmandu::Util/IO-functions> is used to create the output |
|
33
|
|
|
|
|
|
|
handle from the C<file> argument or by using STDOUT. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item fix |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
An ARRAY of one or more fixes or file scripts to be applied to exported items. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item encoding |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Binmode of the output stream C<fh>. Set to "C<:utf8>" by default. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=back |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
See L<Catmandu::Exporter>, L<Catmandu::Addable>, L<Catmandu::Fixable>, |
|
48
|
|
|
|
|
|
|
L<Catmandu::Counter>, and L<Catmandu::Logger> for a full list of methods. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L<Catmandu::Exporter> |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
package Catmandu::Exporter::MARC::MARCMaker; |
|
56
|
1
|
|
|
1
|
|
85086
|
use Catmandu::Sane; |
|
|
1
|
|
|
|
|
156441
|
|
|
|
1
|
|
|
|
|
7
|
|
|
57
|
1
|
|
|
1
|
|
263
|
use Catmandu::Util qw(xml_escape is_different :array :is); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
350
|
|
|
58
|
1
|
|
|
1
|
|
7
|
use Moo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
59
|
1
|
|
|
1
|
|
974
|
use MARC::Record; |
|
|
1
|
|
|
|
|
7617
|
|
|
|
1
|
|
|
|
|
58
|
|
|
60
|
1
|
|
|
1
|
|
10
|
use MARC::Field; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
24
|
|
|
61
|
1
|
|
|
1
|
|
1122
|
use MARC::File::MARCMaker; |
|
|
1
|
|
|
|
|
5495
|
|
|
|
1
|
|
|
|
|
297
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
with 'Catmandu::Exporter', 'Catmandu::Exporter::MARC::Base'; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has record => (is => 'ro' , default => sub { 'record'}); |
|
68
|
|
|
|
|
|
|
has record_format => (is => 'ro' , default => sub { 'raw'} ); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub add { |
|
71
|
|
|
|
|
|
|
my ($self, $data) = @_; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
if ($self->record_format eq 'MARC-in-JSON') { |
|
74
|
|
|
|
|
|
|
$data = $self->_json_to_raw($data); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $marc = $self->_raw_to_marc_record($data->{$self->record}); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$self->fh->print(MARC::File::MARCMaker::encode($marc)); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub commit { |
|
83
|
|
|
|
|
|
|
my ($self) = @_; |
|
84
|
|
|
|
|
|
|
$self->fh->flush; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |