On Tuesday 09 September 2003 16:20, Recheis Meinrad wrote:
> hi,
> but i am not very pleased with it. the library in the directory lib, must
> not know from where it is required. what can i do so that lib can require
> all it's files no matter where the script that requires lib.rb is located?
One of the things I most like in Ruby, is that even core functionality can be 
easily modified at run-time:

[start messy untested code]

alias :_oldrequire :require
def require(req)
  if req=~/\//
    splited=req.split('/')
    req_file=splited.pop
    req_path=splited.join('/')
    oldpath=Dir.pwd
    Dir.chdir req_path
    ret=_oldrequire(req_file)
    Dir.chdir oldpath
    return ret
  else
    _oldrequire(req)
  end
end

[end messy untested code]