module CapistranoMulticonfigParallel::ParseHelper

module used for parsing numbers, strings , arrays and hashes

Public Instance Methods

check_hash_set(hash, props) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb, line 20
def verify_array_of_strings(value)
  value = verify_empty_options(value)
  value.find { |row| !row.is_a?(String) }.present? ? warn_array_without_strings(value) : true
end
verify_empty_options(options) click to toggle source
# File lib/capistrano_multiconfig_parallel/helpers/parse_helper.rb, line 10
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) click to toggle source
# 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