From: Dobrica Pavlinusic Date: Thu, 28 May 2009 10:15:20 +0000 (+0000) Subject: output modules can now define add_row as opposed to add to get input row before norma... X-Git-Url: http://git.rot13.org/?p=webpac2;a=commitdiff_plain;h=4cb43c7e62d6bdfd2749c6c6644fe74ab229d71d output modules can now define add_row as opposed to add to get input row before normalization git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1198 07558da8-63fa-0310-ba24-9fe276d99e06 --- diff --git a/TODO b/TODO index 48b2516..601ad12 100644 --- a/TODO +++ b/TODO @@ -55,6 +55,7 @@ + use UTF-8 as internal encoding + dump stats into var/stats.yml + WebPAC::Output::SWISH for indexing with swish-e [2.35] ++ output modules can now define add_row as opposed to add to get input row before normalization - implement attribute labels in webpac2.cgi - fix encoding for swish-e and/or webpac2.cgi - marc_clone to copy records/fields/indicators from input marc diff --git a/lib/WebPAC/Output/CouchDB.pm b/lib/WebPAC/Output/CouchDB.pm index 0c1c69b..7ca5411 100644 --- a/lib/WebPAC/Output/CouchDB.pm +++ b/lib/WebPAC/Output/CouchDB.pm @@ -60,7 +60,7 @@ Adds one entry to database. =cut -sub add { +sub add_row { my $self = shift; my ( $id, $ds ) = @_; diff --git a/run.pl b/run.pl index e933728..5f7b247 100755 --- a/run.pl +++ b/run.pl @@ -603,6 +603,9 @@ foreach my $database ( sort keys %{ $config->databases } ) { push @{ $row->{'000'} }, $pos; } + foreach my $out ( @output_modules ) { + $out->add_row( $mfn, $row ) if $out->can('add_row'); + } if ($validate) { if ( my $errors = $validate->validate_rec( $row, $input_db->dump_ascii ) ) { diff --git a/t/5-output-couchdb.t b/t/5-output-couchdb.t index fe94498..196c9a4 100755 --- a/t/5-output-couchdb.t +++ b/t/5-output-couchdb.t @@ -38,13 +38,13 @@ my $ds = { }, }; -ok( $out->add( 42, $ds ), 'add 42' ); +ok( $out->add_row( 42, $ds ), 'add 42' ); my @strange = ( qw/èajðinica odma¹æivanje ¾abokreèina ¹uma/ ); -ok( $out->add( 99, { foo => { search => [ @strange ] } } ), 'add 99' ); +ok( $out->add_row( 99, { foo => { search => [ @strange ] } } ), 'add 99' ); -ok( $out->add( 100, { foo => { search => [ qw/foo bar baz/ ] } } ), 'add 100' ); +ok( $out->add_row( 100, { foo => { search => [ qw/foo bar baz/ ] } } ), 'add 100' ); ok( $out->finish, 'finish' );