Hi brian,
Thanks for the reply. Here''s my requirement more specifically:
We have more than 200 tasks split across 10 different .rake files, and
we "load" them all from the Rakefile. However since these are too many
loading them all takes time (about 10 secs) and so it hurts if we have
to run rake repeatedly. So I am looking for a way to load only the
required .rake file based on the namespace:taskname supplied on the
rake command line.
Is there a way to do this? Thanks for any ideas.
S
On 4/13/11, Bryan Crossland
<bacrossland-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On Wed, Apr 13, 2011 at 9:18 AM, Santosh
<santoshc197-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Hi,
>> does anyone know how one can reference the task being executed and get
>> its name in the Rakefile. For example, I want this:
>>
>>
>> puts "You chose the task: " + taskname
>>
>> task :egg do
>> puts " 1 egg "
>> end
>>
>> task :milk do
>> puts " 1 glass milk "
>> end
>>
>>
>> Depending on the task name, I want to do load certain time consuming
>> things before the task is executed. Any ideas?
>>
>
>
> Hi Santosh,
>
> If your tasks are inside of a namespace you already know which one is being
> called. It would not be hard to pass the name of the task to private
> function outside the namespace that will do some addition work for you.
Here
> is a simple example of what I''m talking about.
>
> namespace :grocery do
> task :egg do
> shop_list("egg")
> puts " 1 egg "
> end
>
> task :milk do
> shop_list("milk")
> puts " 1 glass milk "
> end
> end
>
> private
>
> def shop_list(item)
> puts "You are looking for #{item}"
> end
>
> Let me know if this is not what you are looking for.
>
> B.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.