From: Eric Hodel <drbrain@...7.net> Date: 2010-08-27T14:43:24+09:00 Subject: [ruby-core:31885] Avoiding $LOAD_PATH pollution Last year Nobu asked me to propose an API for adding an object to $LOAD_PATH (instead of a String) that could do the work of finding paths to load. The reason was to avoid the pollution of $LOAD_PATH that RubyGems causes as it activates multiple gems. I have created a proof-of-concept implementation called fancy_require: http://github.com/drbrain/fancy_require specifically: http://github.com/drbrain/fancy_require/blob/master/lib/fancy_require.rb The API I propose for the lookup object added to $LOAD_PATH is: The lookup object pushed onto $LOAD_PATH must respond to #path_for. The feature being required (file name) will be passed in by Kernel#require. The lookup object must return the path to the feature, true, false or nil. If nil is returned Kernel#require will continue to the next item in the load path. If true or false are returned the lookup object handled loading the file and recording it in $LOADED_FEATURES. The boolean will be returned as plain require. The true/false behavior would allow the lookup object to load features from a non-file object like a tarball. I think Ruby should also add a method that would determine if a feature is in $LOADED_FEATURES. Maybe Kernel#loaded?(feature). This is not strictly necessary.