In article <jrK2c.57106$lS1.31212 / fe2.texas.rr.com>, Its Me wrote:
>I can see some problems with how 'require' works (e.g. how do I refer to a
>relative path from current working directory?), and recall seeing some
>postings to fix it. A quick search did not uncover it. Any pointers?
[...]

[ruby-talk:92675]
http://www.rubytalk.com/92675

I have a utility library which contains (among other things)

  class << File
    def relative(base, restpath)
      File.join(File.dirname(base), restpath)
    end
  end

At the top of my programs, I load this utility library. Then I can do
  
  require File.relative(__FILE__, 'foo/bar')


You could also do

  module Kernel
    def require_relative(path)
      matchdata = /^(.*):[0-9]+(:in .*)?$/.match(caller[0]) or
      	raise "Unexpected caller format: #{caller[0].inspect}"
      require File.relative(matchdata[1], path)
    end
  end
 
Then you can just have

  require_relative 'foo/bar'

-- 
Tim Sutherland <timsuth / ihug.co.nz>
2004 SDKACM President
Software Developers' Klub - the University of Auckland ACM Student Chapter
http://www.sdkacm.com/