Validator/Plugin/Field080.pm

filter: Statementstmt 100% 55 / 55 Branchbran 94.1% 32 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 98.0% 101 / 103 CC 19 SCAR 25.8
CC
19
Cov
98%
process
19.0
BEGIN
1.0
BEGIN
1.0
CRAP 13.2
« Validator/Plugin/Field655.pm ↑ Summary Validator/Plugin/Field500.pm »
1 package MARC::Validator::Plugin::Field080;
2  
3 6 ▶use base qw(MARC::Validator::Abstract);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use Business::UDC 0.11;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Data::MARC::Validator::Report::Error 0.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Data::MARC::Validator::Report::Plugin::Errors 0.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 our $VERSION = 0.25;
12  
13 25 ▶sub module_name {
Subroutine module_name: called CC=1 SCAR=0.0
Pod documented
14 25 my $self = shift;
15  
16 25 return __PACKAGE__;
17 }
18  
19 26 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
20 26 my $self = shift;
21  
22 26 return 'field_080';
23 }
24  
25 23 ▶sub process {
Subroutine process: called CC=19 SCAR=29.5
Pod documented
26 23 my ($self, $marc_record) = @_;
27  
28 23 my $record_id = $self->{'cb_record_id'}->($marc_record);
29 23 my @record_errors;
30  
31 23 my @field_080 = $marc_record->field('080');
32 23 foreach my $field_080 (@field_080) {
33 92 my $field_080a = $field_080->subfield('a');
34 92 my $udc = Business::UDC->new($field_080a);
35 92 ▶ if (! $udc->is_valid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($udc->is_valid) 25 67 92
36 25 my ($udc_error, %udc_error_params) = $udc->error;
37 25 ▶ if ($udc_error eq 'Alphabetical specification cannot appear standalone.') {
Branch: 15 branches
BranchTrueFalseTotal
if ($udc_error eq 'Alphabetical specification cannot appear standalone.') { } 1 24 25
elsif ($udc_error eq 'Whitespace is not allowed in UDC string.') { } 3 21 24
elsif ($udc_error eq 'Bad apostrophe character.') { } 6 15 21
elsif ($udc_error eq 'Bad quotation mark character.') { } 4 11 15
elsif ($udc_error eq 'Bad dot character in number.') { } 1 10 11
elsif ($udc_error eq q[Missing opening parenthesis '('.]) { } 1 9 10
elsif ($udc_error eq q[Missing closing parenthesis ')'.]) { } 1 8 9
elsif ($udc_error eq q[Extra closing parenthesis ')'.]) { } 1 7 8
elsif ($udc_error eq q[Missing closing quotation mark '"'.]) { } 1 6 7
elsif ($udc_error eq q[Extra opening parenthesis '('.]) { } 1 5 6
elsif ($udc_error eq 'Invalid year in time auxiliary.') { } 1 4 5
elsif ($udc_error eq 'Bad hyphen character.') { } 1 3 4
elsif ($udc_error eq q[Extra dash '-'.]) { } 1 2 3
elsif ($udc_error eq q[Extra dot '.'.]) { } 1 1 2
elsif ($udc_error eq 'Missing operator.') { } 1 0 1
38 push @record_errors, Data::MARC::Validator::Report::Error->new(
39 'error' => "Field 080a has name standalone.",
40 'params' => {
41 'field_080_a' => $field_080a,
42 1 'position' => $udc_error_params{'position'},
43 },
44 );
45 } elsif ($udc_error eq 'Whitespace is not allowed in UDC string.') {
46 push @record_errors, Data::MARC::Validator::Report::Error->new(
47 'error' => "Field 080a has trailing space.",
48 'params' => {
49 'field_080_a' => $field_080a,
50 3 'position' => $udc_error_params{'position'},
51 },
52 );
53 } elsif ($udc_error eq 'Bad apostrophe character.') {
54 push @record_errors, Data::MARC::Validator::Report::Error->new(
55 'error' => "Field 080a has bad apostrophe character.",
56 'params' => {
57 'field_080_a' => $field_080a,
58 'character' => $udc_error_params{'character'},
59 6 'position' => $udc_error_params{'position'},
60 },
61 );
62 } elsif ($udc_error eq 'Bad quotation mark character.') {
63 push @record_errors, Data::MARC::Validator::Report::Error->new(
64 'error' => "Field 080a has bad quotation mark character.",
65 'params' => {
66 'field_080_a' => $field_080a,
67 'character' => $udc_error_params{'character'},
68 4 'position' => $udc_error_params{'position'},
69 },
70 );
71 } elsif ($udc_error eq 'Bad dot character in number.') {
72 push @record_errors, Data::MARC::Validator::Report::Error->new(
73 'error' => "Field 080a has bad dot character.",
74 'params' => {
75 'field_080_a' => $field_080a,
76 'character' => $udc_error_params{'character'},
77 1 'position' => $udc_error_params{'position'},
78 },
79 );
80 } elsif ($udc_error eq "Missing opening parenthesis '('.") {
81 push @record_errors, Data::MARC::Validator::Report::Error->new(
82 'error' => "Field 080a has missing opening parenthesis '('.",
83 'params' => {
84 'field_080_a' => $field_080a,
85 1 'position' => $udc_error_params{'position'},
86 },
87 );
88 } elsif ($udc_error eq "Missing closing parenthesis ')'.") {
89 push @record_errors, Data::MARC::Validator::Report::Error->new(
90 'error' => "Field 080a has missing closing parenthesis ')'.",
91 'params' => {
92 'field_080_a' => $field_080a,
93 1 'position' => $udc_error_params{'position'},
94 },
95 );
96 } elsif ($udc_error eq "Extra closing parenthesis ')'.") {
97 push @record_errors, Data::MARC::Validator::Report::Error->new(
98 'error' => "Field 080a has extra closing parenthesis ')'.",
99 'params' => {
100 'field_080_a' => $field_080a,
101 1 'position' => $udc_error_params{'position'},
102 },
103 );
104 } elsif ($udc_error eq "Missing closing quotation mark '\"'.") {
105 push @record_errors, Data::MARC::Validator::Report::Error->new(
106 'error' => "Field 080a has missing closing quotation mark '\"'.",
107 'params' => {
108 'field_080_a' => $field_080a,
109 1 'position' => $udc_error_params{'position'},
110 },
111 );
112 } elsif ($udc_error eq "Extra opening parenthesis '('.") {
113 push @record_errors, Data::MARC::Validator::Report::Error->new(
114 'error' => "Field 080a has extra opening parenthesis '('.",
115 'params' => {
116 'field_080_a' => $field_080a,
117 1 'position' => $udc_error_params{'position'},
118 },
119 );
120 } elsif ($udc_error eq "Invalid year in time auxiliary.") {
121 push @record_errors, Data::MARC::Validator::Report::Error->new(
122 'error' => "Field 080a has invalid year in time auxiliary.",
123 'params' => {
124 'field_080_a' => $field_080a,
125 1 'position' => $udc_error_params{'position'},
126 },
127 );
128 } elsif ($udc_error eq "Bad hyphen character.") {
129 push @record_errors, Data::MARC::Validator::Report::Error->new(
130 'error' => "Field 080a has bad hyphen character.",
131 'params' => {
132 'field_080_a' => $field_080a,
133 1 'position' => $udc_error_params{'position'},
134 },
135 );
136 } elsif ($udc_error eq "Extra dash '-'.") {
137 push @record_errors, Data::MARC::Validator::Report::Error->new(
138 'error' => "Field 080a has extra dash character.",
139 'params' => {
140 'field_080_a' => $field_080a,
141 1 'position' => $udc_error_params{'position'},
142 },
143 );
144 } elsif ($udc_error eq "Extra dot '.'.") {
145 push @record_errors, Data::MARC::Validator::Report::Error->new(
146 'error' => "Field 080a has extra dot character.",
147 'params' => {
148 'field_080_a' => $field_080a,
149 1 'position' => $udc_error_params{'position'},
150 },
151 );
152 } elsif ($udc_error eq "Missing operator.") {
153 push @record_errors, Data::MARC::Validator::Report::Error->new(
154 'error' => "Field 080a has missing operator.",
155 'params' => {
156 'field_080_a' => $field_080a,
157 1 'position' => $udc_error_params{'position'},
158 },
159 );
160 }
161 }
162 }
163  
164 23 ▶ if (@record_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@record_errors) 23 0 23
165 23 push @{$self->{'errors'}}, Data::MARC::Validator::Report::Plugin::Errors->new(
166 'errors' => \@record_errors,
167 23 'filters' => $self->{'filters'},
168 'record_id' => $record_id,
169 );
170 }
171  
172 23 return;
173 }
174  
175 25 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
Pod documented
176 25 my $self = shift;
177  
178 25 return $VERSION;
179 }
180  
181 6 1;
182  
183 __END__
« Validator/Plugin/Field655.pm ↑ Summary Validator/Plugin/Field500.pm »