class Minarai::Command

Public Class Methods

new(args) click to toggle source
# File lib/minarai/command.rb, line 8
def initialize(args)
  @args = args
end

Public Instance Methods

call() click to toggle source
# File lib/minarai/command.rb, line 12
def call
  Minarai::Logger.info 'Minarai starting...'
  abort_with_error_message unless recipe.valid?
  recipe.runner.run
  Minarai::Logger.info 'Minarai finish'
end

Private Instance Methods

abort_with_error_message() click to toggle source
# File lib/minarai/command.rb, line 21
def abort_with_error_message
  Minarai::Logger.error(recipe.errors) and abort
end
recipe() click to toggle source
# File lib/minarai/command.rb, line 25
def recipe
  @recipe ||= Minarai::Loaders::RecipeLoader.new(recipe_path, variable_path: variable_path).load
end
recipe_missing_error() click to toggle source
# File lib/minarai/command.rb, line 33
def recipe_missing_error
  Minarai::Errors::MissingRecipePathError.new
end
recipe_path() click to toggle source
# File lib/minarai/command.rb, line 29
def recipe_path
  slop_options.arguments[0] || (Minarai::Logger.error(recipe_missing_error) and abort)
end
slop_options() click to toggle source
# File lib/minarai/command.rb, line 41
def slop_options
  @slop_options ||= Slop.parse(@args, suppress_errors: true) do |option|
    option.string '-v', '--variables', 'variable file for erb recipe file'
  end
end
variable_path() click to toggle source
# File lib/minarai/command.rb, line 37
def variable_path
  slop_options[:variables]
end