class Evoker::EntityTask

Specialized task class for downloaded entities

Attributes

config[R]

Parsed yaml config for the task

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method
# File lib/evoker.rb, line 30
def initialize(*args, &block)
  super(*args, &block)
  @stampname = "#{@name}.stamp"
  @actions << lambda { |*args| FileUtils::rm_rf @name }
  CLOBBER.add([@stampname, @name])
  ENTITIES.add(@name)

  if File.exists? "#{@name}.yaml"
    require 'yaml'
    @config = YAML::load_file("#{@name}.yaml")
    self.enhance [Rake.application.intern(Rake::FileTask, "#{@name}.yaml")]
  end
end

Public Instance Methods

execute(args=nil) click to toggle source

Executes task and writes its timestamp file

Calls superclass method
# File lib/evoker.rb, line 45
def execute(args=nil)
  super
  File.open(@stampname, 'w') { |f| f.write(DateTime::now.to_s) }
end
needed?() click to toggle source

Use @stampname instead of task name to determine whether to re-do the task

# File lib/evoker.rb, line 51
def needed?
  ! File.exist?(name) || ! File.exist?(@stampname) || out_of_date?(timestamp)
end
timestamp() click to toggle source

Time stamp for file task is on the stamp file, not on target.

# File lib/evoker.rb, line 56
def timestamp
  if File.exist?(@stampname)
    File.mtime(@stampname)
  else
    Rake::EARLY
  end
end