module Savvy::Utility

Public Instance Methods

valid_env_var?(var) click to toggle source

Validate that the provided var is a string that can be used as a name for environment variables.

@param [String] var

# File lib/savvy/utility.rb, line 22
def valid_env_var?(var)
  var.kind_of?(String) && Dux.presentish?(var)
end
valid_env_vars?(vars) click to toggle source

Validate that the provided value is a one-dimensional array of strings that may or may not exist in ‘ENV`.

@param [<String>] vars

# File lib/savvy/utility.rb, line 9
def valid_env_vars?(vars)
  return false unless vars.kind_of?(Array)

  vars.all? do |var|
    valid_env_var? var
  end
end
valid_url?(url, scheme: nil) click to toggle source
# File lib/savvy/utility.rb, line 26
def valid_url?(url, scheme: nil)
  return false unless url.kind_of?(String) && Dux.presentish?(url)

  if scheme
    return false unless url.start_with?("#{scheme}://")
  end

  return true
end