/[Grep]/lib/Grep/Source.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 /lib/Grep/Source.pm

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

revision 125 by dpavlin, Sat Apr 28 22:52:08 2007 UTC revision 126 by dpavlin, Sat Apr 28 22:53:37 2007 UTC
# Line 203  sub element_by_triplet { Line 203  sub element_by_triplet {
203          my $tree = $args->{tree} || die "no tree";          my $tree = $args->{tree} || die "no tree";
204          my $message = $args->{message} || '';          my $message = $args->{message} || '';
205          my $fatal = $args->{fatal};          my $fatal = $args->{fatal};
206          die "no templates" unless defined( $args->{templates} );          die "no triplets" unless defined( $args->{triplets} );
207          my @templates;          my @triplets;
208  warn dump( $args->{templates} );  warn dump( $args->{triplets} );
209          if ( ref( $args->{templates} ) eq 'ARRAY' ) {          if ( ref( $args->{triplets} ) eq 'ARRAY' ) {
210                  @templates = @{ $args->{templates} };                  @triplets = @{ $args->{triplets} };
211          } else {          } else {
212                  @templates = ( $args->{templates} );                  @triplets = ( $args->{triplets} );
213          }          }
214    
215          push @templates, ( undef, undef ) if ( $#templates == 0 );          push @triplets, ( undef, undef ) if ( $#triplets == 0 );
216    
217          die "wrapper doesn't have 3 elements but ", $#templates unless (          die "wrapper doesn't have 3 elements but ", $#triplets unless (
218                  ( $#templates + 1 ) % 3 == 0                  ( $#triplets + 1 ) % 3 == 0
219          );          );
220    
221          my ( $el, $attr, $value );          my ( $el, $attr, $value );
# Line 223  warn dump( $args->{templates} ); Line 223  warn dump( $args->{templates} );
223          my @results;          my @results;
224          my @tags;          my @tags;
225    
226          while ( @templates ) {          while ( @triplets ) {
227                  ( $el,$attr,$value ) = splice( @templates, 0, 3 );                  ( $el,$attr,$value ) = splice( @triplets, 0, 3 );
228                  my $tag = $attr ? "<$el $attr=\"$value\">" : "<$el>";                  my $tag = $attr ? "<$el $attr=\"$value\">" : "<$el>";
229                  push @tags, $tag;                  push @tags, $tag;
230                  $self->log->debug("looking for $message $tag");                  $self->log->debug("looking for $message $tag");
# Line 287  sub scrape { Line 287  sub scrape {
287    
288          my $div = $self->element_by_triplet(          my $div = $self->element_by_triplet(
289                  tree => $tree,                  tree => $tree,
290                  templates => $args->{wrapper},                  triplets => $args->{wrapper},
291                  message => 'wrapper for all results',                  message => 'wrapper for all results',
292                  fatal => 1                  fatal => 1
293          );          );
# Line 300  sub scrape { Line 300  sub scrape {
300    
301          my @r = $self->element_by_triplet(          my @r = $self->element_by_triplet(
302                  tree => $tree,                  tree => $tree,
303                  templates => $args->{results},                  triplets => $args->{results},
304                  message => 'result element',                  message => 'result element',
305          );          );
306    
# Line 323  sub scrape { Line 323  sub scrape {
323                                  $div = $self->element_by_triplet(                                  $div = $self->element_by_triplet(
324                                          tree => $page_tree,                                          tree => $page_tree,
325                                          message => "result $nr",                                          message => "result $nr",
326                                          templates => $args->{scrape}                                          triplets => $args->{scrape}
327                                  );                                  );
328    
329                                  $self->add_record(                                  $self->add_record(

Legend:
Removed from v.125  
changed lines
  Added in v.126

  ViewVC Help
Powered by ViewVC 1.1.26