Forum: Ruby Advice in rake

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2009-04-23 12:57
(Received via mailing list)
Hi,

I'm using rake to build a project and during this build process to
call some scripts as well.
The problem is now, that the number of required script runs is unknown
to rake prior to starting rake,
but can be determined after running the script once. So I'd like to
use the output of the first runto optionally call
the task again. What is the best way doing this?

Alternatively I could give a command line option to rake telling it
how often to run the task. I had the idea
of putting the number of runs behind the task name, like "run2",
"run1",...
This will require a dynamic detection in the rake file to separate the
actual task name "task" from the number of calls.
Is this possible?

I tried to call the task multiple times in the command line, "rake
task task task", but this executes it only once.

Thanks
   Peter
David Gaya (Guest)
on 2009-04-23 13:37
(Received via mailing list)
Rakefile:
  desc 'Task that runs the build and other scripts'
  task :build do
    number_of_runs = ( ENV['RUN'] ? ENV['RUN'] : 1 )
    number_of_runs.times do
      # Call whatever
    end
  end

Then in command line:
  $ rake task RUN=2

2009/4/23  <removed_email_address@domain.invalid>:
This topic is locked and can not be replied to.