/[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 796 - (show annotations)
Sun Feb 4 12:42:43 2007 UTC (17 years, 3 months ago) by dpavlin
File size: 1859 byte(s)
a try at mocking of inputs in WebPAC::Input::Test

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

  ViewVC Help
Powered by ViewVC 1.1.26