module Envy

Module for loading environment variables and failing programs when variables are not set.

Constants

EnvMissing
VERSION

Public Class Methods

deploy_heroku(app_name) click to toggle source
# File lib/envy.rb, line 48
def self.deploy_heroku(app_name)
  Deploy.deploy_heroku(app_name)
end
env_name?(data) click to toggle source

Entity check for EnvName parameter @param data [Object] object under test @return [Boolean] true if data is a valid EnvName, false otherwise

# File lib/envy.rb, line 33
def self.env_name?(data)
  data.is_a?(String) &&
    (data == data.upcase)
end
load_env(env_name) click to toggle source

Returns the value of the specified environment variable or raises an EnvMissing exception @param env_name [String] name of the environment variable, which should match an

entry in .env* files

@raise [EnvMissing] when the environment variable does not exist @return [String, nil] value of envrionment variable when env_name is a valid

name and nil otherwise
# File lib/envy.rb, line 24
def self.load_env(env_name)
  if env_name?(env_name)
    ENV.fetch(env_name){|name| raise EnvMissing, load_env_error_message(name)}
  end
end
load_env_error_message(env_name) click to toggle source

Exception message for EnvMissing in load_env @param env_name [String] name of the environment variable, which should match an

entry in .env* files

@return [String] error message

# File lib/envy.rb, line 42
def self.load_env_error_message(env_name)
  "#{env_name} is missing from the environment. "\
  "Please ensure that the entry #{env_name}=value-of-var is present in " \
  "your .env or .env.* file."
end
test_envs() click to toggle source

Creates environment variables for `.env' and overwrites them with variables present in `.env.test`

# File lib/envy.rb, line 13
def self.test_envs
  Dotenv.overload('.env.test')
end