Module: CapistranoMulticonfigParallel::ParseHelper
- Included in:
- ApplicationHelper, Configuration
- Defined in:
- lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb
Overview
module used for parsing numbers, strings , arrays and hashes
Class Method Summary collapse
- .check_hash_set(hash, props) ⇒ Object
- .check_numeric(num) ⇒ Object
- .strip_characters_from_string(value) ⇒ Object
- .value_is_array?(value) ⇒ Boolean
- .verify_array_of_strings(value) ⇒ Object
- .verify_empty_options(options) ⇒ Object
- .warn_array_without_strings(value) ⇒ Object
Class Method Details
.check_hash_set(hash, props) ⇒ Object
29 30 31 |
# File 'lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb', line 29 def check_hash_set(hash, props) !Set.new(props).subset?(hash.keys.to_set) || hash.values.find(&:blank?).present? end |
.check_numeric(num) ⇒ Object
6 7 8 |
# File 'lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb', line 6 def check_numeric(num) /^[0-9]+/.match(num.to_s) end |
.strip_characters_from_string(value) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb', line 37 def strip_characters_from_string(value) return '' if value.blank? value = value.delete("\r\n").delete("\n") value = value.gsub(/\s+/, ' ').strip value end |
.value_is_array?(value) ⇒ Boolean
33 34 35 |
# File 'lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb', line 33 def value_is_array?(value) value.present? && value.is_a?(Array) end |
.verify_array_of_strings(value) ⇒ Object
20 21 22 23 |
# File 'lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb', line 20 def verify_array_of_strings(value) value = (value) value.find { |row| !row.is_a?(String) }.present? ? warn_array_without_strings(value) : true end |
.verify_empty_options(options) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb', line 10 def () if .is_a?(Hash) .reject { |_key, value| value.blank? } elsif .is_a?(Array) .reject(&:blank?) else end end |
.warn_array_without_strings(value) ⇒ Object
25 26 27 |
# File 'lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb', line 25 def warn_array_without_strings(value) raise ArgumentError, "the array #{value} must contain only task names" end |