class Rake::Task

Rote adds the following methods to the Rake::Task class.

Public Class Methods

memoize(args, &block) click to toggle source

Memoize the result of the block with respect to the file-based dependencies. Specify a description and dependencies like a Task:

Rake::Task.memoize :task_name => [fn1,fn2] { ... }

If the cached result is up-to-date with respect to the dependencies then the block will not be executed. Instead, the result will be unmarshalled from disk.

# File lib/rote/cache.rb, line 97
def self.memoize(args, &block)
  task_name, deps = resolve_args(args)
  fn = File.join(Rake.cache_dir, MD5.new(deps.inspect).to_s + "." + task_name)
  Rake.register_dependency(deps)
  
  result = nil
  # This file task isn't ever used other than manually below with t.invoke
  t = file fn => deps do
    result = block.call
    mkdir_p Rake.cache_dir unless File.exists?(Rake.cache_dir)
    File.open(fn,"w") { |fp| Marshal.dump(result,fp) }
  end
  if t.needed? then
    t.invoke
    result
  else
    Marshal.load(File.read(fn))
  end
end

Public Instance Methods

execute(args) click to toggle source

Execute the task, setting the executed flag. Used by the monitor task.

# File lib/rote/rotetasks.rb, line 350
def execute(args)
  @executed = true
  pre_rote_execute
end
Also aliased as: pre_rote_execute
executed?() click to toggle source

Determine whether this task has been executed in this cycle. Used by the monitor task.

# File lib/rote/rotetasks.rb, line 343
def executed?
  @executed
end
pre_rote_execute(args) click to toggle source
Alias for: execute
reset() click to toggle source

Reset the executed and invoked flags on this task. Used by the monitor task.

# File lib/rote/rotetasks.rb, line 336
def reset
  @already_invoked = false
  @executed = false
end