Skip to content

Commit

Permalink
Merge pull request #48 from jorol/dev
Browse files Browse the repository at this point in the history
Upgrading Catmandu using new group binds for pica_each
  • Loading branch information
jorol committed Jun 30, 2017
2 parents 41f785b + d9f8d64 commit e72a5e5
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
Expand Up @@ -5,7 +5,7 @@ on 'test', sub {
requires 'IO::File' , '1.14';
};

requires 'Catmandu', '0.9504';
requires 'Catmandu', '1.0601';
requires 'PICA::Data', '0.30';
requires 'PICA::Parser', '0.585';
requires 'PICA::Path', '0.31';
Expand Down
6 changes: 3 additions & 3 deletions lib/Catmandu/Fix/Bind/pica_each.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ our $VERSION = '0.19';
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-pica-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 pica_match("010@a",'ger')
add_field(is_ger,true)
end
if pica_match("045.",'.*')
reject()
end
end
pica_map("045.",test)
|]);

my $importer = Catmandu::Importer::PICA->new( file => './t/files/picaplus.dat', type => "PLUS" );
my $record = $fixer->fix($importer->first);

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

done_testing;

0 comments on commit e72a5e5

Please sign in to comment.