--- trunk/lib/WebPAC/Parser.pm 2006/09/25 15:26:12 707 +++ trunk/lib/WebPAC/Parser.pm 2006/09/29 12:27:36 720 @@ -17,11 +17,11 @@ =head1 VERSION -Version 0.05 +Version 0.06 =cut -our $VERSION = '0.05'; +our $VERSION = '0.06'; =head1 SYNOPSIS @@ -148,6 +148,23 @@ return $self->{_lookup_create}->{ _q($database) }->{ _q($input) }; } +=head2 normalize_rules + + my $source = $parser->normalize_rules($database, $input); + +=cut + +sub normalize_rules { + my $self = shift; + my ($database,$input) = @_; + $input = _input_name($input); + return unless ( + defined( $self->{_normalize_source}->{ _q($database) } ) && + defined( $self->{_normalize_source}->{ _q($database) }->{ _q($input) } ) + ); + return $self->{_normalize_source}->{ _q($database) }->{ _q($input) }; +} + =head1 PRIVATE =head2 _read_sources @@ -208,7 +225,7 @@ $parser->_parse_lookups($database,$input,$path,$source); -Called for each normalize source (rules) in each input by L +Called for each normalize source (rules) in each input by L It will report invalid databases and inputs in error log after parsing. @@ -296,13 +313,15 @@ $log->debug("key = $key"); - my $create = "save_into_lookup('$key', $e[7] $e[8] );\n"; - - $log->debug("create: $create"); - return $self->_lookup_error("invalid database $e[3] in $path" ) unless $self->valid_database( $e[3] ); return $self->_lookup_error("invalid input $e[5] of database $e[3] in $path", ) unless $self->valid_database_input( $e[3], $e[5] ); + my $create = qq{ + save_into_lookup($e[3],$e[5],'$key', $e[7] $e[8] ); + }; + + $log->debug("create: $create"); + # save code to create this lookup $self->{_lookup_create}->{ _q($e[3]) }->{ _q($e[5]) } .= $create; $self->{_lookup_create_key}->{ _q($e[3]) }->{ _q($e[5]) }->{ _q($key) }++; @@ -333,7 +352,7 @@ $log->debug("create: ", dump($self->{_lookup_create}) ); $log->debug("normalize: $normalize_source"); - $self->{_normalize_source}->{$database}->{$input} = $normalize_source; + $self->{_normalize_source}->{$database}->{$input} .= $normalize_source; if ($self->{debug}) { my $Dumper = PPI::Dumper->new( $Document );