class Rake::Task

Attributes

is_only_one_task[RW]
working_dir[RW]

Public Instance Methods

execute(args=nil) click to toggle source

Execute the actions associated with this task.

# File lib/only_one_rake.rb, line 33
def execute(args=nil)
  args ||= EMPTY_TASK_ARGS
  if application.options.dryrun
    application.trace "** Execute (dry run) #{name}"
    return
  end
  if application.options.trace
    application.trace "** Execute #{name}"
  end
  application.enhance_with_matching_rule(name) if @actions.empty?

  # here's the patch!
  self.working_dir = `pwd`.strip # it'll maybe change in the task, so set it first
  Rake.ensure_only_one_task_is_running name, self.working_dir if self.is_only_one_task

  @actions.each do |act|
    case act.arity
    when 1
      act.call(self)
    else
      act.call(self, args)
    end
  end
end