r1633@llin: dpavlin | 2007-11-19 17:33:09 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 19 Nov 2007 16:33:09 +0000 (16:33 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 19 Nov 2007 16:33:09 +0000 (16:33 +0000)
 fetch indicators with rec(900,'i1') and/or rec(900,'i2') as it should be
 (fixed bug which prevented this from working for some values like 0)

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

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

diff --git a/TODO b/TODO
index d814ef3..17665e0 100644 (file)
--- a/TODO
+++ b/TODO
@@ -46,7 +46,8 @@
 + ISBN support in normalize
 + marc_template (WebPAC v1 in a command) [2.31]
 + marc_template must use marc_indicators data
-- indicator(field,nr) nr=1|2 for MARC input -> rec(field,'i1')
++ indicator(field,nr) nr=1|2 for MARC input -> rec(field,'i1') or rec(field,'i2')
+- validator don't accept 0 as valid subfield
 - 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 84b5fee..782c5f3 100644 (file)
@@ -449,7 +449,7 @@ sub rec2 {
                } else {
                        $_->{$sf};
                }
-       } grep { ref($_) eq 'HASH' && $_->{$sf} } @{ $rec->{$f} };
+       } grep { ref($_) eq 'HASH' && defined $_->{$sf} } @{ $rec->{$f} };
 }
 
 =head2 rec
index 5163f73..5c59052 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use blib;
 
-use Test::More tests => 340;
+use Test::More tests => 344;
 
 BEGIN {
        use_ok( 'WebPAC::Test' );
@@ -870,6 +870,7 @@ sub test_s {
                        '200' => [ {
                                a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ],
                                subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ],
+                               i1 => '0', i2 => '1',
                        }, {
                                a => [ 'a3', 'a4', 'a5' ], b => 'b3', c => 'c3',
                                subfields => [ qw/a 0 a 1 b 0 c 0 a 2/ ],
@@ -892,5 +893,8 @@ sub test_s {
                ok( frec_ne( '200' => $sf, '200' => 'c' ), "frec_ne 200 $sf == 200 c");
        }
 
+       test_rule( 'rec(200,i1)', $rec, qq{ rec(200,'i1') }, [ '0' ] );
+       test_rule( 'rec(200,i2)', $rec, qq{ rec(200,'i2') }, [ '1' ] );
+
 }