From: Tom Sawyer Date: 2003-01-12T08:09:03+09:00 Subject: Re: 'require' search path On Saturday 11 January 2003 04:23 am, Tim Bates wrote: > I wish 'require' would count the current directory as the directory the > file is in, rather than the directory the script is being run from. wish granted: module Kernel alias :require_basic :require def require(file_or_directory) if FileTest.directory?(file_or_directory) require "#{file_or_directory}/#{file_or_directory}" else fp = File.dirname(File.expand_path(file_or_directory)) $: << fp r = require_basic file_or_directory i = $LOAD_PATH.index(fp) $LOAD_PATH.delete_at(i) if i return r end end end please test and improve upon. i have only done so minorly. notice also that it adds my much wished for ability to auto-require things like 'dbi/dbi' just by using 'dbi'. this has been added to tomslib/rubylib (new release still pending) -- tom sawyer, aka transami transami@transami.net .''. .''. . *''* :_\/_: . :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- :_\/_:'.:::. | ' *''* * '.\'/.' _\(/_'.':'.' : /\ : ::::: = *_\/_* -= o =- /)\ ' * '..' ':::' === * /\ * .'/.\'. '._____ * | *..* : |. |' .---"| * | _ .--'| || | _| | * | .-'| __ | | | || | .-----. | |' | || | | | | | || | ___' ' /"\ | '-."". '-' '-.' '` |_. ------------------------------------------------------------