Jackson,
Thanks for the idea. I tried the technique to override the
clone_structure task as shown in the link and get the following error
(see below). Any ideas? I''m using rake 0.7.1 and in checking
Rake''s
source code the resolve_args() is under the TaskManager module which
is included when rake is ran from the command line. Any help is much
appreciated.
Thanks,
Zack
$ rake db:test:clone_structure
(in /Users/zackchandler/dev/tabarca)
rake aborted!
undefined method `resolve_args'' for Rake::Task:Class
/Users/zackchandler/dev/tabarca/rakefile:10
(See full trace by running task with --trace)
$
--- custom.rake ---
module Rake
class Task
# Clear all existing actions for the given task and then set the
# action for the task to the given block.
def self.redefine_task(args, &block)
task_name, deps = resolve_args(args)
TASKS.delete(task_name.to_s)
define_task(args, &block)
end
end
end
# Clear all existing actions for the given task and then set the
# action for the task to the given block.
def redefine_task(args, &block)
Rake::Task.redefine_task(args, &block)
end
# Alias one task name to another task name. This let''s a following
# task rename the original task and still depend upon it.
def alias_task(new_name, old_name)
Rake::Task::TASKS[new_name.to_s] = Rake::Task::TASKS.delete(old_name.to_s)
end
namespace :db do
namespace:test do
# Delete the original clone_structure_to_test task and create a new
# one that uses the SQL DDL files to set up the database.
desc "Faster replacement for the original :clone_structure"
redefine_task :clone_structure => :environment do
abcs = ActiveRecord::Base.configurations
`mysql -p #{abcs["test"]["database"]} <
#{RAILS_ROOT}/db/create.sql`
end
end
end
On 5/2/06, Jackson Miller <jackson.miller@greatlodge.com>
wrote:> On Tuesday 02 May 2006 10:34 am, Zack Chandler wrote:
> > Does anyone know how to extend the buit-in rake tasks like test:unit.
> > I want to custom load some fixtures in a particular order.
>
> Basically you extend rake to allow a redefine_task method. I have not had
as
> much luck getting an alias_task method to work. I think both of those
would
> be nice additions to Rake ;)
>
> This should get you started:
> http://article.gmane.org/gmane.comp.lang.ruby.rails/27426
>
> -Jackson
>
> >
> > Thanks,
> > Zack
> > _______________________________________________
> > Rails mailing list
> > Rails@lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>