Skip to content

Commit

Permalink
Upgrading Catmandu using new group binds for mab_each
Browse files Browse the repository at this point in the history
  • Loading branch information
jorol committed Jun 30, 2017
1 parent bc57681 commit 89cf2a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cpanfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
requires 'perl', 'v5.10.1';

requires 'Catmandu', '0.9504';
requires 'Catmandu', '1.0601';
requires 'Catmandu::SRU', '>= 0.032';
requires 'Readonly';

Expand Down
6 changes: 3 additions & 3 deletions lib/Catmandu/Fix/Bind/mab_each.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ our $VERSION = '0.14';
use Moo;
use Catmandu::Util;

with 'Catmandu::Fix::Bind';
with 'Catmandu::Fix::Bind', 'Catmandu::Fix::Bind::Group';

has done => (is => 'ro');

Expand All @@ -16,7 +16,7 @@ sub unit {
}

sub bind {
my ($self,$mvar,$func,$name,$fixer) = @_;
my ($self,$mvar,$code) = @_;

return $mvar if $self->done;

Expand All @@ -28,7 +28,7 @@ sub bind {

$mvar->{record} = [$row];

my $fixed = $fixer->fix($mvar);
my $fixed = $code->($mvar);

push @new , @{$fixed->{record}} if defined($fixed) && exists $fixed->{record};
}
Expand Down
5 changes: 0 additions & 5 deletions t/07-mab-each.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ my $fixer = Catmandu::Fix->new(fixes => [q|
if mab_match("03.",'ger')
add_field(is_ger,true)
end
if mab_match("542",'.*')
reject()
end
end
mab_map("542",test)
|]);

my $importer = Catmandu::Importer::MAB2->new( file => './t/mab2.xml', type => "XML" );
my $record = $fixer->fix($importer->first);

ok exists $record->{record}, 'created a MAB2 record';
is $record->{is_ger}, 'true', 'created is_ger tag';
ok ! exists $record->{test} , 'fields 542 deleted';

done_testing;

0 comments on commit 89cf2a2

Please sign in to comment.