Sha256: ec001b52ae9e9ff0f76de9f2582a2f3451cc974a99a97ccfecb020ec8e2b1c8e

Contents?: true

Size: 745 Bytes

Versions: 3

Compression:

Stored size: 745 Bytes

Contents

# Redefine instead of chain a Rake task
# http://www.bigbold.com/snippets/posts/show/2032

module Rake
  module TaskManager
    def redefine_task(task_class, args, &block)
      task_name, deps = resolve_args(args)
      task_name = task_class.scope_name(@scope, task_name)
      deps = [deps] unless deps.respond_to?(:to_ary)
      deps = deps.collect {|d| d.to_s }
      task = @tasks[task_name.to_s] = task_class.new(task_name, self)
      task.application = self
      task.add_comment(@last_comment)
      @last_comment = nil
      task.enhance(deps, &block)
      task
    end
  end
  class Task
    class << self
      def redefine_task(args, &block)
        Rake.application.redefine_task(self, args, &block)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
has_many_polymorphs-2.10 lib/has_many_polymorphs/rake_task_redefine_task.rb
has_many_polymorphs-2.11 lib/has_many_polymorphs/rake_task_redefine_task.rb
has_many_polymorphs-2.9 lib/has_many_polymorphs/rake_task_redefine_task.rb