Changeset 693

Show
Ignore:
Timestamp:
05/09/06 05:21:03
Author:
miyagawa
Message:

Load pluguins from plugins/*/lib, so that you can checkout external svn plugins to plugins/Something. Fixes #212

Files:

Legend:

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

    r683 r693  
    151151    if ($self->conf->{plugin_path}) { 
    152152        for my $path (@{ $self->conf->{plugin_path} }) { 
    153             my $rule = File::Find::Rule->new; 
    154                $rule->file; 
    155                $rule->name( qr/^\w[\w\.]*$/ ); 
    156             my @files = $rule->in($path); 
    157  
    158             for my $file (@files) { 
    159                 next if $file =~ /\W(?:\.svn|CVS)\b/; 
    160                 my $pkg = $self->extract_package($file) 
    161                     or die "Can't find package from $file"; 
    162  
    163                 (my $base = $file) =~ s!^$path/!!; 
    164                 $self->plugins_path->{$pkg} = $file; 
     153            opendir my $dir, $path or do { 
     154                $self->log(warn => "$path: $!"); 
     155                next; 
     156            }; 
     157            while (my $ent = readdir $dir) { 
     158                next if $ent =~ /^\./; 
     159                $ent = File::Spec->catfile($path, $ent); 
     160                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; 
     165                } elsif (-d $ent) { 
     166                    my $lib = File::Spec->catfile($ent, "lib"); 
     167                    if (-e $lib && -d _) { 
     168                        $self->log(debug => "Add $lib to INC path"); 
     169                        unshift @INC, $lib; 
     170                    } 
     171                } 
    165172            } 
    166173        }