| 1 | package MARC::Validator::Abstract; | ||||||||||
| 2 | |||||||||||
| 3 | 62 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 62 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 62 | ▶ | use Class::Utils qw(set_params); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 62 | ▶ | use Data::MARC::Validator::Report::Plugin 0.02; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 62 | ▶ | use Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 62 | ▶ | use Mo::utils 0.06 qw(check_bool check_required); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 62 | our $VERSION = 0.25; | |||||||||
| 12 | |||||||||||
| 13 | # Constructor. | ||||||||||
| 14 | 115 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 15 | 115 | my ($class, @params) = @_; | |||||||||
| 16 | |||||||||||
| 17 | # Create object. | ||||||||||
| 18 | 115 | my $self = bless {}, $class; | |||||||||
| 19 | |||||||||||
| 20 | # Debug mode. | ||||||||||
| 21 | 115 | $self->{'debug'} = 0; | |||||||||
| 22 | |||||||||||
| 23 | # Errors. | ||||||||||
| 24 | 115 | $self->{'errors'} = []; | |||||||||
| 25 | |||||||||||
| 26 | # Filters. | ||||||||||
| 27 | 115 | $self->{'filters'} = []; | |||||||||
| 28 | |||||||||||
| 29 | # Recommendation. | ||||||||||
| 30 | 115 | $self->{'recommendation'} = 0; | |||||||||
| 31 | |||||||||||
| 32 | # Record id definition. | ||||||||||
| 33 | 115 | $self->{'record_id_def'} = '001'; | |||||||||
| 34 | |||||||||||
| 35 | # Verbose mode. | ||||||||||
| 36 | 115 | $self->{'verbose'} = 0; | |||||||||
| 37 | |||||||||||
| 38 | # Process parameters. | ||||||||||
| 39 | 115 | set_params($self, @params); | |||||||||
| 40 | |||||||||||
| 41 | # Check 'debug'. | ||||||||||
| 42 | 115 | check_bool($self, 'debug'); | |||||||||
| 43 | |||||||||||
| 44 | # Check 'recommendation'. | ||||||||||
| 45 | 103 | check_bool($self, 'recommendation'); | |||||||||
| 46 | |||||||||||
| 47 | # Check 'record_id_def'. | ||||||||||
| 48 | 103 | check_required($self, 'record_id_def'); | |||||||||
| 49 | |||||||||||
| 50 | # Check 'verbose'. | ||||||||||
| 51 | 103 | check_bool($self, 'verbose'); | |||||||||
| 52 | |||||||||||
| 53 | 103 | return $self; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | # Initialization. | ||||||||||
| 57 | 68 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 58 | 68 | my $self = shift; | |||||||||
| 59 | |||||||||||
| 60 | 58 | ▶ | $self->{'cb_record_id'} = sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||
| 61 | 58 | my $marc_record = shift; | |||||||||
| 62 | |||||||||||
| 63 | 58 | my $record_id; | |||||||||
| 64 | 58 | my ($field, $subfield) = $self->{'record_id_def'} =~ m/^(\d+)(.*)$/ms; | |||||||||
| 65 | 58 | my $field_obj = $marc_record->field($field); | |||||||||
| 66 | 58 | ▶ | if (defined $field_obj) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 58 | ▶ | if ($subfield) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 56 | $record_id = $field_obj->subfield($subfield); | |||||||||
| 69 | } else { | ||||||||||
| 70 | 2 | $record_id = $field_obj->as_string; | |||||||||
| 71 | } | ||||||||||
| 72 | } else { | ||||||||||
| 73 | err 'Record id is not defined.', | ||||||||||
| 74 | 0 | 'Record id definition', $self->{'record_id_def'}, | |||||||||
| 75 | ; | ||||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 58 | return $record_id; | |||||||||
| 79 | 68 | }; | |||||||||
| 80 | |||||||||||
| 81 | # Plugin initialization. | ||||||||||
| 82 | 68 | $self->_init; | |||||||||
| 83 | |||||||||||
| 84 | 68 | return; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | # Module name. | ||||||||||
| 88 | 0 | ▶ | sub module_name { | ||||||||
|
Subroutine
module_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 89 | 0 | my $self = shift; | |||||||||
| 90 | |||||||||||
| 91 | 0 | err __PACKAGE__.' is abstract class.'; | |||||||||
| 92 | } | ||||||||||
| 93 | |||||||||||
| 94 | # Name of plugin. | ||||||||||
| 95 | 0 | ▶ | sub name { | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 96 | 0 | my $self = shift; | |||||||||
| 97 | |||||||||||
| 98 | 0 | err __PACKAGE__.' is abstract class,'; | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | 0 | ▶ | sub postprocess { | ||||||||
|
Subroutine
postprocess: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 102 | 0 | my $self = shift; | |||||||||
| 103 | |||||||||||
| 104 | 0 | return; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | # Process statistics. | ||||||||||
| 108 | 0 | ▶ | sub process { | ||||||||
|
Subroutine
process: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 109 | 0 | my ($self, $marc_record) = @_; | |||||||||
| 110 | |||||||||||
| 111 | 0 | err __PACKAGE__.' is abstract class.'; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | sub set_filters { | ||||||||
|
Subroutine
set_filters: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 115 | 0 | my ($self, @filters) = @_; | |||||||||
| 116 | |||||||||||
| 117 | 0 | $self->{'filters'} = \@filters; | |||||||||
| 118 | |||||||||||
| 119 | 0 | return; | |||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | 79 | ▶ | sub report { | ||||||||
|
Subroutine
report: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 123 | 79 | my $self = shift; | |||||||||
| 124 | |||||||||||
| 125 | my $plugin_report = Data::MARC::Validator::Report::Plugin->new( | ||||||||||
| 126 | 'module_name' => $self->module_name, | ||||||||||
| 127 | 'name' => $self->name, | ||||||||||
| 128 | 79 | 'plugin_errors' => $self->{'errors'}, | |||||||||
| 129 | 'version' => $self->version, | ||||||||||
| 130 | ); | ||||||||||
| 131 | |||||||||||
| 132 | 79 | return $plugin_report; | |||||||||
| 133 | } | ||||||||||
| 134 | |||||||||||
| 135 | # Version of plugin. | ||||||||||
| 136 | 0 | ▶ | sub version { | ||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 137 | 0 | my $self = shift; | |||||||||
| 138 | |||||||||||
| 139 | 0 | err __PACKAGE__.' is abstract class,'; | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | 65 | ▶ | sub _init { | ||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||
| 143 | 65 | my $self = shift; | |||||||||
| 144 | |||||||||||
| 145 | 65 | return; | |||||||||
| 146 | } | ||||||||||
| 147 | |||||||||||
| 148 | 62 | 1; | |||||||||
| 149 | |||||||||||
| 150 | __END__ | ||||||||||