[Rake-devel] Question about namespace

Leon Yeh leon at newavenue.net
Mon Dec 25 20:05:27 EST 2006


After Rails Edge event attending rake tutorial by Jim Weitich, I got 
fired up to move all of my bash based cron script ( backup, database 
cleanup, etc ) into rake, so I can chain more tasks together, and create 
file dependencies between tasks.

The idea is to create something like this :

\raketasks
    \cleanup_db.rake
    \filter_mail.rake
    \rakefile


with each rake file under their own namespace, for example for:
[cleanup_db.rake]
namespace :cleanup_db

    def func1
       ...
    end

    task :default => ...
end
--------------------------------------

[filter_mail.rake]
namespace :filter_mail

    def func1
       ...
    end

    task :default => ...
end
--------------------------------------

[rakefile]
require cleanup_db.rake
require filter_mail.rake

task :default  => [filter_mail:default, cleanup_db:default]

--------------------------------------

Everythings looks good and appear to be working, however I found that the namespace does not applied to the function. So when a func1 get called, it was executed at both place.


Can someone let me know on how to make the function is part of the namespace and will not "collide" or get called twice ? I have not checked if capistrano is the place to do this or I am just mis-using rake.


Thanks in advance.

Leon Yeh
New Avenue Systems Inc.
Imagination Delivered. www.newavenue.net




More information about the Rake-devel mailing list