Module: CapistranoMulticonfigParallel::ApplicationHelper
- Includes:
- CoreHelper, InternalHelper
- Included in:
- Application, CLI, CelluloidManager, CelluloidWorker, ChildProcess, Cursor, DependencyTracker, InteractiveMenu, Job, JobCommand, RakeWorker, TerminalTable, WebServer
- Defined in:
- lib/capistrano_multiconfig_parallel/helpers/application_helper.rb
Overview
class that holds the options that are configurable for this gem
Class Method Summary
collapse
Methods included from CoreHelper
app_debug_enabled?, ask_confirm, ask_stdout_confirmation, check_terminal_tty, debug_websocket?, error_filtered?, execute_with_rescue, find_worker_log, force_confirmation, format_error, log_error, log_output_error, log_to_file, print_to_log_file, rescue_error, rescue_interrupt, setup_filename_logger, setup_logger_formatter, show_warning, terminal_actor, websocket_config, websocket_server_config
check_file, config_file, create_log_file, custom_commands, 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_in_directory, 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_capfile
Class Method Details
.action_confirmed?(result) ⇒ Boolean
59
60
61
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 59
def action_confirmed?(result)
result.present? && result.downcase == 'y'
end
|
.check_hash_set(hash, props) ⇒ Object
86
87
88
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 86
def check_hash_set(hash, props)
!Set.new(props).subset?(hash.keys.to_set) || hash.values.find(&:blank?).present?
end
|
.check_numeric(num) ⇒ Object
63
64
65
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 63
def check_numeric(num)
/^[0-9]+/.match(num.to_s)
end
|
.fetch_parsed_string(string) ⇒ Object
110
111
112
113
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 110
def fetch_parsed_string(string)
/^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s
[regex_last_match(1), regex_last_match(2)]
end
|
.fetch_remaining_arguments(args, remaining_args) ⇒ Object
115
116
117
118
119
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 115
def fetch_remaining_arguments(args, remaining_args)
/((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
args << regex_last_match(1).gsub(/\\(.)/, '\1')
regex_last_match(2)
end
|
.find_loaded_gem(name) ⇒ Object
41
42
43
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 41
def find_loaded_gem(name)
Gem.loaded_specs.values.find { |repo| repo.name == name }
end
|
.find_remaining_args(name, remaining_args) ⇒ Object
121
122
123
124
125
126
127
128
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 121
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
25
26
27
28
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 25
def get_question_details(data)
/(.*)\?*\s*\:*\s*(\([^)]*\))*/m =~ data
[regex_last_match(1), regex_last_match(2)]
end
|
.msg_for_stdin?(message) ⇒ Boolean
17
18
19
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 17
def msg_for_stdin?(message)
message['action'] == 'stdin'
end
|
.msg_for_task?(message) ⇒ Boolean
21
22
23
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 21
def msg_for_task?(message)
message['task'].present?
end
|
.multi_fetch_argv(args) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 49
def multi_fetch_argv(args)
options = {}
args.each do |arg|
if arg =~ /^(\w+)=(.*)$/m
options[Regexp.last_match(1)] = Regexp.last_match(2)
end
end
options
end
|
.parse_task_string(string) ⇒ Object
105
106
107
108
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 105
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
45
46
47
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 45
def percent_of(index, total)
index.to_f / total.to_f * 100.0
end
|
.regex_last_match(number) ⇒ Object
101
102
103
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 101
def regex_last_match(number)
Regexp.last_match(number)
end
|
.setup_command_line_standard(*args) ⇒ Object
30
31
32
33
34
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 30
def setup_command_line_standard(*args)
options = args.
args.select(&:present?)
[args, options]
end
|
.strip_characters_from_string(value) ⇒ Object
94
95
96
97
98
99
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 94
def strip_characters_from_string(value)
return unless value.present?
value = value.delete("\r\n").delete("\n")
value = value.gsub(/\s+/, ' ').strip
value
end
|
.value_is_array?(value) ⇒ Boolean
90
91
92
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 90
def value_is_array?(value)
value.present? && value.is_a?(Array)
end
|
.verify_array_of_strings(value) ⇒ Object
77
78
79
80
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 77
def verify_array_of_strings(value)
value.reject(&:blank?)
warn_array_without_strings(value)
end
|
.verify_empty_options(options) ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 67
def verify_empty_options(options)
if options.is_a?(Hash)
options.reject { |_key, value| value.blank? }
elsif options.is_a?(Array)
options.reject(&:blank?)
else
options
end
end
|
.warn_array_without_strings(value) ⇒ Object
82
83
84
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 82
def warn_array_without_strings(value)
raise ArgumentError, 'the array must contain only task names' if value.find { |row| !row.is_a?(String) }
end
|
.wrap_string(string, options = {}) ⇒ Object
36
37
38
39
|
# File 'lib/capistrano_multiconfig_parallel/helpers/application_helper.rb', line 36
def wrap_string(string, options = {})
options.stringify_keys!
string.scan(/.{#{options.fetch('length', 80)}}|.+/).map(&:strip).join(options.fetch('character', $INPUT_RECORD_SEPARATOR))
end
|