Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > A Rake executable script, is this the correct approach

Reply
Thread Tools

A Rake executable script, is this the correct approach

 
 
John Pywtorak
Guest
Posts: n/a
 
      10-25-2006
I humbly come to you, because searching, mostly google, has failed to
produce a reference, or someone who has done this.

We traditionally run Rakefile's using either
$ rake
or
$ rake -f my.rake
etc

what if I wanted an executable script, say myscript, which is really a
rake task file, but runs as though it where run as above.
Attempt 1
#!/usr/bin/env rake
task :default do puts "Hello, Rake!" end
FAILED

Attempt 2
#!/usr/bin/env ruby
task :default do puts "Hello, Rake!" end
Rake::Task[:default].invoke
SUCCESS

So, is the latter really the best way? While it works I worry that rake
is somehow not setup the same way if the this had been run the
traditional way. Thanks

--
Windows
Start Here
Frustrating Hanging Crashing
Blue Screen of Death
Reboot




 
Reply With Quote
 
 
 
 
John Pywtorak
Guest
Posts: n/a
 
      10-25-2006
You missed the point and the sha-bang in attempt 1 which was
#!/usr/bin/env rake, not ruby.

I understand what rake is doing, what I want is an executable rake file
without having to explicitly run rake. Thanks

Jason Roelofs wrote:
> Well, attempt 1 is merely defining the task, the task then has to be run,
> which is what's happening in Attempt 2.
>
> When you type `rake` in the command line, what you are really doing is
>
> rake default
>
> Hopefully that explains what's going on.
>
> Jason
>
> On 10/25/06, John Pywtorak <(E-Mail Removed)> wrote:
>>
>> I humbly come to you, because searching, mostly google, has failed to
>> produce a reference, or someone who has done this.
>>
>> We traditionally run Rakefile's using either
>> $ rake
>> or
>> $ rake -f my.rake
>> etc
>>
>> what if I wanted an executable script, say myscript, which is really a
>> rake task file, but runs as though it where run as above.
>> Attempt 1
>> #!/usr/bin/env rake
>> task :default do puts "Hello, Rake!" end
>> FAILED
>>
>> Attempt 2
>> #!/usr/bin/env ruby
>> task :default do puts "Hello, Rake!" end
>> Rake::Task[:default].invoke
>> SUCCESS
>>
>> So, is the latter really the best way? While it works I worry that rake
>> is somehow not setup the same way if the this had been run the
>> traditional way. Thanks
>>
>> --
>> Windows
>> Start Here
>> Frustrating Hanging Crashing
>> Blue Screen of Death
>> Reboot
>>
>>
>>
>>
>>

>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple rake build files? large rake files thufir Ruby 3 04-12-2008 07:28 AM
rake published rdoc version and arity of Rake::Task#execute - wrongnumber of arguments (0 for 1) James Mead Ruby 0 01-15-2008 05:42 PM
Rake TestTask running its block anytime rake is invoked Adam Anderson Ruby 1 09-19-2007 08:40 AM
Rake and rake aborted! Rake aborted! undefined method `gem' for main:Object peppermonkey Ruby 1 02-10-2007 04:43 AM
Rake 0.7.0 breaks "rake engine_migrate"? Joe Van Dyk Ruby 2 01-31-2006 12:11 AM



Advertisments