Loads .env
file.
Add this to your application's shard.yml
:
dependencies:
dotenv:
github: gdotdesign/cr-dotenv
Your .env
file:
# Comments can be included for context
#
MY_VARIABLE=my-value
# Empty Lines are also ignore
#
ANOTHER_VAR=awesome-value
In your application:
require "dotenv"
# Load deafult ".env" file
Dotenv.load
# Other file
Dotenv.load ".env-other"
# If you load env variable from file and
# you want to raise execption in case of
# missing dotenv file, to make this error
# immediately obvious then use the bang
# verion of the load method:
Dotenv.load!
# or
Dotenv.load! ".env-other"
# Loading multiple files in order,
# and sets the last loaded value for a varibale
Dotenv.load! %w(.env .env.test)
# From IO
Dotenv.load MemoryIO.new("VAR=test")
# From Hash
Dotenv.load({"VAR" => "test"})
# A Hash is returned with the loaded variables
hash = Dotenv.load
puts hash["MY_VARIABLE"] # my-value
puts ENV["MY_VARIABLE"] # my-value
- Fork it ( https://github.com/gdotdesign/cr-dotenv/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- [gdotdesign] Gusztáv Szikszai - creator, maintainer
- [bonyiii]
- [kriskova]
- [neovintage] Rimas Silkaitis
- [rodrigopinto] Rodrigo Pinto