/[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

Annotation of /trunk/lib/WebPAC/Input/Test.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 797 - (hide annotations)
Sun Feb 4 13:28:30 2007 UTC (17 years, 4 months ago) by dpavlin
File size: 2005 byte(s)
finish tweaking mock framework, test and fix problem with slashes in modify_record

1 dpavlin 796 package WebPAC::Input::Test;
2    
3     use warnings;
4     use strict;
5    
6     use WebPAC::Input;
7 dpavlin 797 use WebPAC::Common;
8 dpavlin 796 use base qw/WebPAC::Common/;
9 dpavlin 797 use Data::Dump qw/dump/;
10 dpavlin 796
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 dpavlin 797 $WebPAC::Input::Test::size = 42;
42 dpavlin 796
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     =cut
57    
58     sub new {
59     my $class = shift;
60     my $self = {@_};
61     bless($self, $class);
62    
63     my $arg = {@_};
64    
65     $self->_get_logger()->info("mocking Test database with args = ", dump($arg));
66    
67     $self ? return $self : return undef;
68     }
69    
70     =head2 fetch_rec
71    
72     Return record with ID C<$mfn> from database
73    
74     my $rec = $isis->fetch_rec( $mfn );
75    
76 dpavlin 797 Second argument, C<filter_coderef> will be assigned to
77     C<WebPAC::Input::Test::filer_coderef>.
78 dpavlin 796
79     =cut
80    
81 dpavlin 797 our $rec;
82     our $filter_coderef;
83 dpavlin 796
84     sub fetch_rec {
85     my $self = shift;
86    
87 dpavlin 797 my $mfn = shift;
88     $filter_coderef = shift;
89 dpavlin 796
90 dpavlin 797 $self->_get_logger()->debug("mfn = $mfn rec = ", dump($rec));
91 dpavlin 796
92     return $rec;
93     }
94    
95     =head2 dump_ascii
96    
97     Return dump of record ID C<$mfn> from database
98    
99     my $rec = $isis->dump_ascii( $mfn );
100    
101     =cut
102    
103     sub dump_ascii {
104     my $self = shift;
105    
106     return dump( $rec );
107     }
108    
109     =head2 size
110    
111     Return number of records in database
112    
113     my $size = $isis->size;
114    
115     =cut
116    
117 dpavlin 797 our $size = 1;
118 dpavlin 796
119     sub size {
120     my $self = shift;
121 dpavlin 797 $self->_get_logger()->debug("size = $size");
122 dpavlin 796 return $size;
123     }
124    
125     =head1 AUTHOR
126    
127     Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
128    
129     =head1 COPYRIGHT & LICENSE
130    
131     Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
132    
133     This program is free software; you can redistribute it and/or modify it
134     under the same terms as Perl itself.
135    
136     =cut
137    
138     1; # End of WebPAC::Input::Test

  ViewVC Help
Powered by ViewVC 1.1.26