Validator/Plugin/Field080.pm

filter: Statementstmt 100% 48 / 48 Branchbran 90.0% 18 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 97.5% 80 / 82 CC 12 SCAR 19.9
CC
12
Cov
97%
process
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.3
« Validator/Plugin/Field300.pm ↑ Summary Validator/Plugin/Field264.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.09;
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.23;
12  
13 18 ▶sub module_name {
Subroutine module_name: called CC=1 SCAR=0.0
Pod documented
14 18 my $self = shift;
15  
16 18 return __PACKAGE__;
17 }
18  
19 19 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
20 19 my $self = shift;
21  
22 19 return 'field_080';
23 }
24  
25 16 ▶sub process {
Subroutine process: called CC=12 SCAR=24.9
Pod documented
26 16 my ($self, $marc_record) = @_;
27  
28 16 my $record_id = $self->{'cb_record_id'}->($marc_record);
29 16 my @record_errors;
30  
31 16 my @field_080 = $marc_record->field('080');
32 16 foreach my $field_080 (@field_080) {
33 62 my $field_080a = $field_080->subfield('a');
34 62 my $udc = Business::UDC->new($field_080a);
35 62 ▶ if (! $udc->is_valid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($udc->is_valid) 18 44 62
36 18 my ($udc_error, %udc_error_params) = $udc->error;
37 18 ▶ if ($udc_error eq 'Alphabetical specification cannot appear standalone.') {
Branch: 8 branches
BranchTrueFalseTotal
if ($udc_error eq 'Alphabetical specification cannot appear standalone.') { } 1 17 18
elsif ($udc_error eq 'Whitespace is not allowed in UDC string.') { } 3 14 17
elsif ($udc_error eq 'Bad apostrophe character.') { } 6 8 14
elsif ($udc_error eq 'Bad quotation mark character.') { } 4 4 8
elsif ($udc_error eq 'Bad dot character in number.') { } 1 3 4
elsif ($udc_error eq q[Missing opening parenthesis '('.]) { } 1 2 3
elsif ($udc_error eq q[Missing closing parenthesis ')'.]) { } 1 1 2
elsif ($udc_error eq q[Extra closing parenthesis ')'.]) { } 1 0 1
38 1 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 },
43 );
44 } elsif ($udc_error eq 'Whitespace is not allowed in UDC string.') {
45 3 push @record_errors, Data::MARC::Validator::Report::Error->new(
46 'error' => "Field 080a has trailing space.",
47 'params' => {
48 'field_080_a' => $field_080a,
49 },
50 );
51 } elsif ($udc_error eq 'Bad apostrophe character.') {
52 push @record_errors, Data::MARC::Validator::Report::Error->new(
53 'error' => "Field 080a has bad apostrophe character.",
54 'params' => {
55 'field_080_a' => $field_080a,
56 6 'character' => $udc_error_params{'character'},
57 },
58 );
59 } elsif ($udc_error eq 'Bad quotation mark character.') {
60 push @record_errors, Data::MARC::Validator::Report::Error->new(
61 'error' => "Field 080a has bad quotation mark character.",
62 'params' => {
63 'field_080_a' => $field_080a,
64 4 'character' => $udc_error_params{'character'},
65 },
66 );
67 } elsif ($udc_error eq 'Bad dot character in number.') {
68 push @record_errors, Data::MARC::Validator::Report::Error->new(
69 'error' => "Field 080a has bad dot character.",
70 'params' => {
71 'field_080_a' => $field_080a,
72 1 'character' => $udc_error_params{'character'},
73 },
74 );
75 } elsif ($udc_error eq "Missing opening parenthesis '('.") {
76 push @record_errors, Data::MARC::Validator::Report::Error->new(
77 'error' => "Field 080a has missing opening parenthesis '('.",
78 'params' => {
79 'field_080_a' => $field_080a,
80 1 'character' => $udc_error_params{'character'},
81 },
82 );
83 } elsif ($udc_error eq "Missing closing parenthesis ')'.") {
84 push @record_errors, Data::MARC::Validator::Report::Error->new(
85 'error' => "Field 080a has missing closing parenthesis ')'.",
86 'params' => {
87 'field_080_a' => $field_080a,
88 1 'character' => $udc_error_params{'character'},
89 },
90 );
91 } elsif ($udc_error eq "Extra closing parenthesis ')'.") {
92 push @record_errors, Data::MARC::Validator::Report::Error->new(
93 'error' => "Field 080a has extra closing parenthesis ')'.",
94 'params' => {
95 'field_080_a' => $field_080a,
96 1 'character' => $udc_error_params{'character'},
97 },
98 );
99 }
100 }
101 }
102  
103 16 ▶ if (@record_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@record_errors) 16 0 16
104 16 push @{$self->{'errors'}}, Data::MARC::Validator::Report::Plugin::Errors->new(
105 'errors' => \@record_errors,
106 16 'filters' => $self->{'filters'},
107 'record_id' => $record_id,
108 );
109 }
110  
111 16 return;
112 }
113  
114 18 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
Pod documented
115 18 my $self = shift;
116  
117 18 return $VERSION;
118 }
119  
120 6 1;
121  
122 __END__
« Validator/Plugin/Field300.pm ↑ Summary Validator/Plugin/Field264.pm »