Fix/marc_xml.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.9% 32 / 33 CC 2 SCAR 2.5
CC
2
Cov
100%
emit_value
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Fix/marc_in_json.pm ↑ Summary Importer/MARC/MicroLIF.pm »
1 package Catmandu::Fix::marc_xml;
2  
3 3 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 our $VERSION = '1.33';
6  
7 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Catmandu::MARC;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 has path => (fix_arg => 1);
13 3 has reverse => (fix_opt => 1);
14  
15 3 with 'Catmandu::Fix::SimpleGetValue';
16  
17 6 ▶sub emit_value {
Subroutine emit_value: called CC=2 SCAR=6.9
Pod undocumented
18 6 my ($self, $var) = @_;
19  
20 6 ▶ if ($self->reverse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reverse) { } 1 5 6
21 1 "if (is_string(${var})) {" .
22 "${var} = Catmandu::MARC->instance->marc_xml(${var}, reverse => 1);" .
23 "}";
24 }
25 else {
26 5 "if (is_array_ref(${var})) {" .
27 "${var} = Catmandu::MARC->instance->marc_xml(${var});" .
28 "}";
29 }
30 }
31  
32 =head1 NAME
33  
34 Catmandu::Fix::marc_xml - transform a Catmandu MARC record into MARCXML
35  
36 =head1 SYNOPSIS
37  
38 # Transforms the 'record' key into a MARCXML string
39 marc_xml('record')
40  
41 # Transforms the XML in the 'record' key into MARC accessible data
42 marc_xml('record',reverse:1)
43  
44 =head1 DESCRIPTION
45  
46 Convert MARC data into a MARCXML string
47  
48 =head1 METHODS
49  
50 =head2 marc_xml(PATH,[reverse:1])
51  
52 Transform the MARC record found at PATH to MARC XML. If an
53 C<reverse> option is given, then XML found at C<PATH> will be transformed
54 into an internal MARC format. The MARC representation needs to be
55 stored in the C<record> key to be used with other L<Catmandu::MARC> fixes.
56  
57 =head1 INLINE
58  
59 This Fix can be used inline in a Perl script:
60  
61 use Catmandu::Fix::marc_xml as => 'marc_xml';
62  
63 my $data = { record => [...] };
64  
65 $data = marc_xml($data);
66  
67 =head1 SEE ALSO
68  
69 L<Catmandu::Fix>
70  
71 =cut
72  
73 3 1;
« Fix/marc_in_json.pm ↑ Summary Importer/MARC/MicroLIF.pm »