Jean-denis Vauguet wrote:
> I don't know if this practice of relying on $0 is solid, though.
It's very risky:
* on many platforms it's truncated
* the script which the user started running isn't necessarily the file
which is requiring your code
I suggest you look at Kernel#caller instead.
Unfortunately it just gives you strings which you have to parse
yourself, and you'll probably need to grep out all the rubygems-related
paths.
For an example, look in the sinatra gem (lib/sinatra/base.rb,
specifically methods caller_locations and caller_files). Sinatra uses
this to locate the application source code, for reading inline
templates.
--
Posted via http://www.ruby-forum.com/.