From 130b78db744ddebc5a9e3dee8856ac599e4f8f9c Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 31 Aug 2008 09:14:18 +0000 Subject: [PATCH] r1733@llin: dpavlin | 2008-08-31 11:14:02 +0200 beginning of marc_clone git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1108 07558da8-63fa-0310-ba24-9fe276d99e06 --- TODO | 1 + lib/WebPAC/Normalize/MARC.pm | 16 ++++++++++++++++ t/3-normalize-marc.t | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/TODO b/TODO index 35d560a..e48c913 100644 --- a/TODO +++ b/TODO @@ -53,6 +53,7 @@ + csv/excel output conf/normalize/csv_ff-peri.pl [2.34] + fix input/excel encoding problems + use UTF-8 as internal encoding +- marc_clone to copy records/fields/indicators from input marc - rewrite WebPAC::Input to be based on Module::Pluggable - check usage of config in normalize file (database, input name?) - load_ds/save_ds should use on-disk hash to preserve inodes diff --git a/lib/WebPAC/Normalize/MARC.pm b/lib/WebPAC/Normalize/MARC.pm index 2126483..e298bc3 100644 --- a/lib/WebPAC/Normalize/MARC.pm +++ b/lib/WebPAC/Normalize/MARC.pm @@ -6,6 +6,7 @@ our @EXPORT = qw/ marc_duplicate marc_remove marc_count marc_original_order marc_template + marc_clone /; use strict; @@ -623,6 +624,21 @@ sub marc_count { return $#{ $marc_record }; } +=head2 marc_clone + +Clone marc records from input file, whole or just some fields/indicators + + marc_clone; # whole record + +=cut + +sub marc_clone { + foreach my $f ( keys %$rec ) { + warn "## clone $f"; + marc_original_order( $f, $f ); + } +} + =head1 PRIVATE FUNCTIONS =head2 _marc_push diff --git a/t/3-normalize-marc.t b/t/3-normalize-marc.t index 0a29c27..8c9f675 100755 --- a/t/3-normalize-marc.t +++ b/t/3-normalize-marc.t @@ -127,3 +127,25 @@ foreach my $from ( 0 .. $max_occ - 1 ) { } } + +sub test_marc_clone { + my $rec = shift; + + ok( _clean_ds(), '_clean_ds' ); + ok( _set_ds( $rec ), '_set_ds' ); + + ok( marc_clone, 'marc_clone' ); + + ok(my $marc = WebPAC::Normalize::MARC::_get_marc_fields(), "_get_marc_fields"); + diag "rec = ",dump( $rec ); + diag "marc = ",dump( $marc ); + + is_deeply( $rec, $marc, 'same' ); + +} + +test_marc_clone( { + '900' => [{ 'a' => '900a', 'b' => '900b', subfields => [ qw/a 0 b 0/ ] }], + '901' => [{ 'c' => '901c', subfields => [ qw/c 0/ ] }], +} ); + -- 2.20.1