From 5573c556fe4b76576fa7a1bd33ed320d2fc9b437 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 19 Nov 2007 16:33:09 +0000 Subject: [PATCH] r1633@llin: dpavlin | 2007-11-19 17:33:09 +0100 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 | 3 ++- lib/WebPAC/Normalize.pm | 2 +- t/3-normalize.t | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index d814ef3..17665e0 100644 --- 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 diff --git a/lib/WebPAC/Normalize.pm b/lib/WebPAC/Normalize.pm index 84b5fee..782c5f3 100644 --- a/lib/WebPAC/Normalize.pm +++ b/lib/WebPAC/Normalize.pm @@ -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 diff --git a/t/3-normalize.t b/t/3-normalize.t index 5163f73..5c59052 100755 --- a/t/3-normalize.t +++ b/t/3-normalize.t @@ -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' ] ); + } -- 2.20.1