Module: Rake::Hooks

Defined in:
lib/rake/hooks/version.rb,
lib/rake/hooks.rb

Constant Summary collapse

VERSION =
"1.2.3"

Instance Method Summary collapse

Instance Method Details

#after(*task_names, &new_task) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rake/hooks.rb', line 13

def after(*task_names, &new_task)
  task_names.each do |task_name|
    old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
    desc old_task.full_comment
    task task_name do
      old_task.invoke
      new_task.call
    end
  end
end

#before(*task_names, &new_task) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/rake/hooks.rb', line 2

def before(*task_names, &new_task)
  task_names.each do |task_name|
    old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
    desc old_task.full_comment
    task task_name do
      new_task.call
      old_task.invoke
    end
  end
end