my $dataf = $self->{data}{crec}{tags}[-1];
my $field = $map->field($tag, $code);
- # handle modifiers
+ # test filters
+ for my $filter ( @{$map->filters($field)} ) {
+ return if ($sub->text =~ /$filter/i);
+ }
+ # handle multi modifier
if (my $mods = $map->mods($field)) {
if ($mods->{multi}) {
my $name = $tag . $code;
}
}
+ # if this were a multi field, it would be handled already. make sure its a singleton
die "Multiple occurances of a non-multi field: $tag$code at rec ",
($self->{data}{rptr} + 1),"\n" if (defined $dataf->{uni}{$code});
+
+ # everything seems okay
$dataf->{uni}{$code} = $sub->text;
}
$tok .= ' ' . shift @tokens
until ($tokens[0] =~ m/'$/);
$tok .= ' ' . shift @tokens;
- $tok =~ s/^'//;
+ $tok =~ s/'//;
$tok =~ s/'$//;
}
if ($tok =~ m/^m:/)
#!perl -T
-use Test::More tests => 40;
+use Test::More tests => 41;
#use Test::More qw(no_plan);
use Equinox::Migration::SubfieldMapper;
is_deeply ($sm->mods('note_alt'), { multi => 1, req => 1 }, 'multi, req');
is_deeply ($sm->mods('date_a'), { foo => 1, bar => 1, quux => 1 });
is_deeply ($sm->filters('date_a'), ['one two three']);
+is_deeply ($sm->filters('type'), ['foo']);
'999$x - multi');
is ($mp->{data}{tmap}{250}, undef, 'tag map test 2a');
is_deeply ($mp->{data}{tmap}{999}, [0], 'tag map test 2b');
+
+# map-05 is map-04 with a "no digits" filter on 999$x
+$mp = Equinox::Migration::MapDrivenMARCXMLProc->new( marcfile => 't/corpus/mdmp-0.txt',
+ mapfile => 't/corpus/mdmpmap-05.txt');
+is_deeply ($mp->{map}->filters('multi_field'), ['\d']);
+$rec = $mp->parse_record;
+$rec = $mp->parse_record;
+$rec = $mp->parse_record;
+$rec = $mp->parse_record;
+is_deeply ($rec->{tags}[0]{multi}{'999x'}, ['FICTION'], '999$x - multi no digits');
call_num 999 a
-multi_field 999 x m:multi f:\\d
+multi_field 999 x m:multi f:\d
edition 250 a
library_alt 999 m
note 949 o m:multi
note_alt 999 o m:multi m:req
-type 949 t
+type 949 t f:foo
type_alt 999 t
date_a 949 v m:foo m:bar f:'one two three' m:quux
date_a_alt 999 v