From: Nikodemus Siivola Date: 2002-05-08T18:38:58+09:00 Subject: require variants Regarding the recent dicussion of having require "dir" recursively require all *.rb's in dir: As transami pointed out, this would enable the the user to easily organize disorganized libraries whose authors have just assumed that they reside in the load path. Just drop the recursion to enable libraries to have private files: def require_lib( lib ) $:.each do |dir| path = "#{dir}/#{lib}" Dir["#{path}/*.rb"].each { |f| require f } if File.directory?( path ) end end alias :require_dir :require_lib Just typed it up without testing so there's bound to be a bug there ;) and it doesn't handle *.so's *.o's *.dll's and what you's... But the idea is there. And as a companion tool it would be nice to be able to know that you are getting a file from the same directory as opposed to somewhere in path: def require_local( file ) local = caller.last.split(":").first dir = File.dirname( File.expand_path(local) ) require "#{dir}/#{file}" end Also untested. What do you think? -- Nikodemus