[libcatmandu-marc-perl] 43/208: Adding fixes to help MARC validation Fix scripts
Jonas Smedegaard
dr at jones.dk
Sat Oct 28 03:42:33 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag upstream/1.19
in repository libcatmandu-marc-perl.
commit 1adf1753b8d29feeefe257a775df663b029fcc2d
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date: Mon Sep 12 11:37:57 2016 +0200
Adding fixes to help MARC validation Fix scripts
---
.../Fix/Condition/{marc_match.pm => marc_has.pm} | 24 ++++++++---------
.../Condition/{marc_match.pm => marc_has_many.pm} | 30 ++++++++++------------
lib/Catmandu/Fix/Condition/marc_match.pm | 2 +-
3 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/lib/Catmandu/Fix/Condition/marc_match.pm b/lib/Catmandu/Fix/Condition/marc_has.pm
similarity index 60%
copy from lib/Catmandu/Fix/Condition/marc_match.pm
copy to lib/Catmandu/Fix/Condition/marc_has.pm
index c0e5c02..e451f3a 100644
--- a/lib/Catmandu/Fix/Condition/marc_match.pm
+++ b/lib/Catmandu/Fix/Condition/marc_has.pm
@@ -1,7 +1,7 @@
-package Catmandu::Fix::Condition::marc_match;
+package Catmandu::Fix::Condition::marc_has;
use Catmandu::Sane;
use Catmandu::Fix::marc_map;
-use Catmandu::Fix::Condition::all_match;
+use Catmandu::Fix::Condition::exists;
use Catmandu::Fix::set_field;
use Catmandu::Fix::remove_field;
use Moo;
@@ -12,7 +12,6 @@ our $VERSION = '1.00_01';
with 'Catmandu::Fix::Condition';
has marc_path => (fix_arg => 1);
-has value => (fix_arg => 1);
sub emit {
my ($self,$fixer,$label) = @_;
@@ -23,7 +22,7 @@ sub emit {
my $marc_map = Catmandu::Fix::marc_map->new($self->marc_path , "$tmp_var.\$append");
$perl .= $marc_map->emit($fixer,$label);
- my $all_match = Catmandu::Fix::Condition::all_match->new("$tmp_var.*",$self->value);
+ my $all_match = Catmandu::Fix::Condition::exists->new("$tmp_var");
my $remove_field = Catmandu::Fix::remove_field->new($tmp_var);
my $pass_fixes = $self->pass_fixes;
@@ -39,30 +38,29 @@ sub emit {
=head1 NAME
-Catmandu::Fix::Condition::marc_match - Conditionals on MARC fields
+Catmandu::Fix::Condition::marc_has - Test if a MARC (sub)field exists
=head1 SYNOPSIS
- # marc_match(MARC_PATH,REGEX)
+ # marc_has(MARC_PATH)
- if marc_match('245','My funny title')
- add_field('my.funny.title','true')
+ unless marc_has('245')
+ add_field('error.$append','no 245 value!')
end
=head1 DESCRIPTION
-Evaluate the enclosing fixes only if the MARC (sub)field matches a
-regular expression.
+Evaluate the enclosing fixes only if the MARC (sub)field exists.
=head1 METHODS
-=head2 marc_match(MARC_PATH, REGEX)
+=head2 marc_has(MARC_PATH)
-Evaluates to true when the MARC_PATH values matches the REGEX, false otherwise.
+Evaluates to true when the MARC_PATH values exists, false otherwise.
=head1 SEE ALSO
-L<Catmandu::Fix>
+L<Catmandu::Fix::marc_has_many>
=cut
diff --git a/lib/Catmandu/Fix/Condition/marc_match.pm b/lib/Catmandu/Fix/Condition/marc_has_many.pm
similarity index 50%
copy from lib/Catmandu/Fix/Condition/marc_match.pm
copy to lib/Catmandu/Fix/Condition/marc_has_many.pm
index c0e5c02..58e392b 100644
--- a/lib/Catmandu/Fix/Condition/marc_match.pm
+++ b/lib/Catmandu/Fix/Condition/marc_has_many.pm
@@ -1,7 +1,7 @@
-package Catmandu::Fix::Condition::marc_match;
+package Catmandu::Fix::Condition::marc_has_many;
use Catmandu::Sane;
use Catmandu::Fix::marc_map;
-use Catmandu::Fix::Condition::all_match;
+use Catmandu::Fix::Condition::exists;
use Catmandu::Fix::set_field;
use Catmandu::Fix::remove_field;
use Moo;
@@ -12,7 +12,6 @@ our $VERSION = '1.00_01';
with 'Catmandu::Fix::Condition';
has marc_path => (fix_arg => 1);
-has value => (fix_arg => 1);
sub emit {
my ($self,$fixer,$label) = @_;
@@ -20,17 +19,17 @@ sub emit {
my $perl;
my $tmp_var = '_tmp_' . int(rand(9999));
- my $marc_map = Catmandu::Fix::marc_map->new($self->marc_path , "$tmp_var.\$append");
+ my $marc_map = Catmandu::Fix::marc_map->new($self->marc_path , "$tmp_var.\$append", -split=>1);
$perl .= $marc_map->emit($fixer,$label);
- my $all_match = Catmandu::Fix::Condition::all_match->new("$tmp_var.*",$self->value);
+ my $all_match = Catmandu::Fix::Condition::exists->new("$tmp_var.0.1");
my $remove_field = Catmandu::Fix::remove_field->new($tmp_var);
my $pass_fixes = $self->pass_fixes;
my $fail_fixes = $self->fail_fixes;
- $all_match->pass_fixes([ $remove_field , @$pass_fixes ]);
- $all_match->fail_fixes([ $remove_field , @$fail_fixes ]);
+ $all_match->pass_fixes([ @$pass_fixes ]);
+ $all_match->fail_fixes([ @$fail_fixes ]);
$perl .= $all_match->emit($fixer,$label);
@@ -39,30 +38,29 @@ sub emit {
=head1 NAME
-Catmandu::Fix::Condition::marc_match - Conditionals on MARC fields
+Catmandu::Fix::Condition::marc_has_many - Test if a MARC has more than one (sub)field
=head1 SYNOPSIS
- # marc_match(MARC_PATH,REGEX)
+ # marc_has_many(MARC_PATH)
- if marc_match('245','My funny title')
- add_field('my.funny.title','true')
+ if marc_has_many('245')
+ add_field('error.$append','more than one 245!')
end
=head1 DESCRIPTION
-Evaluate the enclosing fixes only if the MARC (sub)field matches a
-regular expression.
+Evaluate the enclosing fixes only if the MARC has more than one (sub)field.
=head1 METHODS
-=head2 marc_match(MARC_PATH, REGEX)
+=head2 marc_has_many(MARC_PATH)
-Evaluates to true when the MARC_PATH values matches the REGEX, false otherwise.
+Evaluates to true when the MARC has more than one (sub)field, false otherwise.
=head1 SEE ALSO
-L<Catmandu::Fix>
+L<Catmandu::Fix::marc_has>
=cut
diff --git a/lib/Catmandu/Fix/Condition/marc_match.pm b/lib/Catmandu/Fix/Condition/marc_match.pm
index c0e5c02..d63cf6b 100644
--- a/lib/Catmandu/Fix/Condition/marc_match.pm
+++ b/lib/Catmandu/Fix/Condition/marc_match.pm
@@ -39,7 +39,7 @@ sub emit {
=head1 NAME
-Catmandu::Fix::Condition::marc_match - Conditionals on MARC fields
+Catmandu::Fix::Condition::marc_match - Test if a MARC (sub)field matches a value
=head1 SYNOPSIS
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git
More information about the Pkg-perl-cvs-commits
mailing list