In practice, File.dirname(__FILE__) is an extremely common idiom. Given
that, it seems reasonably to create a new constant.
Similarly, since require File.expand_path(File.join(File.dirname(__FILE__),
"foo")) is an extremely common idiom, require_relative "foo" seems like a
reasonable addition.

-- Yehuda

On Fri, Jul 17, 2009 at 6:24 AM, Joel VanderWerf <vjoel / path.berkeley.edu>wrote:

> Ryan Davis wrote:
>
>>
>> On Jul 16, 2009, at 06:30 , Roger Pack wrote:
>>
>>  __DIR__ would be a nice constant.
>>>
>>
>> Don't forget __DIR_DIR__ and __DIR_DIR_DIR__!!
>>
>> ...This feels vaguely familiar...
>>
>
> One way to get __DIR__ is:
>
> File.expand_path("..", __FILE__)
>
> and it has the advantage of iterating nicely:
>
> File.expand_path("../../..", __FILE__)
>
> It does have the side-effect of conversion to an absolute path, but that is
> usually (in my experience) part of the process anyway, so __DIR__ doesn't
> save much effort.
>
> --
>      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
>
>


-- 
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325