marc_original_order has now arguments in order marc_field, original_field to
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Aug 2006 14:29:43 +0000 (14:29 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Aug 2006 14:29:43 +0000 (14:29 +0000)
be consistent with other directives

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

lib/WebPAC/Normalize.pm
t/3-normalize.t

index 62e289a..2956604 100644 (file)
@@ -36,11 +36,11 @@ WebPAC::Normalize - describe normalisaton rules using sets
 
 =head1 VERSION
 
-Version 0.15
+Version 0.16
 
 =cut
 
-our $VERSION = '0.15';
+our $VERSION = '0.16';
 
 =head1 SYNOPSIS
 
@@ -646,29 +646,36 @@ sub marc_remove {
 
 Copy all subfields preserving original order to marc field.
 
-  marc_original_order(210, 260);
+  marc_original_order( marc_field_number, original_input_field_number );
+
+Please note that field numbers are consistent with other commands (marc
+field number first), but somewhat counter-intuitive (destination and then
+source).
 
 You might want to use this command if you are just renaming subfields or
 using pre-processing modify_record in C<config.yml> and don't need any
 post-processing or want to preserve order of original subfields.
 
+
 =cut
 
 sub marc_original_order {
 
-       my ($from, $to) = @_;
+       my ($to, $from) = @_;
        die "marc_original_order needs from and to fields\n" unless ($from && $to);
 
-       my $r = $rec->{$from} || return;
+       return unless defined($rec->{$from});
+
+       my $r = $rec->{$from};
        die "record field $from isn't array\n" unless (ref($r) eq 'ARRAY');
 
        my ($i1,$i2) = defined($marc_indicators->{$to}) ? @{ $marc_indicators->{$to} } : (' ',' ');
-       warn "## marc_original_order($from,$to) source = ", dump( $r ),$/ if ($debug > 1);
+       warn "## marc_original_order($to,$from) source = ", dump( $r ),$/ if ($debug > 1);
 
        foreach my $d (@$r) {
 
                if (! defined($d->{subfields}) && ref($d->{subfields}) ne 'ARRAY') {
-                       warn "# marc_original_order($from,$to): field $from doesn't have subfields specification\n";
+                       warn "# marc_original_order($to,$from): field $from doesn't have subfields specification\n";
                        next;
                }
        
index 5ac6dd2..da741bb 100755 (executable)
@@ -657,7 +657,7 @@ sub test_s {
                        } ],
                },
                qq{
-                       marc_original_order(200,900);
+                       marc_original_order(900,200);
                },
                [
                        [ '900', ' ', ' ', 'a', 'a1', 'b', 'b1', 'a', 'a2', 'b', 'b2', 'c', 'c1', 'c', 'c2', ],