Module: Bebox::CommandsHelper

Includes:
WizardsHelper
Included in:
ProjectCommands
Defined in:
lib/bebox/commands/commands_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WizardsHelper

#choose_option, #confirm_action?, #valid_puppet_class_name?, #write_input

Class Method Details

.vagrant_installed?Boolean

Check if vagrant is installed on the machine

Returns:

  • (Boolean)


27
28
29
# File 'lib/bebox/commands/commands_helper.rb', line 27

def self.vagrant_installed?
  (`which vagrant`) == 'vagrant not found' ? false : true
end

.valid_step?(step) ⇒ Boolean

Check if the step argument is valid

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/bebox/commands/commands_helper.rb', line 32

def self.valid_step?(step)
  steps = %w{step-0 step-1 step-2 step-3}
  steps.include?(step)
end

Instance Method Details

#default_environmentObject

Obtain the default environment for a project



17
18
19
20
21
22
23
24
# File 'lib/bebox/commands/commands_helper.rb', line 17

def default_environment
  environments = Bebox::Environment.list(project_root)
  if environments.count > 0
    return environments.include?('vagrant') ? 'vagrant' : environments.first
  else
    return ''
  end
end

#get_environment(options) ⇒ Object

Obtain the environment from command parameters or menu



8
9
10
11
12
13
14
# File 'lib/bebox/commands/commands_helper.rb', line 8

def get_environment(options)
  environment = options[:environment]
  # Ask for environment of node if flag environment not set
  environment ||= choose_option(Environment.list(project_root), 'Choose an existing environment:')
  # Check environment existence
  Bebox::Environment.environment_exists?(project_root, environment) ? (return environment) : exit_now!(error("The '#{environment}' environment does not exist."))
end