Changeset 745

Show
Ignore:
Timestamp:
05/15/06 18:03:03
Author:
miyagawa
Message:

allow plugins/Filter/Bar.pm directory structure.
http://d.hatena.ne.jp/fuba/20060514/1147579162#c

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger.pm

    r716 r745  
    159159                $ent = File::Spec->catfile($path, $ent); 
    160160                if (-f $ent && $ent =~ /\.pm$/) { 
    161                     my $pkg = $self->extract_package($ent) 
    162                         or die "Can't find package from $ent"; 
    163                     (my $base = $ent) =~ s!^$path/!!; 
    164                     $self->plugins_path->{$pkg} = $ent; 
     161                    $self->add_plugin_path($ent); 
    165162                } elsif (-d $ent) { 
    166163                    my $lib = File::Spec->catfile($ent, "lib"); 
     
    168165                        $self->log(debug => "Add $lib to INC path"); 
    169166                        unshift @INC, $lib; 
     167                    } else { 
     168                        my $rule = File::Find::Rule->new; 
     169                           $rule->file; 
     170                           $rule->name('*.pm'); 
     171                        my @modules = $rule->in($ent); 
     172                        for my $module (@modules) { 
     173                            $self->add_plugin_path($module); 
     174                        } 
    170175                    } 
    171176                } 
     
    177182        $self->load_plugin($plugin) unless $plugin->{disable}; 
    178183    } 
     184} 
     185 
     186sub add_plugin_path { 
     187    my($self, $file) = @_; 
     188 
     189    my $pkg = $self->extract_package($file) 
     190        or die "Can't find package from $file"; 
     191    $self->plugins_path->{$pkg} = $file; 
     192    $self->log(debug => "$file is added as a path to plugin $pkg"); 
    179193} 
    180194