Module: Envy
- Includes:
- Deploy, Dotenv
- Defined in:
- lib/envy.rb,
lib/envy/version.rb
Overview
Module for loading environment variables and failing programs when variables are not set.
Constant Summary collapse
- EnvMissing =
Class.new(StandardError)
- VERSION =
'1.1.0'
Constants included from Deploy
Deploy::MissingHerokuToken, Deploy::TokenName
Class Method Summary collapse
- .deploy_heroku(app_name) ⇒ Object
-
.env_name?(data) ⇒ Boolean
Entity check for EnvName parameter.
-
.load_env(env_name) ⇒ String?
Returns the value of the specified environment variable or raises an EnvMissing exception.
-
.load_env_error_message(env_name) ⇒ String
Exception message for EnvMissing in #load_env.
-
.test_envs ⇒ Object
Creates environment variables for ‘.env’ and overwrites them with variables present in ‘.env.test`.
Methods included from Deploy
#config_vars, #deploy_heroku, #heroku_client, heroku_token
Class Method Details
.deploy_heroku(app_name) ⇒ Object
48 49 50 |
# File 'lib/envy.rb', line 48 def self.deploy_heroku(app_name) Deploy.deploy_heroku(app_name) end |
.env_name?(data) ⇒ Boolean
Entity check for EnvName parameter
33 34 35 36 |
# File 'lib/envy.rb', line 33 def self.env_name?(data) data.is_a?(String) && (data == data.upcase) end |
.load_env(env_name) ⇒ String?
Returns the value of the specified environment variable or raises an EnvMissing exception
24 25 26 27 28 |
# File 'lib/envy.rb', line 24 def self.load_env(env_name) if env_name?(env_name) ENV.fetch(env_name){|name| raise EnvMissing, (name)} end end |
.load_env_error_message(env_name) ⇒ String
Exception message for EnvMissing in #load_env
42 43 44 45 46 |
# File 'lib/envy.rb', line 42 def self.(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 ⇒ Object
Creates environment variables for ‘.env’ and overwrites them with variables present in ‘.env.test`
13 14 15 |
# File 'lib/envy.rb', line 13 def self.test_envs Dotenv.overload('.env.test') end |