Module: Bebox::CommandsHelper
- Includes:
- WizardsHelper
- Included in:
- ProjectCommands
- Defined in:
- lib/bebox/commands/commands_helper.rb
Class Method Summary collapse
-
.vagrant_installed? ⇒ Boolean
Check if vagrant is installed on the machine.
-
.valid_step?(step) ⇒ Boolean
Check if the step argument is valid.
Instance Method Summary collapse
-
#default_environment ⇒ Object
Obtain the default environment for a project.
-
#get_environment(options) ⇒ Object
Obtain the environment from command parameters or menu.
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
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
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_environment ⇒ Object
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() environment = [: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 |