Class: CapistranoMulticonfigParallel::InteractiveMenu
- Inherits:
-
Object
- Object
- CapistranoMulticonfigParallel::InteractiveMenu
- Includes:
- ApplicationHelper
- Defined in:
- lib/capistrano_multiconfig_parallel/classes/interactive_menu.rb
Overview
methods used for the interactive menu where are listed all aplications
Instance Method Summary collapse
- #confirm_option_selected ⇒ Object
- #handle_menu_option(msg, option, choices, applications) ⇒ Object
- #print_all_websites_available_options(applications, msg, choices) ⇒ Object
- #print_menu_choices(msg, choices, applications) ⇒ Object
- #show_all_websites_interactive_menu(applications) ⇒ Object
Methods included from ApplicationHelper
parse_task_string, strip_characters_from_string
Methods included from StagesHelper
check_stage_path, checks_paths, fetch_stages, fetch_stages_paths, sorted_paths, stages_paths
Methods included from CoreHelper
app_configuration, app_debug_enabled?, app_logger, ask_confirm, check_terminal_tty, debug_websocket?, execute_with_rescue, find_config_type, find_loaded_gem, find_worker_log, force_confirmation, format_error, log_error, log_to_file, rescue_error, rescue_interrupt, show_warning, websocket_config, websocket_server_config
Methods included from InternalHelper
config_file, custom_commands, default_internal_config, detect_root, enable_main_log_file, find_env_multi_cap_root, internal_config_directory, internal_config_file, log_directory, main_log_file, root, try_detect_capfile
Instance Method Details
#confirm_option_selected ⇒ Object
24 25 26 27 |
# File 'lib/capistrano_multiconfig_parallel/classes/interactive_menu.rb', line 24 def confirm_option_selected print 'Enter a comma-separated list of option numbers or one single option number (again to uncheck, ENTER when done): ' $stdin.gets.squeeze(' ').strip end |
#handle_menu_option(msg, option, choices, applications) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/capistrano_multiconfig_parallel/classes/interactive_menu.rb', line 49 def (msg, option, choices, applications) arr_in = option.split(',') arr_in.each_with_index do |number_option, _index| num = number_option.to_i if /^[0-9]+/.match(num.to_s) && ((num.to_i > 0 && num.to_i <= applications.size)) num -= 1 msg += "#{applications[num]} was #{choices[num].present? ? 'un' : ''}checked\n" choices[num] = choices[num].blank? ? '+' : ' ' else msg = "Invalid option: #{num}\n" next end end end |
#print_all_websites_available_options(applications, msg, choices) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/capistrano_multiconfig_parallel/classes/interactive_menu.rb', line 40 def (applications, msg, choices) puts 'Available options:' applications.each_with_index do |option, index| puts "#{(index + 1)} #{choices[index].present? ? "#{choices[index]}" : ''}) #{option} " end puts "\n#{msg}" if msg.present? true end |
#print_menu_choices(msg, choices, applications) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/capistrano_multiconfig_parallel/classes/interactive_menu.rb', line 29 def (msg, choices, applications) while (applications, msg, choices) && (option = confirm_option_selected).present? if /^[0-9,]+/.match(option) (msg, option, choices, applications) else msg = "Invalid option: #{option}\n " next end end end |
#show_all_websites_interactive_menu(applications) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/capistrano_multiconfig_parallel/classes/interactive_menu.rb', line 7 def (applications) msg = '' choices = [] (msg, choices, applications) print "\nYou selected" msg = ' nothing' result = '' applications.each_with_index do |option_name, index| next unless choices[index].present? print(" #{option_name}") msg = '' result += "#{option_name}," end print "#{msg}\n" strip_characters_from_string(result) end |