Thibault Jouan 0904fa1fc9 Implement Worker class:
* Move recipe processing code in the worker;
* Refactor CLI and use the the worker;
* Implement Recipe#tasks and remove tasks application during evaluation,
  tasks are now applied by the worker after all evaluations are done.
2013-08-10 14:47:02 +00:00

24 lines
478 B
Ruby

module Producer
module Core
class Recipe
attr_reader :code, :filepath, :tasks
def self.from_file(filepath)
new(File.read(filepath), filepath)
end
def initialize(code, filepath = nil)
@code = code
@filepath = filepath
@tasks = []
end
def evaluate(env)
dsl = DSL.new(@code).evaluate(env)
dsl.tasks.map { |e| e.evaluate env }
@tasks = dsl.tasks
end
end
end
end