Implement recipe evaluation feature

This commit is contained in:
Thibault Jouan
2013-07-22 14:59:54 +00:00
parent f0d90c96e9
commit 0921be9ab0
8 changed files with 95 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ require 'producer/core/version'
module Producer
module Core
autoload :CLI, 'producer/core/cli'
autoload :CLI, 'producer/core/cli'
autoload :Recipe, 'producer/core/recipe'
end
end

View File

@@ -12,6 +12,8 @@ module Producer
def run!
print_usage_and_exit(64) unless @arguments.length == 2
Recipe.from_file(@arguments[1]).evaluate
end

View File

@@ -0,0 +1,19 @@
module Producer
module Core
class Recipe
attr_reader :code
def self.from_file(filepath)
new(File.read(filepath))
end
def initialize(code)
@code = code
end
def evaluate
Object.new.instance_eval @code
end
end
end
end