This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/debride.rb b/lib/debride.rb | |
index 54e2f4f..7730457 100755 | |
--- a/lib/debride.rb | |
+++ b/lib/debride.rb | |
@@ -35,31 +35,36 @@ class Debride < MethodBasedSexpProcessor | |
end | |
def self.load_plugins proj = PROJECT | |
- unless defined? @@plugins then | |
- @@plugins = [] | |
+ unless defined? @@load_plugins then | |
+ @@load_plugins = true | |
+ seen = [] | |
task_re = /#{PROJECT}_task/o | |
plugins = Gem.find_files("#{PROJECT}_*.rb").reject { |p| p =~ task_re } | |
plugins.each do |plugin| | |
plugin_name = File.basename(plugin, ".rb").sub(/^#{PROJECT}_/o, "") | |
- next if @@plugins.include? plugin_name | |
+ next if seen.include? plugin_name | |
begin | |
load plugin | |
- @@plugins << plugin_name | |
+ seen << plugin_name | |
rescue LoadError => e | |
warn "error loading #{plugin.inspect}: #{e.message}. skipping..." | |
end | |
end | |
end | |
- | |
- @@plugins | |
rescue | |
# ignore | |
end | |
def self.file_extensions | |
- %w[rb rake] + load_plugins | |
+ old_methods = instance_methods - superclass.instance_methods | |
+ load_plugins | |
+ new_methods = instance_methods - old_methods | |
+ | |
+ file_extensions = new_methods.grep(/^process_/).map {|m| m.to_s.sub(/^process_/, "") } | |
+ | |
+ %w[rb rake] + file_extensions | |
end | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment