Browse files

Fixes #8 stop Rake clashing with models named Task.

Stopped Rake being required by Seedbank.
Renamed Seedbank::Task to Seedbank::RenameTask.
Only add Seedbank::RenameTask and Seedbank::TaskManager when DSL included.

Signed-off-by: James McCarthy <james2mccarthy@gmail.com>
  • Loading branch information...
1 parent 9d81155 commit d757987f91996dc692912956ecd9f08798289c94 @james2m committed Jul 19, 2012
Showing with 7 additions and 6 deletions.
  1. +1 −3 lib/seedbank.rb
  2. +5 −0 lib/seedbank/dsl.rb
  3. +1 −1 lib/seedbank/{task.rb → rename_task.rb}
  4. +0 −2 lib/tasks/seed.rake
View
4 lib/seedbank.rb
@@ -1,10 +1,8 @@
require 'seedbank/dsl'
-require 'seedbank/task'
+require 'seedbank/rename_task'
require 'seedbank/task_manager'
require 'seedbank/runner'
-require 'rake' unless defined?(Rake)
-
module Seedbank
class << self
View
5 lib/seedbank/dsl.rb
@@ -1,6 +1,11 @@
module Seedbank
module DSL
+ def self.included(base)
+ Rake::Task.extend(Seedbank::RenameTask)
+ Rake::Application.send(:include, Seedbank::TaskManager)
+ end
+
def override_task(*args, &block)
name, params, deps = Rake.application.resolve_args(args.dup)
fq_name = Rake.application.instance_variable_get(:@scope).dup.push(name).join(':')
View
2 lib/seedbank/task.rb → lib/seedbank/rename_task.rb
@@ -1,5 +1,5 @@
module Seedbank
- module Task
+ module RenameTask
def rename_task(fq_name, new_name)
Rake.application.rename_task(fq_name, new_name)
View
2 lib/tasks/seed.rake
@@ -1,7 +1,5 @@
namespace :db do
- Rake::Task.extend(Seedbank::Task)
- Rake::Application.send(:include, Seedbank::TaskManager)
include Seedbank::DSL
base_dependencies = ['db:seed:original']

1 comment on commit d757987

@JurgenJocubeit

Nice work! And thanks for sorting this out... I think seedbank is invaluable and kudos to you for sharing it.

Please sign in to comment.