=head1 VERSION
-Version 0.05
+Version 0.07
=cut
-our $VERSION = '0.05';
+our $VERSION = '0.07';
=head1 SYNOPSIS
my $db = WebPAC::Input->new(
module => 'WebPAC::Input::ISIS',
config => $config,
- lookup => $lookup_obj,
low_mem => 1,
);
my $db = new WebPAC::Input(
module => 'WebPAC::Input::MARC',
- code_page => 'ISO-8859-2',
+ encoding => 'ISO-8859-2',
low_mem => 1,
recode => 'char pairs',
no_progress_bar => 1,
C<module> is low-level file format module. See L<WebPAC::Input::Isis> and
L<WebPAC::Input::MARC>.
-Optional parametar C<code_page> specify application code page (which will be
+Optional parametar C<encoding> specify application code page (which will be
used internally). This should probably be your terminal encoding, and by
default, it C<ISO-8859-2>.
my $log = $self->_get_logger;
+ $log->logconfess("code_page argument is not suppored any more. change it to encoding") if ($self->{lookup});
+ $log->logconfess("lookup argument is not suppored any more. rewrite call to lookup_ref") if ($self->{lookup});
+
$log->logconfess("specify low-level file format module") unless ($self->{module});
my $module = $self->{module};
$module =~ s#::#/#g;
$self->{init}->($self, @_);
}
- $self->{'code_page'} ||= 'ISO-8859-2';
+ $self->{'encoding'} ||= 'ISO-8859-2';
# running with low_mem flag? well, use DBM::Deep then.
if ($self->{'low_mem'}) {
offset => 6000,
lookup => $lookup_obj,
stats => 1,
+ lookup_ref => sub {
+ my ($k,$v) = @_;
+ # store lookup $k => $v
+ },
);
By default, C<code_page> is assumed to be C<852>.
C<stats> create optional report about usage of fields and subfields
+C<lookup_coderef> is closure to call when adding key => $value combinations to
+lookup.
+
Returns size of database, regardless of C<offset> and C<limit>
parametars, see also C<size>.
my $log = $self->_get_logger();
+ $log->logconfess("lookup argument is not suppored any more. rewrite call to lookup_coderef") if ($arg->{lookup});
+ $log->logconfess("lookup_coderef must be CODE, not ",ref($arg->{lookup_coderef}))
+ if ($arg->{lookup_coderef} && ref($arg->{lookup_coderef}) ne 'CODE');
+
$log->logcroak("need path") if (! $arg->{'path'});
my $code_page = $arg->{'code_page'} || '852';
}
# create Text::Iconv object
- $self->{iconv} = Text::Iconv->new($code_page,$self->{'code_page'});
+ $self->{iconv} = Text::Iconv->new($code_page,$self->{'encoding'}); ## FIXME remove!
my $filter_ref;
# store size for later
$self->{size} = ($to_rec - $from_rec) ? ($to_rec - $from_rec + 1) : 0;
- $log->info("processing $self->{size}/$size records [$from_rec-$to_rec] convert $code_page -> $self->{code_page}", $self->{stats} ? ' [stats]' : '');
+ $log->info("processing $self->{size}/$size records [$from_rec-$to_rec] convert $code_page -> $self->{encoding}", $self->{stats} ? ' [stats]' : '');
# read database
for (my $pos = $from_rec; $pos <= $to_rec; $pos++) {
}
# create lookup
- $self->{'lookup'}->add( $rec ) if ($rec && $self->{'lookup'});
+ $arg->{'lookup_coderef'}->( $rec ) if ($rec && $arg->{'lookup_coderef'});
# update counters for statistics
if ($self->{stats}) {
use WebPAC::Common 0.02;
use WebPAC::Lookup;
-use WebPAC::Input 0.03;
+use WebPAC::Input 0.07;
use WebPAC::Store 0.03;
use WebPAC::Normalize 0.11;
use WebPAC::Output::TT;
my $input_db = new WebPAC::Input(
module => $input_module,
- code_page => $config->{webpac}->{webpac_encoding},
+ encoding => $config->{webpac}->{webpac_encoding},
limit => $limit || $input->{limit},
offset => $offset,
- lookup => $lookup,
+ lookup_coderef => sub {
+ my $rec = shift || return;
+ $lookup->add( $rec );
+ },
recode => $input->{recode},
stats => $stats,
);