Sha256: 46f68e40567cccd2176e30c057a18cbcc5e19f8a96c6fa04414c1fa2b304b1c6

Contents?: true

Size: 676 Bytes

Versions: 6

Compression:

Stored size: 676 Bytes

Contents

#
# I would love to claim credit for this code, but I cannot. It comes from the
# good folk over at metaskills.net
#
# http://www.metaskills.net/2010/5/26/the-alias_method_chain-of-rake-override-rake-task
#

Rake::TaskManager.class_eval do
  def alias_task(fq_name)
    new_name = "#{fq_name}:original"
    @tasks[new_name] = @tasks.delete(fq_name)
  end
end

def alias_task(fq_name)
  Rake.application.alias_task(fq_name)
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(':')
  alias_task(fq_name)
  Rake::Task.define_task(*args, &block)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bones-3.7.3 lib/bones/rake_override_task.rb
bones-3.7.2 lib/bones/rake_override_task.rb
bones-3.7.1 lib/bones/rake_override_task.rb
bones-3.7.0 lib/bones/rake_override_task.rb
bones-3.6.5 lib/bones/rake_override_task.rb
bones-3.6.4 lib/bones/rake_override_task.rb