leader from WebPAC::Input::MARC is now available as rec('leader')
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 29 Oct 2007 23:20:13 +0000 (23:20 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 29 Oct 2007 23:20:13 +0000 (23:20 +0000)
for mondifications within leader, use substr(rec('leader'),from,to)
instead of proposed leader(field,nr) syntax

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@908 07558da8-63fa-0310-ba24-9fe276d99e06

Makefile.PL
TODO
lib/WebPAC/Input/MARC.pm
t/2-input.t

index 3f3c200..249d1f0 100644 (file)
@@ -24,7 +24,7 @@ WriteMakefile(
        'LWP' => 0,
        'File::Path' => 0,
        'Biblio::Isis' => 0.24,
-       'MARC::Fast' => 0.05,
+       'MARC::Fast' => 0.08,
        'Search::Estraier' => 0.06,
        'List::Util' => 0,
        'Spreadsheet::ParseExcel', => 0,
diff --git a/TODO b/TODO
index 40f6189..a66da93 100644 (file)
--- a/TODO
+++ b/TODO
 + work without indexers installed or enabled [2.30]
 + simpliest possible conf/llin.yml as example
 + WebPAC::Output::JSON to produce data for Simile's exhibit
++ leader from WebPAC::Input::MARC is now available as rec('leader')
+- indicator(field,nr) nr=1|2 for MARC input
+- show i1 and i2 in statistcs specially
 - load_ds/save_ds should use on-disk hash to preserve inodes
-- leader(position,...), indicator(field,nr) nr=1|2 for MARC input
 - validate should ignore modify_file
 - add option to specify output marc path in config.yml
 - add dBase input format
index a0ca958..da1ae31 100644 (file)
@@ -5,6 +5,7 @@ use strict;
 
 use MARC::Fast 0.03;
 use base qw/WebPAC::Common/;
+use Carp qw/confess/;
 
 =head1 NAME
 
@@ -12,11 +13,11 @@ WebPAC::Input::MARC - support for MARC database files
 
 =head1 VERSION
 
-Version 0.08
+Version 0.09
 
 =cut
 
-our $VERSION = '0.08';
+our $VERSION = '0.09';
 
 
 =head1 SYNOPSIS
@@ -82,8 +83,10 @@ sub fetch_rec {
        if ($mfn > $self->{_marc_size}) {
                $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
        } else {
-               my $row = $self->{_marc_db}->to_hash($mfn);
+               my $marc = $self->{_marc_db} || confess "no _marc_db?";
+               my $row = $marc->to_hash($mfn);
                push @{$row->{'000'}}, $mfn;
+               push @{$row->{'leader'}}, $marc->last_leader;
                return $row;
        }
 }
index 19af3df..a2cd982 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-use Test::More tests => 118;
+use Test::More tests => 123;
 use Test::Exception;
 use Cwd qw/abs_path/;
 use blib;
@@ -18,12 +18,12 @@ my $debug = shift @ARGV;
 my $no_log = $debug ? 0 : 1;
 
 ok(my $abs_path = abs_path($0), "abs_path");
-$abs_path =~ s#/[^/]*$#/#;
+$abs_path =~ s#/[^/]*$#/#;     #vim
 
 my $module = 'WebPAC::Input::ISIS';
 diag "testing with $module";
 
-throws_ok { my $input = new WebPAC::Input( ) } qr/module/, "need module";
+throws_ok { my $input = new WebPAC::Input( no_log => $no_log ) } qr/module/, "need module";
 ok(my $input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, stats => 1 ), "new $module");
 ok(my $input_lm = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module");
 
@@ -79,6 +79,8 @@ sub test_fetch($$) {
                cmp_ok($input->pos, '==', $mfn, "pos $mfn");
                push @db, $rec;
                ok(my $dump = $input->dump_ascii, "dump_ascii $mfn");
+               # XXX test count will help us keep this test in-line :-)
+               ok($rec->{leader}, "leader $mfn") if $rec->{leader};
                diag $dump if ($debug);
        }