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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 798 - (show annotations)
Sun Feb 4 13:31:38 2007 UTC (17 years, 2 months ago) by dpavlin
File size: 2110 byte(s)
store filter (no tests for it, though!)

1 package WebPAC::Input::Test;
2
3 use warnings;
4 use strict;
5
6 use WebPAC::Input;
7 use WebPAC::Common;
8 use base qw/WebPAC::Common/;
9 use Data::Dump qw/dump/;
10
11 =head1 NAME
12
13 WebPAC::Input::Test - Mock test records for WebPAC
14
15 =head1 VERSION
16
17 Version 0.01
18
19 =cut
20
21 our $VERSION = '0.01';
22
23 =head1 SYNOPSIS
24
25 Setup test record
26
27 $WebPAC::Input::Test::rec = {
28 '200' => [ {
29 'a' => 'foo',
30 'b' => 'bar',
31 }, {
32 'a' => 'baz',
33 } ],
34 '900' => [
35 'foobar',
36 ],
37 };
38
39 Setup optional size
40
41 $WebPAC::Input::Test::size = 42;
42
43 =head1 FUNCTIONS
44
45 =head2 new
46
47 my $isis = new WebPAC::Input::Test(
48 path => '/path/to/LIBRI'
49 filter => sub {
50 my ($l,$field_nr) = @_;
51 # do something with $l which is line of input file
52 return $l;
53 },
54 }
55
56 C<filter> will be assigned to C<$WebPAC::Input::Test::filter>
57
58 =cut
59
60 our $filter;
61
62 sub new {
63 my $class = shift;
64 my $self = {@_};
65 bless($self, $class);
66
67 my $arg = {@_};
68
69 $filter = $arg->{filter};
70
71 $self->_get_logger()->info("mocking Test database with args = ", dump($arg));
72
73 $self ? return $self : return undef;
74 }
75
76 =head2 fetch_rec
77
78 Return record with ID C<$mfn> from database
79
80 my $rec = $isis->fetch_rec( $mfn );
81
82 Second argument, C<filter_coderef> will be assigned to
83 C<$WebPAC::Input::Test::filer_coderef>
84
85 =cut
86
87 our $rec;
88 our $filter_coderef;
89
90 sub fetch_rec {
91 my $self = shift;
92
93 my $mfn = shift;
94 $filter_coderef = shift;
95
96 $self->_get_logger()->debug("mfn = $mfn rec = ", dump($rec));
97
98 return $rec;
99 }
100
101 =head2 dump_ascii
102
103 Return dump of record ID C<$mfn> from database
104
105 my $rec = $isis->dump_ascii( $mfn );
106
107 =cut
108
109 sub dump_ascii {
110 my $self = shift;
111
112 return dump( $rec );
113 }
114
115 =head2 size
116
117 Return number of records in database
118
119 my $size = $isis->size;
120
121 =cut
122
123 our $size = 1;
124
125 sub size {
126 my $self = shift;
127 $self->_get_logger()->debug("size = $size");
128 return $size;
129 }
130
131 =head1 AUTHOR
132
133 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
134
135 =head1 COPYRIGHT & LICENSE
136
137 Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
138
139 This program is free software; you can redistribute it and/or modify it
140 under the same terms as Perl itself.
141
142 =cut
143
144 1; # End of WebPAC::Input::Test

  ViewVC Help
Powered by ViewVC 1.1.26