/[webpac2]/trunk/lib/WebPAC/Input/MARC.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input/MARC.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 652 by dpavlin, Thu Sep 7 15:01:45 2006 UTC revision 908 by dpavlin, Mon Oct 29 23:20:13 2007 UTC
# Line 4  use warnings; Line 4  use warnings;
4  use strict;  use strict;
5    
6  use MARC::Fast 0.03;  use MARC::Fast 0.03;
7    use base qw/WebPAC::Common/;
8    use Carp qw/confess/;
9    
10  =head1 NAME  =head1 NAME
11    
# Line 11  WebPAC::Input::MARC - support for MARC d Line 13  WebPAC::Input::MARC - support for MARC d
13    
14  =head1 VERSION  =head1 VERSION
15    
16  Version 0.05  Version 0.09
17    
18  =cut  =cut
19    
20  our $VERSION = '0.05';  our $VERSION = '0.09';
21    
22    
23  =head1 SYNOPSIS  =head1 SYNOPSIS
# Line 23  our $VERSION = '0.05'; Line 25  our $VERSION = '0.05';
25  Open USMARC, Unimarc or any other file format that has same internal  Open USMARC, Unimarc or any other file format that has same internal
26  structure using C<MARC::Fast>.  structure using C<MARC::Fast>.
27    
28   my $marc = new WebPAC::Input::MARC();   my $marc = new WebPAC::Input::MARC(
29   $marc->open( path => '/path/to/marc.iso' );          path => '/path/to/marc.iso'
30     );
31    
32  =head1 FUNCTIONS  =head1 FUNCTIONS
33    
34  =head2 open_db  =head2 new
35    
36  Returns handle to database and size in records  Returns new low-level input API object
37    
38    my ($db,$size) = $open_db(    my $marc = new WebPAC::Input::MARC(
39          path => '/path/to/marc.iso',          path => '/path/to/marc.iso',
40          filter => \&code_ref,          filter => \&code_ref,
41    }    }
42    
43  =cut  =cut
44    
45  sub open_db {  sub new {
46          my $self = shift;          my $class = shift;
47            my $self = {@_};
48            bless($self, $class);
49    
50          my $arg = {@_};          my $arg = {@_};
51    
# Line 57  sub open_db { Line 62  sub open_db {
62          $self->{_marc_size} = $db_size;          $self->{_marc_size} = $db_size;
63          $self->{_marc_db} = $db;          $self->{_marc_db} = $db;
64    
65          return ($db, $db_size);          $self ? return $self : return undef;
66  }  }
67    
68  =head2 fetch_rec  =head2 fetch_rec
# Line 78  sub fetch_rec { Line 83  sub fetch_rec {
83          if ($mfn > $self->{_marc_size}) {          if ($mfn > $self->{_marc_size}) {
84                  $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");                  $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
85          } else {          } else {
86                  my $row = $self->{_marc_db}->to_hash($mfn);                  my $marc = $self->{_marc_db} || confess "no _marc_db?";
87                    my $row = $marc->to_hash($mfn);
88                  push @{$row->{'000'}}, $mfn;                  push @{$row->{'000'}}, $mfn;
89                    push @{$row->{'leader'}}, $marc->last_leader;
90                  return $row;                  return $row;
91          }          }
92  }  }
93    
94  =head1 PROPERTIES  =head2 dump_ascii
95    
96    Return ASCII dump of record with ID C<$mfn> from database
97    
98      print $self->dump_ascii( $mfn );
99    
100    }
101    
102    =cut
103    
104    sub dump_ascii {
105            my $self = shift;
106    
107            my $mfn = shift;
108            return $self->{_marc_db}->to_ascii($mfn);
109    }
110    
111    =head2 size
112    
113  =head2 _marc_size  Return number of records in database
114    
115  Store size of MARC database    my $size = $isis->size;
116    
117    print $self->{_marc_size};  =cut
118    
119    sub size {
120            my $self = shift;
121            return $self->{_marc_size};
122    }
123    
124    
125  =head1 AUTHOR  =head1 AUTHOR

Legend:
Removed from v.652  
changed lines
  Added in v.908

  ViewVC Help
Powered by ViewVC 1.1.26