Changeset 19223
- Timestamp:
- 09/12/08 16:32:18 (5 years ago)
- Location:
- lang/perl/App-Hachero/trunk
- Files:
-
- 4 modified
-
Makefile.PL (modified) (1 diff)
-
lib/App/Hachero.pm (modified) (3 diffs)
-
t/app/01_plugin_path.t (modified) (2 diffs)
-
t/data/plugin/test_foo.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-Hachero/trunk/Makefile.PL
r19113 r19223 27 27 build_requires 'Test::Base'; 28 28 29 install_script 'hachero.pl'; 30 29 31 tests 't/*.t t/*/*.t t/*/*/*.t'; 30 32 -
lang/perl/App-Hachero/trunk/lib/App/Hachero.pm
r19114 r19223 10 10 use Module::Collect; 11 11 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/); 14 14 15 my $packages_from_plugin_path; 15 16 my $context; 16 17 sub context { $context } … … 18 19 sub new { 19 20 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); 20 40 21 41 my $self = $class->SUPER::new(@_); … … 61 81 } 62 82 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 81 83 sub class_component_load_plugin_resolver { 82 84 my ($self, $package) = @_; 83 85 $package = "App::Hachero::Plugin::$package"; 84 for my $pkg (@{ $ self->packages_from_plugin_path }) {86 for my $pkg (@{ $packages_from_plugin_path }) { 85 87 return $pkg if $pkg->{package} eq $package; 86 88 } -
lang/perl/App-Hachero/trunk/t/app/01_plugin_path.t
r19113 r19223 1 1 use strict; 2 2 use warnings; 3 use Test::More tests => 1;3 use Test::More tests => 2; 4 4 use File::Spec; 5 5 use App::Hachero; … … 21 21 22 22 ok $app; 23 $app->run_hook('input'); 24 is $app->currentline, 'ok'; -
lang/perl/App-Hachero/trunk/t/data/plugin/test_foo.pm
r19113 r19223 4 4 use base 'App::Hachero::Plugin::Base'; 5 5 6 sub input : Hook { 7 my ($self, $context) = @_; 8 $context->currentline('ok'); 9 } 10 6 11 1;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)