Class: Evoker::EntityTask
- Inherits:
-
Rake::FileTask
- Object
- Rake::FileTask
- Evoker::EntityTask
- Defined in:
- lib/evoker.rb
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
Returns a new instance of EntityTask.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/evoker.rb', line 27 def initialize(*args, &block) super(*args, &block) @stampname = "#{@name}.stamp" @actions << lambda { 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
25 26 27 |
# File 'lib/evoker.rb', line 25 def config @config end |
Instance Method Details
#execute(args = nil) ⇒ Object
Executes task and writes its timestamp file
42 43 44 45 |
# File 'lib/evoker.rb', line 42 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
48 49 50 |
# File 'lib/evoker.rb', line 48 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.
53 54 55 56 57 58 59 |
# File 'lib/evoker.rb', line 53 def if File.exist?(@stampname) File.mtime(@stampname) else Rake::EARLY end end |