11 |
|
|
12 |
=head1 VERSION |
=head1 VERSION |
13 |
|
|
14 |
Version 0.02 |
Version 0.04 |
15 |
|
|
16 |
=cut |
=cut |
17 |
|
|
18 |
our $VERSION = '0.02'; |
our $VERSION = '0.04'; |
19 |
|
|
20 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
21 |
|
|
82 |
db => $db_obj, |
db => $db_obj, |
83 |
lookup_regex => $lookup->regex, |
lookup_regex => $lookup->regex, |
84 |
lookup => $lookup_obj, |
lookup => $lookup_obj, |
85 |
|
prefix => 'foobar', |
86 |
); |
); |
87 |
|
|
88 |
Parametar C<filter> defines user supplied snippets of perl code which can |
Parametar C<filter> defines user supplied snippets of perl code which can |
89 |
be use with C<filter{...}> notation. |
be use with C<filter{...}> notation. |
90 |
|
|
91 |
|
C<prefix> is used to form filename for database record (to support multiple |
92 |
|
source files which are joined in one database). |
93 |
|
|
94 |
Recommended parametar C<lookup_regex> is used to enable parsing of lookups |
Recommended parametar C<lookup_regex> is used to enable parsing of lookups |
95 |
in structures. If you pass this parametar, you must also pass C<lookup> |
in structures. If you pass this parametar, you must also pass C<lookup> |
96 |
which is C<WebPAC::Lookup> object. |
which is C<WebPAC::Lookup> object. |
115 |
|
|
116 |
$log->logdie("lookup must be WebPAC::Lookup object") if ($self->{'lookup'} && ! $self->{'lookup'}->isa('WebPAC::Lookup')); |
$log->logdie("lookup must be WebPAC::Lookup object") if ($self->{'lookup'} && ! $self->{'lookup'}->isa('WebPAC::Lookup')); |
117 |
|
|
118 |
|
$log->warn("no prefix defined. please check that!") unless ($self->{'prefix'}); |
119 |
|
|
120 |
$self ? return $self : return undef; |
$self ? return $self : return undef; |
121 |
} |
} |
122 |
|
|
144 |
|
|
145 |
$log->logdie("need unique ID (mfn) in field 000 of record ", sub { Dumper($rec) } ) unless (defined($rec->{'000'})); |
$log->logdie("need unique ID (mfn) in field 000 of record ", sub { Dumper($rec) } ) unless (defined($rec->{'000'})); |
146 |
|
|
147 |
my $mfn = $rec->{'000'}->[0] || $log->logdie("field 000 isn't array!"); |
my $id = $rec->{'000'}->[0] || $log->logdie("field 000 isn't array!"); |
148 |
|
|
149 |
my $cache_file; |
my $cache_file; |
150 |
|
|
151 |
if ($self->{'db'}) { |
if ($self->{'db'}) { |
152 |
my $ds = $self->{'db'}->load_ds( $mfn ); |
my $ds = $self->{'db'}->load_ds( id => $id, prefix => $self->{prefix} ); |
153 |
$log->debug("load_ds( rec = ", sub { Dumper($rec) }, ") = ", sub { Dumper($ds) }); |
$log->debug("load_ds( rec = ", sub { Dumper($rec) }, ") = ", sub { Dumper($ds) }); |
154 |
return $ds if ($ds); |
return $ds if ($ds); |
155 |
$log->debug("cache miss, creating"); |
$log->debug("cache miss, creating"); |
255 |
} |
} |
256 |
|
|
257 |
$self->{'db'}->save_ds( |
$self->{'db'}->save_ds( |
258 |
id => $mfn, |
id => $id, |
259 |
ds => $ds, |
ds => $ds, |
260 |
|
prefix => $self->{prefix}, |
261 |
) if ($self->{'db'}); |
) if ($self->{'db'}); |
262 |
|
|
263 |
$log->debug("ds: ", sub { Dumper($ds) }); |
$log->debug("ds: ", sub { Dumper($ds) }); |
675 |
|
|
676 |
=cut |
=cut |
677 |
|
|
678 |
1; # End of WebPAC::DB |
1; # End of WebPAC::Normalize |