/[webpac2]/trunk/lib/WebPAC/Parser.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Parser.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 702 by dpavlin, Mon Sep 25 13:08:17 2006 UTC revision 703 by dpavlin, Mon Sep 25 13:24:09 2006 UTC
# Line 17  WebPAC::Parser - parse perl normalizatio Line 17  WebPAC::Parser - parse perl normalizatio
17    
18  =head1 VERSION  =head1 VERSION
19    
20  Version 0.04  Version 0.05
21    
22  =cut  =cut
23    
24  our $VERSION = '0.04';  our $VERSION = '0.05';
25    
26  =head1 SYNOPSIS  =head1 SYNOPSIS
27    
# Line 61  sub new { Line 61  sub new {
61    
62          $log->logdie("can't iterate_inputs over this config object") unless ($self->{config}->can('iterate_inputs'));          $log->logdie("can't iterate_inputs over this config object") unless ($self->{config}->can('iterate_inputs'));
63    
64          $self->read_sources;          $self->_read_sources;
65    
66          $self ? return $self : return undef;          $self ? return $self : return undef;
67  }  }
68    
69  =head2 read_sources  =head2 lookup_create_rules
70    
71      my $source = $parser->lookup_create_rules($database, $input);
72    
73    =cut
74    
75    sub lookup_create_rules {
76            my $self = shift;
77            my ($database,$input) = @_;
78            return $self->{_lookup_create}->{ _q($database) }->{ _q($input) };
79    }
80    
81    =head2 valid_database
82    
83      my $ok = $parse->valid_database('key');
84    
85    =cut
86    
87    sub valid_database {
88            my $self = shift;
89    
90            my $database = shift || return;
91    
92            return defined($self->{valid_inputs}->{ _q($database) });
93    }
94    
95    =head2 valid_database_input
96    
97      my $ok = $parse->valid_database('database_key','input_name');
98    
99    =cut
100    
101    sub valid_database_input {
102            my $self = shift;
103    
104            my ($database,$input) = @_;
105            return defined($self->{valid_inputs}->{ _q($database) }->{ _q($input) });
106    }
107    
108    =head2 depends
109    
110    Return all databases and inputs on which specified one depends
111    
112      $depends_on = $parser->depends('database','input');
113    
114    =cut
115    
116    sub depends {
117            my $self = shift;
118            my ($database,$input) = @_;
119            $self->_get_logger->debug("depends($database,$input)");
120            return unless (
121                    defined( $self->{depends}->{ _q($database) } ) &&
122                    defined( $self->{depends}->{ _q($database) }->{ _q($input) } )
123            );
124            return $self->{depends}->{ _q($database) }->{ _q($input) };
125    }
126    
127    =head1 PRIVATE
128    
129    =head2 _read_sources
130    
131    my $source_files = $parser->read_sources;    my $source_files = $parser->_read_sources;
132    
133  Called by L</new>.  Called by L</new>.
134    
135  =cut  =cut
136    
137  sub read_sources {  sub _read_sources {
138          my $self = shift;          my $self = shift;
139    
140          my $log = $self->_get_logger();          my $log = $self->_get_logger();
# Line 105  sub read_sources { Line 165  sub read_sources {
165                          $self->{valid_inputs}->{$database}->{$input_name}++;                          $self->{valid_inputs}->{$database}->{$input_name}++;
166    
167                          push @lookups, sub {                          push @lookups, sub {
168                                  $self->parse_lookups( $database, $input_name, $full, $s );                                  $self->_parse_lookups( $database, $input_name, $full, $s );
169                          };                          };
170    
171                          $nr++;                          $nr++;
# Line 120  sub read_sources { Line 180  sub read_sources {
180          return $nr;          return $nr;
181  }  }
182    
183  =head2 parse_lookups  =head2 _parse_lookups
184    
185    $parser->parse_lookups($database,$input,$path,$source);    $parser->_parse_lookups($database,$input,$path,$source);
186    
187  Called for each normalize source in each input by L</new>  Called for each normalize source (rules) in each input by L</read_sources>
188    
189  It will report invalid databases and inputs in error log after parsing.  It will report invalid databases and inputs in error log after parsing.
190    
191  =cut  =cut
192    
193  sub parse_lookups {  sub _parse_lookups {
194          my $self = shift;          my $self = shift;
195          my ($database, $input, $path, $source) = @_;          my ($database, $input, $path, $source) = @_;
196    
# Line 267  sub parse_lookups { Line 327  sub parse_lookups {
327  }  }
328    
329    
 =head2 lookup_create_rules  
   
   my $source = $parser->lookup_create_rules($database, $input);  
   
 =cut  
   
 sub lookup_create_rules {  
         my $self = shift;  
         my ($database,$input) = @_;  
         return $self->{_lookup_create}->{ _q($database) }->{ _q($input) };  
 }  
   
 =head2 valid_database  
   
   my $ok = $parse->valid_database('key');  
   
 =cut  
   
 sub valid_database {  
         my $self = shift;  
   
         my $database = shift || return;  
   
         return defined($self->{valid_inputs}->{ _q($database) });  
 }  
   
 =head2 valid_database_input  
   
   my $ok = $parse->valid_database('database_key','input_name');  
   
 =cut  
   
 sub valid_database_input {  
         my $self = shift;  
   
         my ($database,$input) = @_;  
         return defined($self->{valid_inputs}->{ _q($database) }->{ _q($input) });  
 }  
   
 =head2 depends  
   
 Return all databases and inputs on which specified one depends  
   
   $depends_on = $parser->depends('database','input');  
   
 =cut  
   
 sub depends {  
         my $self = shift;  
         my ($database,$input) = @_;  
         $self->_get_logger->debug("depends($database,$input)");  
         return unless (  
                 defined( $self->{depends}->{ _q($database) } ) &&  
                 defined( $self->{depends}->{ _q($database) }->{ _q($input) } )  
         );  
         return $self->{depends}->{ _q($database) }->{ _q($input) };  
 }  
   
 =head1 PRIVATE  
   
330  =head2 _q  =head2 _q
331    
332  Strip single or double quotes around value  Strip single or double quotes around value

Legend:
Removed from v.702  
changed lines
  Added in v.703

  ViewVC Help
Powered by ViewVC 1.1.26