| 1 | package MARC::Validator::Plugin::Field655; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 Data::MARC::Validator::Report::Error 0.02; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Data::MARC::Validator::Report::Plugin::Errors 0.02; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use English; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Error::Pure::Utils qw(clean); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use MARC::Leader 0.08; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use MARC::Field008; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use MARC::Validator::Const; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | our $VERSION = 0.25; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | sub module_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | return __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | return 'field_655'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=16 SCAR=31.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | my ($self, $marc_record) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | my $record_id = $self->{'cb_record_id'}->($marc_record); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | my @record_errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | my $leader_string = $marc_record->leader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my $leader = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | MARC::Leader->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | 'verbose' => $self->{'verbose'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | )->parse($leader_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | if ($EVAL_ERROR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | clean(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | my $field_008_obj = $marc_record->field('008'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | if (! defined $field_008_obj) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | my $field_008_string = $field_008_obj->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | my $field_008 = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | MARC::Field008->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'leader' => $leader, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | 'verbose' => $self->{'verbose'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | )->parse($field_008_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | ▶ | if ($EVAL_ERROR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | clean(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | my $field_655 = $marc_record->field('655'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | ▶ | if (defined $field_655) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | my $field_655a = $field_655->subfield('a'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | if (defined $field_655a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | my $material = $field_008->material; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | my $lang = $marc_record->subfield('040', 'b'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | ▶ | if (! defined $lang) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | my $qr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | foreach my $qr_ar (['comics', '6'], ['textbook', 'p']) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 4 | ▶ | if (exists $MARC::Validator::Const::FIELD_655{$lang} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $MARC::Validator::Const::FIELD_655{$lang} and exists $MARC::Validator::Const::FIELD_655{$lang}{$qr_ar->[0]}
MC/DC0%0/2
exists $MARC::Validator::Const::FIELD_655{$lang} and exists $MARC::Validator::Const::FIELD_655{$lang}{$qr_ar->[0]}
exists $MARC::Validator::Const::FIELD_655{$lang}
exists $MARC::Validator::Const::FIELD_655{$lang}{$qr_ar->[0]}
Truth table33%1/3
A and B
A= exists $MARC::Validator::Const::FIELD_655{$lang}B= exists $MARC::Validator::Const::FIELD_655{$lang}{$qr_ar->[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | && exists $MARC::Validator::Const::FIELD_655{$lang}->{$qr_ar->[0]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | $qr = $MARC::Validator::Const::FIELD_655{$lang}->{$qr_ar->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | if (! defined $qr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | if ($material->isa('Data::MARC::Field008::Book') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$material->isa("Data::MARC::Field008::Book") and $material->nature_of_content ne "||||" and $field_655a =~ /$qr/ and not $material->nature_of_content =~ /$qr_ar->[1]/
$material->isa("Data::MARC::Field008::Book") and $material->nature_of_content ne "||||" and $field_655a =~ /$qr/
$material->isa("Data::MARC::Field008::Book") and $material->nature_of_content ne "||||"
MC/DC25%1/4
$material->isa("Data::MARC::Field008::Book") and $material->nature_of_content ne "||||" and $field_655a =~ /$qr/ and not $material->nature_of_content =~ /$qr_ar->[1]/
$material->isa("Data::MARC::Field008::Book")
$material->nature_of_content ne "||||"
$field_655a =~ /$qr/
not $material->nature_of_content =~ /$qr_ar->[1]/
Truth table40%2/5
A and B and C and not(D)
A= $material->isa("Data::MARC::Field008::Book")B= $material->nature_of_content ne "||||"C= $field_655a =~ /$qr/D= not $material->nature_of_content =~ /$qr_ar->[1]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | && $material->nature_of_content ne '||||' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | && $field_655a =~ $qr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | && $material->nature_of_content !~ $qr_ar->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | push @record_errors, Data::MARC::Validator::Report::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 'error' => 'Missing '.$qr_ar->[0].' nature of content in field 008.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 'params' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 'field_008_nature_of_content' => $material->nature_of_content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'field_655_a' => $field_655a, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 'material' => 'book', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | ▶ | if (@record_errors) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | push @{$self->{'errors'}}, Data::MARC::Validator::Report::Plugin::Errors->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 'errors' => \@record_errors, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | 'filters' => $self->{'filters'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 'record_id' => $record_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | return $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||