From: Tom Sawyer Date: 2003-01-12T10:57:52+09:00 Subject: Re: 'require' search path On Saturday 11 January 2003 06:38 pm, dblack@candle.superlink.net wrote: > > 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'. > > And seems to do away with the ability to require things like 'scanf' > just by using 'scanf'.... > > candle:~/hacking/ruby$ ruby req.rb > req.rb:10:in `require': No such file to load -- scanf/scanf (LoadError) > from req.rb:10:in `require' > from req.rb:6:in `require' > from req.rb:18 > > In any event, I think it might be best to consider writing a new > method, rather than overriding require, if you want to create a new > package-loading functionality. 'require' and 'load' are spoken for, > and you're going to end up quarantining your code from the rest of > Ruby if you redefine them. David, well, hopefully it just needs a fix. i don't seem to have scanf. so i can't test this. i take it though that the problem is that there is a scanf directory and a scanf include file. the require is finding the directory first and thus failing. hmm...just need to make sure it looks for the file first, prior to trying it as a "directory-require". how to do?... yes, there may be some unexpected "successful" requires due to this code that normally would fail, but (once fixed) i see no reason that it should cause previous code to break. so there should be no issue of quarantining. also, that was an aside adjustment. the second part is the more intersesting of the two alterations. see any problems with that? i esspecially like this. i find it awfully painful to have to go through my files and change requires simple b/c i've decided to put them in a different directory. -- tom sawyer, aka transami transami@transami.net .''. .''. . *''* :_\/_: . :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- :_\/_:'.:::. | ' *''* * '.\'/.' _\(/_'.':'.' : /\ : ::::: = *_\/_* -= o =- /)\ ' * '..' ':::' === * /\ * .'/.\'. '._____ * | *..* : |. |' .---"| * | _ .--'| || | _| | * | .-'| __ | | | || | .-----. | |' | || | | | | | || | ___' ' /"\ | '-."". '-' '-.' '` |_. ------------------------------------------------------------