Changeset 1177

Show
Ignore:
Timestamp:
07/28/06 11:54:17
Author:
miyagawa
Message:
  • Rough cut of Search::KinoSearch? plugin thanks to Marvin Humphrey talk in OSCON '06
  • Couple of fixes to $context->run_hook to implement searcher.search thing. Still looks a little clumsy.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/Makefile.PL

    r1173 r1177  
    231231        recommends('Text::WrapI18N'), 
    232232    ], 
     233    'Search::KinoSearch' => [ 
     234        -default => 0, 
     235        recommends('KinoSearch'), 
     236    ], 
    233237); 
    234238 
  • trunk/plagger/lib/Plagger.pm

    r1173 r1177  
    284284 
    285285sub run_hook { 
    286     my($self, $hook, $args, $once) = @_; 
     286    my($self, $hook, $args, $once, $callback) = @_; 
     287 
     288    my @ret; 
    287289    for my $action (@{ $self->{hooks}->{$hook} }) { 
    288290        my $plugin = $action->{plugin}; 
    289291        if ( $plugin->rule->dispatch($plugin, $hook, $args) ) { 
    290             my $done = $action->{callback}->($plugin, $self, $args); 
    291             return 1 if $once && $done; 
    292         } 
    293     } 
    294  
    295     # if $once is set, here means not executed = fail 
    296     return if $once; 
     292            my $ret = $action->{callback}->($plugin, $self, $args); 
     293            push @ret, $ret; 
     294            if ($callback) { 
     295                $callback->($ret); 
     296            } 
     297            return $ret if $once; 
     298        } else { 
     299            push @ret, undef; 
     300        } 
     301    } 
     302 
     303    return @ret; 
    297304} 
    298305 
    299306sub run_hook_once { 
    300     my($self, $hook, $args) = @_; 
    301     $self->run_hook($hook, $args, 1); 
     307    my($self, $hook, $args, $callback) = @_; 
     308    $self->run_hook($hook, $args, 1, $callback); 
    302309} 
    303310