[Rt-commit] r5878 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Wed Sep 6 21:33:38 EDT 2006


Author: ruz
Date: Wed Sep  6 21:33:37 2006
New Revision: 5878

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin.pm

Log:
 r3707 at cubic-pc:  cubic | 2006-09-07 03:34:57 +0400
 ::Shredder::Plugin
 * add optional argument 'type' in method List


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin.pm	Wed Sep  6 21:33:37 2006
@@ -63,19 +63,37 @@
 library files as values. Method has no arguments. Can be used as class
 method too.
 
+Takes optional argument C<type> and leaves in the result hash only
+plugins of that type.
+
 =cut
 
 sub List
 {
     my $self = shift;
+    my $type = shift;
+
     my @files;
     foreach my $root( @INC ) {
-        my $mask = File::Spec->catdir( $root, qw(RT Shredder Plugin *.pm) );
+        my $mask = File::Spec->catfile( $root, qw(RT Shredder Plugin *.pm) );
         push @files, glob $mask;
     }
 
     my %res = map { $_ =~ m/([^\\\/]+)\.pm$/; $1 => $_ } reverse @files;
 
+    return %res unless $type;
+
+    delete $res{'Base'};
+    foreach my $name( keys %res ) {
+        my $class = join '::', qw(RT Shredder Plugin), $name;
+        unless( eval "require $class" ) {
+            delete $res{ $name };
+            next;
+        }
+        next if lc $class->Type eq lc $type;
+        delete $res{ $name };
+    }
+
     return %res;
 }
 


More information about the Rt-commit mailing list