Class: Evoker::EntityTask
- Inherits:
-
Rake::FileTask
- Object
- Rake::FileTask
- Evoker::EntityTask
- Defined in:
- lib/evoker.rb
Overview
Specialized task class for downloaded entities
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Parsed yaml config for the task.
Instance Method Summary collapse
-
#execute(args = nil) ⇒ Object
Executes task and writes its timestamp file.
-
#initialize(*args, &block) ⇒ EntityTask
constructor
A new instance of EntityTask.
-
#needed? ⇒ Boolean
Use @stampname instead of task name to determine whether to re-do the task.
-
#timestamp ⇒ Object
Time stamp for file task is on the stamp file, not on target.
Constructor Details
#initialize(*args, &block) ⇒ EntityTask
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |
Instance Attribute Details
#config ⇒ Object (readonly)
Parsed yaml config for the task
28 29 30 |
# File 'lib/evoker.rb', line 28 def config @config end |
Instance Method Details
#execute(args = nil) ⇒ Object
Executes task and writes its timestamp file
45 46 47 48 |
# File 'lib/evoker.rb', line 45 def execute(args=nil) super File.open(@stampname, 'w') { |f| f.write(DateTime::now.to_s) } end |
#needed? ⇒ Boolean
Use @stampname instead of task name to determine whether to re-do the task
51 52 53 |
# File 'lib/evoker.rb', line 51 def needed? ! File.exist?(name) || ! File.exist?(@stampname) || out_of_date?() end |
#timestamp ⇒ Object
Time stamp for file task is on the stamp file, not on target.
56 57 58 59 60 61 62 |
# File 'lib/evoker.rb', line 56 def if File.exist?(@stampname) File.mtime(@stampname) else Rake::EARLY end end |