Moose/Formater/AuthorityUnimarcToMarc21.pm

filter: Statementstmt 48.9% 23 / 47 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 45.0% 27 / 60 CC 10 SCAR 43.7
CC
10
Cov
42%
__ANON__
110.0
BEGIN
1.0
BEGIN
1.0
CRAP 78.9
« Moose/Lint/Checker/RulesFile.pm ↑ Summary Moose/Formater/Legacy.pm »
1 package MARC::Moose::Formater::AuthorityUnimarcToMarc21;
2 4 $MARC::Moose::Formater::AuthorityUnimarcToMarc21::VERSION = '1.0.49';
3 # ABSTRACT: Convert authority record from UNIMARC to MARC21
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 extends 'MARC::Moose::Formater';
9  
10 4 ▶use MARC::Moose::Field::Control;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use MARC::Moose::Field::Std;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14  
15 # List of moved fields unchanged
16 4 my @unchanged;
17 4 push @unchanged, [$_, 500] for 300..315;
18 4 push @unchanged, [317, 561],
19 [320, 504],
20 [321, 500],
21 [322, 508],
22 [323, 511],
23 [324, 500],
24 [328, 502],
25 [330, 520],
26 [332, 524],
27 [333, 521],
28 [337, 538],
29 [686, '084'];
30  
31 # Tags with non-filing indicator (pos 1 or 2)
32 4 my $nonfiling_tags = [
33 [ qw/130 630 730 740 830/ ],
34 [ qw/240 242 243 245 440 830/ ],
35 ];
36  
37 # NSB/NSE characters
38 4 my $ns_characters = [
39 [ "\x08", "\x09" ],
40 [ "\x88", "\x89" ]
41 ];
42  
43  
44 4 my $equivals = [
45 [ qw/ 200 100 / ],
46 [ qw/ 210 110 / ],
47 [ qw/ 215 151 / ],
48 [ qw/ 220 120 / ],
49 [ qw/ 225 125 / ],
50 [ qw/ 230 130 / ],
51 [ qw/ 240 140 / ],
52 [ qw/ 250 150 / ],
53 [ qw/ 415 451 / ],
54 [ qw/ 515 551 / ],
55 ];
56  
57 0 ▶override 'format' => sub {
Subroutine __ANON__: not called CC=10 SCAR=47.0
58 0 my ($self, $unimarc) = @_;
59  
60 0 my $record = MARC::Moose::Record->new();
61  
62 0 $record->_leader(" nam a22 7a 4500");
63  
64 # First, copy as it is
65 0 $record->append( grep { 1 } @{$unimarc->fields} );
66  
67 0 for (@$equivals) {
68 0 my ($from, $to) = @$_;
69 0 for my $field ($record->field($from)) {
70 0 $field->tag($to);
71 }
72 }
73  
74 # On intervertit $z et $y
75 0 for my $field ( $record->field('1..|4..|5..') ) {
76 $field->subf( [ map {
77 0 my ($letter, $value) = @$_;
78 0 ▶ $letter = $letter eq 'y' ? 'z' :
Branch: 2 branches
BranchTrueFalseTotal
$letter eq 'y' ? : 0 0 0
$letter eq 'z' ? : 0 0 0
79 $letter eq 'z' ? 'y' : $letter;
80 0 [ $letter, $value ];
81 0 } @{$field->subf} ] );
82 }
83  
84 # Clean non-filing characters in all fields
85 0 for my $field (@{$record->fields}) {
86 0 ▶ next if $field->tag lt '010';
Branch: 1 branch
BranchTrueFalseTotal
if $field->tag lt "010" 0 0 0
87 0 for (@{$field->subf} ) {
88 0 ▶ next if $_->[0] !~ /[a-z0-9]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->[0] =~ /[a-z0-9]/u 0 0 0
89 0 $_->[1] =~ s/\x08|\x09//g;
90 }
91 }
92  
93 0 return $record;
94 4 };
95  
96 4 __PACKAGE__->meta->make_immutable;
97  
98 4 1;
99  
100 __END__
« Moose/Lint/Checker/RulesFile.pm ↑ Summary Moose/Formater/Legacy.pm »