Changeset 19223

Show
Ignore:
Timestamp:
09/12/08 16:32:18 (5 years ago)
Author:
lopnor
Message:

lang/perl/App-Hachero: DisableDynamicPlugin?

Location:
lang/perl/App-Hachero/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/App-Hachero/trunk/Makefile.PL

    r19113 r19223  
    2727build_requires 'Test::Base'; 
    2828 
     29install_script 'hachero.pl'; 
     30 
    2931tests 't/*.t t/*/*.t t/*/*/*.t'; 
    3032 
  • lang/perl/App-Hachero/trunk/lib/App/Hachero.pm

    r19114 r19223  
    1010use Module::Collect; 
    1111 
    12 __PACKAGE__->load_components(qw/Plaggerize Autocall::InjectMethod/); 
    13 __PACKAGE__->mk_accessors(qw/currentline currentlog currentinfo result work_path packages_from_plugin_path/); 
     12__PACKAGE__->load_components(qw/DisableDynamicPlugin Plaggerize Autocall::InjectMethod/); 
     13__PACKAGE__->mk_accessors(qw/currentline currentlog currentinfo result work_path/); 
    1414 
     15my $packages_from_plugin_path; 
    1516my $context; 
    1617sub context { $context } 
     
    1819sub new { 
    1920    my $class = shift; 
     21    my $args = $_[0]; 
     22    my $config = $class->setup_config( $args->{config} ); 
     23 
     24    my @plugins; 
     25    my $plugin_list = $config->{global}->{pluginloader}->{plugin_list}; 
     26    for my $plugin (@{ $config->{$plugin_list} }) { 
     27        push @plugins, { module => $plugin->{module}, config => $plugin }; 
     28    } 
     29 
     30    if (my $path = $config->{global}{plugin_path}) { 
     31        my $collect = Module::Collect->new( 
     32            path => $path, 
     33            pattern => '*.pm', 
     34            prefix => 'App::Hachero::Plugin', 
     35        ); 
     36        $packages_from_plugin_path = $collect->modules; 
     37    } 
     38 
     39    $class->load_plugins(@plugins); 
    2040 
    2141    my $self = $class->SUPER::new(@_); 
     
    6181} 
    6282 
    63 sub setup_plugins { 
    64     my ($self, @args) = @_; 
    65  
    66     $self->packages_from_plugin_path([]); 
    67  
    68     if (my $path = $self->conf->{global}{plugin_path}) { 
    69         my $collect = Module::Collect->new( 
    70             path => $path, 
    71             pattern => '*.pm', 
    72             prefix => 'App::Hachero::Plugin', 
    73         ); 
    74         my $packages = $collect->modules; 
    75  
    76         $self->packages_from_plugin_path($packages); 
    77     } 
    78     $self->NEXT( setup_plugins => @args ); 
    79 } 
    80  
    8183sub class_component_load_plugin_resolver { 
    8284    my ($self, $package) = @_; 
    8385    $package = "App::Hachero::Plugin::$package"; 
    84     for my $pkg (@{ $self->packages_from_plugin_path }) { 
     86    for my $pkg (@{ $packages_from_plugin_path }) { 
    8587        return $pkg if $pkg->{package} eq $package; 
    8688    } 
  • lang/perl/App-Hachero/trunk/t/app/01_plugin_path.t

    r19113 r19223  
    11use strict; 
    22use warnings; 
    3 use Test::More tests => 1; 
     3use Test::More tests => 2; 
    44use File::Spec; 
    55use App::Hachero; 
     
    2121 
    2222ok $app; 
     23$app->run_hook('input'); 
     24is $app->currentline, 'ok'; 
  • lang/perl/App-Hachero/trunk/t/data/plugin/test_foo.pm

    r19113 r19223  
    44use base 'App::Hachero::Plugin::Base'; 
    55 
     6sub input : Hook { 
     7    my ($self, $context) = @_; 
     8    $context->currentline('ok'); 
     9} 
     10 
    6111;