Moose/Formater/Marcxml.pm

filter: Statementstmt 42.2% 19 / 45 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 42.5% 23 / 54 CC 4 SCAR 21.7
CC
4
Cov
40%
__ANON__
20.0
__ANON__
2.0
__ANON__
2.0
CRAP 8.8
« Moose/Parser/Marcxml.pm ↑ Summary Moose/Lint/Processor.pm »
1 package MARC::Moose::Formater::Marcxml;
2 #ABSTRACT: MARC::Moose record formater into MARCXML
3 4 $MARC::Moose::Formater::Marcxml::VERSION = '1.0.49';
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 extends 'MARC::Moose::Formater';
7  
8 4 ▶use MARC::Moose::Field::Control;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use MARC::Moose::Field::Std;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use XML::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 0 ▶override 'begin' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 0 return "<collection>\n";
15 4 };
16  
17  
18 0 ▶override 'end' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
19 0 return "</collection>\n";
20 4 };
21  
22  
23 0 ▶override 'format' => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
24 0 my ($self, $record) = @_;
25  
26 0 my $str = '';
27 0 my $w = XML::Writer->new( OUTPUT => \$str, DATA_MODE => 1, DATA_INDENT => 2 );
28  
29 0 $w->startTag( 'record' );
30 0 $w->startTag( 'leader' );
31 0 $w->characters( $record->leader );
32 0 $w->endTag();
33  
34 0 for my $field ( @{$record->fields} ) {
35 0 ▶ if ( ref($field) eq 'MARC::Moose::Field::Control' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $field eq 'MARC::Moose::Field::Control') { } 0 0 0
36 0 $w->startTag( "controlfield", tag => $field->tag );
37 0 $w->characters( $field->value );
38 0 $w->endTag();
39 }
40 else {
41 0 $w->startTag(
42 "datafield", tag => $field->tag, ind1 => $field->ind1,
43 ind2 => $field->ind2 );
44 0 for ( @{$field->subf} ) {
45 0 my ($letter, $value) = @$_;
46 0 $w->startTag( "subfield", code => $letter );
47 # FIXME: XML::Writer should escape 1B (ESC) character, but it doesn't
48 0 $value =~ s/\x1B//g;
49 0 $w->characters( $value );
50 0 $w->endTag();
51 }
52 0 $w->endTag();
53 }
54 }
55 0 $w->endTag();
56 0 return $str . "\n";
57 4 };
58  
59 4 __PACKAGE__->meta->make_immutable;
60  
61 4 1;
62  
63 __END__
« Moose/Parser/Marcxml.pm ↑ Summary Moose/Lint/Processor.pm »