/[webpac2]/trunk/lib/WebPAC/Input/ISI.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

Contents of /trunk/lib/WebPAC/Input/ISI.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 898 - (show annotations)
Wed Oct 10 19:01:55 2007 UTC (16 years, 6 months ago) by dpavlin
File size: 2025 byte(s)
 r1344@llin:  dpavlin | 2007-10-10 20:34:20 +0200
 skeleton of support for ISI export format, parse headers

1 package WebPAC::Input::ISI;
2
3 use warnings;
4 use strict;
5
6 use WebPAC::Input;
7 use base qw/WebPAC::Common/;
8
9 =head1 NAME
10
11 WebPAC::Input::ISI - support for ISI Export Format
12
13 =head1 VERSION
14
15 Version 0.00
16
17 =cut
18
19 our $VERSION = '0.00';
20
21
22 =head1 SYNOPSIS
23
24 Open file in ISI export fromat
25
26 my $input = new WebPAC::Input::ISI(
27 path => '/path/to/ISI/records.txt',
28 );
29
30 =head1 FUNCTIONS
31
32 =head2 new
33
34 Returns new low-level input API object
35
36 my $input = new WebPAC::Input::ISI(
37 path => '/path/to/ISI/records.txt'
38 filter => sub {
39 my ($l,$field_nr) = @_;
40 # do something with $l which is line of input file
41 return $l;
42 },
43 }
44
45 Options:
46
47 =over 4
48
49 =item path
50
51 path to ISI export file
52
53 =back
54
55 =cut
56
57 sub new {
58 my $class = shift;
59 my $self = {@_};
60 bless($self, $class);
61
62 my $arg = {@_};
63
64 my $log = $self->_get_logger();
65
66 open( my $fh, '<', $arg->{path} ) || $log->logconfess("can't open $arg->{path}: $!");
67
68 my ( $format, $version );
69
70 my $line = <$fh>;
71 chomp($line);
72 if ( $line =~ /^FN\s(.+)$/) {
73 $format = $1;
74 } else {
75 $log->logdie("first line of $arg->{path} has to be FN, but is: $line");
76 }
77
78 $line = <$fh>;
79 chomp($line);
80 if ( $line =~ /^VR\s(.+)$/) {
81 $version = $1;
82 } else {
83 $log->logdie("second line of $arg->{path} has to be VN, but is: $line");
84 }
85
86 $log->info("opening $format $version database '$arg->{path}'");
87
88 $self ? return $self : return undef;
89 }
90
91 =head2 fetch_rec
92
93 Return record with ID C<$mfn> from database
94
95 my $rec = $input->fetch_rec( $mfn, $filter_coderef);
96
97 =cut
98
99 sub fetch_rec {
100 my $self = shift;
101
102 my ($mfn, $filter_coderef) = @_;
103
104 my $rec;
105
106 return $rec;
107 }
108
109
110 =head2 size
111
112 Return number of records in database
113
114 my $size = $input->size;
115
116 =cut
117
118 sub size {
119 my $self = shift;
120 return 2;
121 }
122
123 =head1 AUTHOR
124
125 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
126
127 =head1 COPYRIGHT & LICENSE
128
129 Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
130
131 This program is free software; you can redistribute it and/or modify it
132 under the same terms as Perl itself.
133
134 =cut
135
136 1; # End of WebPAC::Input::ISI

  ViewVC Help
Powered by ViewVC 1.1.26