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:
@@ -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
|
||||
|
Reference in New Issue
Block a user