r842@llin: dpavlin | 2006-07-23 22:23:52 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 23 Jul 2006 20:19:56 +0000 (20:19 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 23 Jul 2006 20:19:56 +0000 (20:19 +0000)
 append subfields

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

conf/normalize/mapping.pl
lib/WebPAC/Normalize.pm
t/3-normalize.t

index 5bc195b..a69223c 100644 (file)
@@ -89,7 +89,7 @@ marc_compose('245',
        'b', rec('200','e'),
        'c', rec('200','f'),
 # FIXME append to last subfield
-#      '+', prefix('. ', rec('200','c') ),
+       '+', prefix('. ', rec('200','c') ),
 );
 
 
@@ -255,7 +255,7 @@ marc('100','a',
        )
 );
 
-_debug(2);
+#_debug(2);
 
 marc_indicators('700', 1, ' ');
 
@@ -320,7 +320,7 @@ marc('700','a',
        )
 );
 
-_debug(0);
+#_debug(0);
 
 
 if ( rec('710','f') ) {
index d36b7b7..1a144f8 100644 (file)
@@ -35,11 +35,11 @@ WebPAC::Normalize - describe normalisaton rules using sets
 
 =head1 VERSION
 
-Version 0.14
+Version 0.15
 
 =cut
 
-our $VERSION = '0.14';
+our $VERSION = '0.15';
 
 =head1 SYNOPSIS
 
@@ -525,6 +525,9 @@ Save values for each MARC subfield explicitly
        'c', rec('200','c')
   );
 
+If you specify C<+> for subfield, value will be appended
+to previous defined subfield.
+
 =cut
 
 sub marc_compose {
@@ -542,8 +545,12 @@ sub marc_compose {
 
                next unless (defined($v) && $v !~ /^\s*$/);
                from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding);
-               push @$m, ( $sf, $v );
                warn "## ++ marc_compose($f,$sf,$v) ", dump( $m ),$/ if ($debug > 1);
+               if ($sf ne '+') {
+                       push @$m, ( $sf, $v );
+               } else {
+                       $m->[ $#$m ] .= $v;
+               }
        }
 
        warn "## marc_compose current marc = ", dump( $m ),$/ if ($debug > 1);
index 0a0873e..1fa10b8 100755 (executable)
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 147;
+use Test::More tests => 150;
 use Test::Exception;
 use Cwd qw/abs_path/;
 use blib;
@@ -479,6 +479,22 @@ sub test_s {
                ],
        );
 
+       test_rec_rules(
+               'marc_compose with + subfields',
+               { '200' => [{ a => 'foo ; bar', b => 42, c => 'baz' }] },
+               qq{
+                       marc_compose('900',
+                               'a', rec(200,'a'),
+                               '+', prefix(" * ", rec(200,'c')),
+                               'b', rec(200,'b'),
+                               '+', prefix(" : ", rec(200,'c')),
+                       );
+               },
+               [
+                       [ '900', ' ', ' ', 'a', 'foo ; bar * baz', 'b', '42 : baz' ]
+               ],
+       );
+
        #
        # test rules
        #