Improve coding standards

This commit is contained in:
Thibault Jouan 2013-12-20 06:46:28 +00:00
parent 0b68a8165d
commit 9251c6af8e
4 changed files with 21 additions and 15 deletions

View File

@ -1,10 +1,10 @@
module Producer
module Core
class CLI
attr_reader :arguments
USAGE = "Usage: #{File.basename $0} recipe_file"
attr_reader :arguments
def initialize(arguments, stdout = $stdout)
@stdout = stdout
@arguments = arguments

View File

@ -1,12 +1,14 @@
module Producer
module Core
class Recipe
attr_accessor :tasks
def self.evaluate_from_file(filepath, env)
DSL.evaluate(File.read(filepath), env)
class << self
def evaluate_from_file(filepath, env)
DSL.evaluate(File.read(filepath), env)
end
end
attr_accessor :tasks
def initialize(tasks = [])
@tasks = tasks
end

View File

@ -2,13 +2,15 @@ module Producer
module Core
class Recipe
class DSL
attr_reader :tasks
def self.evaluate(code, env)
dsl = new(code).evaluate(env)
Recipe.new(dsl.tasks)
class << self
def evaluate(code, env)
dsl = new(code).evaluate(env)
Recipe.new(dsl.tasks)
end
end
attr_reader :tasks
def initialize(code = nil, &block)
@code = code
@block = block

View File

@ -1,12 +1,14 @@
module Producer
module Core
class Task
attr_reader :name, :actions, :condition
def self.evaluate(name, env, &block)
DSL.evaluate(name, env, &block)
class << self
def evaluate(name, env, &block)
DSL.evaluate(name, env, &block)
end
end
attr_reader :name, :actions, :condition
def initialize(name, actions = [], condition = true)
@name = name
@actions = actions