[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rakefile "$0" path in rake

Peter Pk

1/13/2009 2:58:00 PM

Is there a way to get the path to "itself" in a rakefile loaded by rake?

ie for:
rake --rakefile ../../some/path/to/rakefile.rb

***

inside rakefile

myPath = # ????
p "running #{myPath}"
--
Posted via http://www.ruby-....

3 Answers

Jan-Erik R.

1/13/2009 3:03:00 PM

0

Peter Pk schrieb:
> Is there a way to get the path to "itself" in a rakefile loaded by rake?
>
> ie for:
> rake --rakefile ../../some/path/to/rakefile.rb
>
> ***
>
> inside rakefile
>
> myPath = # ????
> p "running #{myPath}"
try using the "magic variable" __FILE__ ?

James Gray

1/13/2009 3:04:00 PM

0

On Jan 13, 2009, at 8:57 AM, Peter Pk wrote:

> Is there a way to get the path to "itself" in a rakefile loaded by
> rake?

Sure.

> ***
>
> inside rakefile
>
> myPath = # ????

my_path = File.expand_path(__FILE__)

> p "running #{myPath}"

Hope that helps.

James Edward Gray II

Peter Pk

1/13/2009 3:37:00 PM

0

badboy wrote:
> Peter Pk schrieb:
>> p "running #{myPath}"
> try using the "magic variable" __FILE__ ?

Thanks! Thats it!
--
Posted via http://www.ruby-....