Rote adds the following methods to the Rake::Task class.
Methods
Public Class methods
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.
[ show source ]
# File lib/rote/cache.rb, line 96
96: def self.memoize(args, &block)
97: task_name, deps = resolve_args(args)
98: fn = File.join(Rake.cache_dir, MD5.new(deps.inspect).to_s + "." + task_name)
99: Rake.register_dependency(deps)
100:
101: result = nil
102: # This file task isn't ever used other than manually below with t.invoke
103: t = file fn => deps do
104: result = block.call
105: mkdir_p Rake.cache_dir unless File.exists?(Rake.cache_dir)
106: File.open(fn,"w") { |fp| Marshal.dump(result,fp) }
107: end
108: if t.needed? then
109: t.invoke
110: result
111: else
112: Marshal.load(File.read(fn))
113: end
114: end
Public Instance methods
Execute the task, setting the executed flag. Used by the monitor task.
[ show source ]
# File lib/rote/rotetasks.rb, line 350
350: def execute
351: @executed = true
352: pre_rote_execute
353: end
Determine whether this task has been executed in this cycle. Used by the monitor task.
[ show source ]
# File lib/rote/rotetasks.rb, line 343
343: def executed?
344: @executed
345: end
Reset the executed and invoked flags on this task. Used by the monitor task.
[ show source ]
# File lib/rote/rotetasks.rb, line 336
336: def reset
337: @already_invoked = false
338: @executed = false
339: end