r1258@llin: dpavlin | 2007-05-27 13:14:58 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 27 May 2007 11:14:40 +0000 (11:14 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 27 May 2007 11:14:40 +0000 (11:14 +0000)
 Changed delimiter_templates arguments to be more intuitive,
 disable MARC generation when running delimiters validation
 (this is just disk overhead)

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@851 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Validate.pm
run.pl
t/1-validate-delimiters.t

index 80c60bf..30633be 100644 (file)
@@ -468,7 +468,7 @@ Generate report of delimiter tamplates
 
   my $report = $validate->delimiter_teplates(
        report => 1,
-       accumulated => 1,
+       current_input => 1,
   );
 
 Options:
@@ -479,9 +479,9 @@ Options:
 
 Generate humanly readable report with single fields
 
-=item accumulated
+=item current_input
 
-Use accumulated data from all inputs
+Report just current_input and not accumulated data
 
 =back
 
@@ -492,12 +492,8 @@ sub delimiters_templates {
 
        my $args = {@_};
 
-       my $t;
-       if ( $args->{accumulated} ) {
-               $t = $self->{_accumulated_delimiters_templates};
-       } else {
-               $t = $self->{_delimiters_templates};
-       }
+       my $t = $self->{_accumulated_delimiters_templates};
+       $t = $self->{_delimiters_templates} if ( $args->{current_input} );
 
        my $log = $self->_get_logger;
 
@@ -552,7 +548,7 @@ sub save_delimiters_templates {
        $path .= '.new' if ( -e $path );
 
        open(my $d, '>', $path) || $log->fatal("can't open $path: $!");
-       print $d $self->delimiters_templates( accumulated => 1 );
+       print $d $self->delimiters_templates;
        close($d);
 
        $log->info("new delimiters templates saved to $path");
diff --git a/run.pl b/run.pl
index 8cb20b5..bbe7914 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -144,6 +144,8 @@ GetOptions(
        "help" => \$help,
 );
 
+$marc_generate = 0 if ( $validate_delimiters_path );
+
 pod2usage(-verbose => 2) if ($help);
 
 my $config = new WebPAC::Config( path => $config_path );
@@ -568,7 +570,10 @@ while (my ($database, $db_config) = each %{ $config->databases }) {
                                print $report_fh "$errors\n" if ($report_fh);
                        }
 
-                       print $report_fh "\nAll possible subfields/delimiter templates:\n", $validate->delimiters_templates( report => 1 ), "\n\n";
+                       print $report_fh "\nAll possible subfields/delimiter templates:\n", $validate->delimiters_templates( report => 1, current_input => 1 ), "\n\n";
+
+                       # must be last thing that touches $validate for this input
+                       $validate->reset;
                }
 
                if ($stats) {
@@ -582,9 +587,6 @@ while (my ($database, $db_config) = each %{ $config->databases }) {
 
                # close report
                close($report_fh) if ($report_fh);
-
-               # reset validate stats
-               $validate->reset if ( $validate );
        }
 
        eval { $indexer->finish } if ($indexer && $indexer->can('finish'));
index 1a663a4..2f7e5b4 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 13;
+use Test::More tests => 15;
 use Test::Exception;
 use blib;
 
@@ -68,12 +68,17 @@ is_deeply( $v->{_delimiters_templates}, {
        901 => { "^a :  / ^b" => 2 },
 }, 'just subfields and delimiters');
 
-ok(my $dt = $v->delimiters_templates, 'delimiters_template');
+ok(! $v->delimiters_templates, 'no accumulated delimiters_template');
+
+ok(my $dt = $v->delimiters_templates( current_input => 1 ), 'delimiters_template');
 diag $dt if ( $debug );
 
-ok($dt = $v->delimiters_templates( report => 1 ), 'delimiters_template report');
+ok($dt = $v->delimiters_templates( report => 1, current_input => 1 ), 'delimiters_template report');
 diag $dt if ( $debug );
 
+$v->reset;
+ok( $v->delimiters_templates, 'have accumulated delimiters_templates');
+
 $v->{_validate_delimiters_templates} = {
        900 => { '^a : ^b' => 1 },
 };