Implement basic task actions API:

* Add Action base class;
* Implement Task::DSL.define_action(keyword, klass);
* Add Task::DSL#actions accessor;
* Apply task DSL actions when Task instances are evaluated.
This commit is contained in:
Thibault Jouan
2013-08-03 14:45:14 +00:00
parent 8e455fc4d5
commit e6c14f1903
7 changed files with 92 additions and 3 deletions

View File

@@ -2,11 +2,23 @@ module Producer
module Core
class Task
class DSL
class << self
def define_action(keyword, klass)
define_method(keyword) do |*args|
@actions << klass.new(@env, *args)
end
end
end
attr_accessor :actions
def initialize(&block)
@block = block
@block = block
@actions = []
end
def evaluate(env)
@env = env
instance_eval &@block
rescue ConditionNotMetError
rescue NameError => e