
|
# File rbot/plugins.rb, line 113
def scan
dirs = Array.new
dirs << File.dirname(__FILE__) + "/plugins"
dirs += @dirs
dirs.each {|dir|
if(FileTest.directory?(dir))
d = Dir.new(dir)
d.each {|file|
next if(file =~ /^\./)
next unless(file =~ /\.rb$/)
@tmpfilename = "#{dir}/#{file}"
# create a new, anonymous module to "house" the plugin
plugin_module = Module.new
begin
plugin_string = IO.readlines(@tmpfilename).join("")
plugin_module.module_eval(plugin_string)
rescue StandardError, NameError, LoadError, SyntaxError => err
puts "plugin #{@tmpfilename} load failed: " + err
puts err.backtrace.join("\n")
end
}
end
}
end
|