Sha256: 597aee64d30be64428b43c09c1a6b8f613e39cc38ed830ab6be50fece285845a

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Rake
  module TaskManager
    ##
    # This gives us access to the tasks already defined in rake.
    def all_tasks
      @tasks
    end
  end

  ##
  # Simple shortcut for Rake.application.all_tasks
  def self.all_tasks
    Rake.application.all_tasks
  end

  ##
  # Hooks into rake and allows us to clear out a task by name or
  # regexp. Use this if you want to completely override a task instead
  # of extend it.
  def self.clear_tasks(*tasks)
    tasks.flatten.each do |name|
      case name
      when Regexp then
        all_tasks.delete_if { |k,_| k =~ name }
      else
        all_tasks.delete(name)
      end
    end
  end

  ##
  # Removes the last action added to a task. Use this when two
  # libraries define the same task and you only want one of the
  # actions.
  #
  #   require 'hoe'
  #   require 'tasks/rails'
  #   Rake.undo("test") # rolls out rails' test task
  def self.undo(*names)
    names.each do |name|
      all_tasks[name].actions.delete_at(-1)
    end
  end
end unless Rake.respond_to? :all_tasks

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hoe-2.2.0 lib/hoe/rake.rb
hoe-2.0.0 lib/hoe/rake.rb
hoe-2.1.0 lib/hoe/rake.rb