On Thu, Mar 28, 2002 at 03:31:15PM +0900, nobu.nokada / softhome.net wrote:
> Rather, IMHO, it's better to use relative path from __FILE__
> for that purpose,
> 
>  $LOAD_PATH << File.join(File.dirname(__FILE__), "../src")
> 
> or
> 
>  $LOAD_PATH << File.expand_path("../src", File.dirname(__FILE__))

Alternatively, RubyTreasures has "requirelocal" and "loadlocal":

  require 'loaders'
  requirelocal '../src/code.under.test'
  loadlocal 'config.rb'

This has the added advantage of canonicalizing the path before requiring
the file, so if you require the same file twice with different names
(even if it is symlinked), it is still loaded only once.

The source for 'loaders.rb' can be found at:

  http://rm-f.net/~cout/ruby/treasures/RubyTreasures-0.3/lib/hacks/loaders.rb.html

Paul