Michael Morin wrote: > module Kernel > alias modwhich_original_require require > $MODWHICH_SEEN = [] > > def require(path) > p = > path + > (path =~ %r{\.[^/]+$} ? '' : '.rb') > > dir = $LOAD_PATH.find do|d| > File.exists? "#{d}/#{p}" > end > > return if $MODWHICH_SEEN.include? "#{dir}/#{p}" > $MODWHICH_SEEN << "#{dir}/#{p}" > > puts "require: #{path} => #{dir}/#{p}" unless dir.nil? > modwhich_original_require path > end > end Small bug fix to account of files that aren't found. module Kernel alias modwhich_original_require require $MODWHICH_SEEN = [] def require(path) p = path + (path =~ %r{\.[^/]+$} ? '' : '.rb') dir = $LOAD_PATH.find do|d| File.exists? "#{d}/#{p}" end # Let the original require raise an exception if # the file is not found. return modwhich_original_require(path) if dir.nil? return if $MODWHICH_SEEN.include? "#{dir}/#{p}" $MODWHICH_SEEN << "#{dir}/#{p}" puts "require: #{path} => #{dir}/#{p}" unless dir.nil? modwhich_original_require path end end -- Michael Morin Guide to Ruby http://ruby.about.com/ Become an About.com Guide: beaguide.about.com About.com is part of the New York Times Company