Manage environment variables within your Ruby project
Add this line to your application's Gemfile:
gem 'envm', github: "teespring/envm"
And then execute:
$ bundle
Or install it yourself as:
$ gem install envm
require 'envm'
# Configure the environment variable manifest file
# Supported formats: YML
Envm::Config.manifest_path = File.join(Rails.root, "config", "env.yml")
# you'll have to manually call setup
Envm.setup
# Access allowed environment varables
Envm["DATABASE_URL"]
#=> "mysql2://root@localhost:3306/teespring_dev"
# Access disallowed environment varables
Envm["DATABASE_URLX"]
#=> fail Envm::EnvVarNotFoundError, "DATABASE_URLX was not found"
# Access environment varables using Ruby's ENV
ENV["DATABASE_URL"]
# => STDERR.puts "Warning: deprecated usage of ENV with value 'DATABASE_URL'"
The gem is available as open source under the terms of the MIT License.