fdcce3612996399037bf777a3591b867b39065ab
[webpac2] / lib / WebPAC / Input / MARC.pm
1 package WebPAC::Input::MARC;
2
3 use warnings;
4 use strict;
5
6 use blib;
7
8 use WebPAC::Common;
9 use MARC::Fast;
10
11 =head1 NAME
12
13 WebPAC::Input::MARC - support for MARC database files
14
15 =head1 VERSION
16
17 Version 0.01
18
19 =cut
20
21 our $VERSION = '0.01';
22
23
24 =head1 SYNOPSIS
25
26 Open USMARC, Unimarc or any other file format that has same internal
27 structure using C<MARC::Fast>.
28
29  my $marc = new WebPAC::Input::MARC();
30  $marc->open( path => '/path/to/marc.iso' );
31
32 =head1 FUNCTIONS
33
34 =head2 open_db
35
36 Returns handle to database
37
38   my $db = $open_db(
39         path => '/path/to/marc.iso'
40   }
41
42 =cut
43
44 sub open_db {
45         my $self = shift;
46
47         my $arg = {@_};
48
49         my $log = $self->_get_logger();
50
51         $log->info("opening MARC database '$arg->{path}'");
52
53         my $db = new MARC::Fast( marcdb => $arg->{path});
54         my $db_size = $db->count;
55
56         return ($db, $db_size);
57 }
58
59 =head2 fetch_rec
60
61 Return record with ID C<$mfn> from database
62
63   my $rec = $self->fetch_rec( $db, $mfn );
64
65 }
66
67 =cut
68
69 sub fetch_rec {
70         my $self = shift;
71
72         my ($db, $mfn) = @_;
73
74         return $db->fetch($mfn);
75 }
76
77 =head1 AUTHOR
78
79 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
80
81 =head1 COPYRIGHT & LICENSE
82
83 Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.
84
85 This program is free software; you can redistribute it and/or modify it
86 under the same terms as Perl itself.
87
88 =cut
89
90 1; # End of WebPAC::Input::MARC