From: Paul Brannan Date: 2002-05-08T20:53:31+09:00 Subject: Re: require variants On Wed, May 08, 2002 at 06:38:58PM +0900, Nikodemus Siivola wrote: > 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... Handling these would be nontrivial. I think a better solution is to write (or generate) a script with the same name as the directory; the script can recurse through the directory itself or require individual files, as the author sees fit. > 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 I agree. I use something like this in ALL my Ruby code, and I would very much like it I could distribute code that depends on something like this, without having to duplicate it in each of my projects. See: [ruby-talk:21406] And: http://rm-f.net/~cout/ruby/treasures/RubyTreasures-0.4/lib/hacks/loaders.rb.html for a more complete version. Paul