Added hash_filter when using MARC::Fast 0.12
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 22 Aug 2013 12:02:58 +0000 (14:02 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 22 Aug 2013 12:03:53 +0000 (14:03 +0200)
This enables modify_file to work with MARC inputs

Makefile.PL
lib/WebPAC/Input/MARC.pm

index 358dee5..c6499cb 100644 (file)
@@ -22,7 +22,7 @@ requires      'Encode';
 requires       'LWP';
 requires       'File::Path';
 requires       'Biblio::Isis' => '0.24';
-requires       'MARC::Fast' => '0.11';
+requires       'MARC::Fast' => '0.12';
 requires       'List::Util';
 requires       'MARC::Record' => '2.0';
 requires       'Data::Dump';
index c5f7b30..6002320 100644 (file)
@@ -3,7 +3,7 @@ package WebPAC::Input::MARC;
 use warnings;
 use strict;
 
-use MARC::Fast;
+use MARC::Fast 0.12;
 use base qw/WebPAC::Common/;
 use Carp qw/confess/;
 
@@ -56,10 +56,6 @@ sub new {
 
        my $db = new MARC::Fast(
                marcdb => $arg->{path},
-               hash_filter => sub {
-                       my ( $l, $nr ) = @_;
-                       Encode::decode( 'utf-8', $l );
-               },
        );
        my $db_size = $db->count - 1;   # FIXME
 
@@ -80,13 +76,13 @@ Return record with ID C<$mfn> from database
 sub fetch_rec {
        my $self = shift;
 
-       my $mfn = shift;
+       my ($mfn, $filter_coderef) = @_;
 
        if ($mfn > $self->{_marc_size}) {
                $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
        } else {
                my $marc = $self->{_marc_db} || confess "no _marc_db?";
-               my $row = $marc->to_hash($mfn, include_subfields => 1);
+               my $row = $marc->to_hash($mfn, include_subfields => 1, hash_filter => $filter_coderef);
                push @{$row->{'000'}}, $mfn;
                push @{$row->{'leader'}}, $marc->last_leader;
                return $row;