Module: CapistranoMulticonfigParallel::ApplicationHelper
- Includes:
- CapistranoHelper, CoreHelper, GemHelper, InternalHelper, ParseHelper, StagesHelper
- Included in:
- Application, BaseActorHelper::ClassMethods, CLI, Cursor, DependencyTracker, InteractiveMenu, Job, JobCommand, RunnerStatus, WebServer
- Defined in:
- lib/capistrano_multiconfig_parallel/helpers/application_helper.rb
Overview
class that holds the options that are configurable for this gem
Constant Summary
collapse
- DEFAULT_TEXT_LENGTH =
22
Class Method Summary
collapse
env_key_format, env_prefix, filtered_env_keys_format, setup_flags_for_job, trace_flag
Methods included from GemHelper
fetch_gem_version, find_loaded_gem, find_loaded_gem_property, format_gem_version, get_parsed_version, verify_gem_version
app_names_from_stages, application_supports_multi_apps?, check_stage_path, checks_paths, configuration_has_valid_path?, fetch_apps_from_file, fetch_paths_from_file, fetch_stages_app, fetch_stages_paths, independent_deploy?, multi_apps?, sorted_paths, stages, stages_paths, stages_root
check_hash_set, check_numeric, strip_characters_from_string, value_is_array?, verify_array_of_strings, verify_empty_options, warn_array_without_strings
Methods included from CoreHelper
app_debug_enabled?, ask_confirm, ask_stdout_confirmation, check_terminal_tty, debug_websocket?, development_debug?, error_filtered?, execute_with_rescue, find_worker_log, force_confirmation, format_error, log_error, log_output_error, log_to_file, multi_fetch_argv, print_to_log_file, rescue_error, rescue_interrupt, setup_filename_logger, setup_logger_formatter, show_warning, terminal_actor, terminal_errors?, websocket_config, websocket_server_config
arg_is_in_default_config?, check_file, create_log_file, custom_commands, default_config_keys, default_internal_config, default_internal_configuration_params, detect_root, enable_main_log_file, fail_capfile_not_found, fetch_default_internal_config, find_config_type, find_env_multi_cap_root, find_file_by_names, find_file_in_directory, get_current_gem_name, internal_config_directory, internal_config_file, log_directory, main_log_file, multi_level_prop, pathname_is_root?, pwd_directory, pwd_parent_dir, root, setup_default_configuration_types, sliced_default_config, try_detect_file, try_detect_file_in_dir
Class Method Details
.action_confirmed?(result) ⇒ Boolean
103
104
105
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 103
def action_confirmed?(result)
result.present? && result.downcase == 'y'
end
|
.fetch_parsed_string(string) ⇒ Object
116
117
118
119
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 116
def fetch_parsed_string(string)
/^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s
[regex_last_match(1), regex_last_match(2)]
end
|
.fetch_remaining_arguments(args, remaining_args) ⇒ Object
121
122
123
124
125
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 121
def fetch_remaining_arguments(args, remaining_args)
/((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
args << regex_last_match(1).gsub(/\\(.)/, '\1')
regex_last_match(2)
end
|
.find_remaining_args(name, remaining_args) ⇒ Object
127
128
129
130
131
132
133
134
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 127
def find_remaining_args(name, remaining_args)
args = []
loop do
remaining_args = fetch_remaining_arguments(args, remaining_args)
break if remaining_args.blank?
end
[name, args]
end
|
.get_question_details(data) ⇒ Object
73
74
75
76
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 73
def get_question_details(data)
matches = /(.*)\?*\s*\:*\s*(\([^)]*\))*/m.match(data).captures
[matches[0], matches[1]]
end
|
.internal_wrap_string(string, options = {}) ⇒ Object
.message_from_bundler?(message) ⇒ Boolean
69
70
71
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 69
def message_from_bundler?(message)
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present? && message['action'] == 'bundle_install'
end
|
.message_is_about_a_task?(message) ⇒ Boolean
65
66
67
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 65
def message_is_about_a_task?(message)
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present? && message['action'] == 'invoke'
end
|
.message_is_for_stdout?(message) ⇒ Boolean
61
62
63
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 61
def message_is_for_stdout?(message)
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['action'] == 'stdout'
end
|
.msg_for_stdin?(message) ⇒ Boolean
57
58
59
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 57
def msg_for_stdin?(message)
message['action'] == 'stdin'
end
|
.parse_json(res) ⇒ Hash?
Method that is used to parse a string as JSON , if it fails will return nil
50
51
52
53
54
55
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 50
def parse_json(res)
return if res.blank?
JSON.parse(res)
rescue JSON::ParserError
nil
end
|
.parse_task_string(string) ⇒ Object
111
112
113
114
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 111
def parse_task_string(string) name, remaining_args = fetch_parsed_string(string)
name.present? ? find_remaining_args(name, remaining_args) : [string, []]
end
|
.percent_of(index, total) ⇒ Object
99
100
101
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 99
def percent_of(index, total)
index.to_f / total.to_f * 100.0
end
|
.regex_last_match(number) ⇒ Object
107
108
109
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 107
def regex_last_match(number)
Regexp.last_match(number)
end
|
.setup_command_line_standard(*args) ⇒ Object
78
79
80
81
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 78
def setup_command_line_standard(*args)
options = args.
[args.select(&:present?), options]
end
|
.truncate(string, truncate_at, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 32
def truncate(string, truncate_at, options = {})
return string.dup unless string.length > truncate_at
options[:omission] ||= '...'
length_with_room_for_omission = truncate_at - options[:omission].length
stop = if options[:separator]
string.rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission
else
length_with_room_for_omission
end
"#{string[0...stop]}#{options[:omission]}"
end
|
.wrap_coloured_string(string, options = {}) ⇒ Object
92
93
94
95
96
97
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 92
def wrap_coloured_string(string, options = {})
new_array = internal_wrap_string(string, options).collect do |str|
str.colorize(options["color"].to_s.to_sym)
end
new_array.join(options.fetch('character', $INPUT_RECORD_SEPARATOR))
end
|
.wrap_string(string, options = {}) ⇒ Object
88
89
90
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 88
def wrap_string(string, options = {})
internal_wrap_string(string, options).join(options.fetch('character', $INPUT_RECORD_SEPARATOR))
end
|