r1733@llin: dpavlin | 2008-08-31 11:14:02 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 31 Aug 2008 09:14:18 +0000 (09:14 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 31 Aug 2008 09:14:18 +0000 (09:14 +0000)
 beginning of marc_clone

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1108 07558da8-63fa-0310-ba24-9fe276d99e06

TODO
lib/WebPAC/Normalize/MARC.pm
t/3-normalize-marc.t

diff --git a/TODO b/TODO
index 35d560a..e48c913 100644 (file)
--- 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
index 2126483..e298bc3 100644 (file)
@@ -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
index 0a29c27..8c9f675 100755 (executable)
@@ -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/ ]                }],
+} );
+