[libcatmandu-marc-perl] 198/208: Adding a default FMT field when none is given
Jonas Smedegaard
dr at jones.dk
Sat Oct 28 03:42:50 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 6cc4a5dcdc1f6ee5f7f0b98c4bdbe516f352e401
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date: Tue Sep 26 07:40:31 2017 +0200
Adding a default FMT field when none is given
---
Build.PL | 2 +-
README.md | 1 +
lib/Catmandu/Exporter/MARC/ALEPHSEQ.pm | 16 ++++++++++++++--
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Build.PL b/Build.PL
index 4783371..dd4aa2a 100644
--- a/Build.PL
+++ b/Build.PL
@@ -1,5 +1,5 @@
-# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.005.
+# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.008.
use strict;
use warnings;
diff --git a/README.md b/README.md
index 47d065c..c95b181 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,7 @@ Catmandu::MARC - Catmandu modules for working with MARC data
# MODULES
+- [Catmandu::MARC::Tutorial](https://metacpan.org/pod/Catmandu::MARC::Tutorial)
- [Catmandu::Importer::MARC](https://metacpan.org/pod/Catmandu::Importer::MARC)
- [Catmandu::Exporter::MARC](https://metacpan.org/pod/Catmandu::Exporter::MARC)
- [Catmandu::Fix::marc\_map](https://metacpan.org/pod/Catmandu::Fix::marc_map)
diff --git a/lib/Catmandu/Exporter/MARC/ALEPHSEQ.pm b/lib/Catmandu/Exporter/MARC/ALEPHSEQ.pm
index fbd88d3..dca0253 100644
--- a/lib/Catmandu/Exporter/MARC/ALEPHSEQ.pm
+++ b/lib/Catmandu/Exporter/MARC/ALEPHSEQ.pm
@@ -40,6 +40,10 @@ An ARRAY of one or more fixes or file scripts to be applied to exported items.
Binmode of the output stream C<fh>. Set to "C<:utf8>" by default.
+=item default_fmt
+
+Set the value of the default C<FMT> field when none is given. Set to C<BK> by default.
+
=back
=head1 METHODS
@@ -63,8 +67,9 @@ our $VERSION = '1.18';
with 'Catmandu::Exporter', 'Catmandu::Exporter::MARC::Base';
has record => (is => 'ro' , default => sub { 'record'});
-has record_format => (is => 'ro', default => sub { 'raw'} );
+has record_format => (is => 'ro' , default => sub { 'raw'} );
has skip_empty_subfields => (is => 'ro' , default => sub { 0 });
+has default_fmt => (is => 'ro' , default => sub { 'BK'} );
sub add {
my ($self,$data) = @_;
@@ -73,11 +78,18 @@ sub add {
$data = $self->_json_to_raw($data);
}
- my $_id = sprintf("%-9.9d", $data->{_id} // 0);
+ my $id_str = $data->{_id};
+ $id_str =~ s{\D}{0}g if defined $id_str;
+ my $_id = sprintf("%-9.9d", $id_str // 0);
my $record = $data->{$self->record};
my @lines = ();
+ # Check required FMT field
+ if (@$record > 0 && $record->[0]->[0] ne 'FMT') {
+ push @lines , join('',$_id, ' ' , 'FMT', ' ', ' ' , ' L ' , $self->default_fmt);
+ }
+
for my $field (@$record) {
my ($tag,$ind1,$ind2, at data) = @$field;
--
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