envy v0.2.0

Envy loads environment variables from a .env files

envy

Envy is a shard that loads environment variables from a .env files into ENV.

Travis GitHub license

Installation

Add this to your application's shard.yml:

dependencies:
  envy:
    github: petoem/envy

Usage

# As early as possible in your application, require and load a `.env` file
require "envy"

# Load environment variables from `.env` file in the current working directory
Envy.load

# This will load environment variables and overwrite existing ones
Envy.load!

# You can specify multiple files and they will be loaded in order.
Envy.load ".env.development", ".env.redis"

# To parse a `.env` file, returns `Hash(String, String)`. Raises if the file does not exist.
Envy.parse ".env"

# To raise an exception if the .env file does not exist, you can append a block to Envy#load or Envy#load!.
Envy.load! do
  { raise_exception: true }
end

.env files

# Comments and empty lines are ignored

# Basic environment variable
NAME=value

# You can add export in front of each line so you can source the file
export NAME=value

# Spaces inside values are kept
SPACES=are kept

# Double quotes are removed from beginning and end but kept in the inside
# e.g. QUOTES => here are \"\" inside
QUOTES="here are "" inside"

# Equal signs are allowd inside values
EQUAL_SIGNS=are=allowed=

# Variable names are automatically upcased
# e.g. NaMe => NAME
NaMe=value

# Empty value become empty string
EMPTY=

Contributing

  1. Fork it ( https://github.com/petoem/envy/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • petoem Michael Petö - creator, maintainer
Repository

envy

Owner
Statistic
  • 2
  • 1
  • 0
  • 1
  • 0
  • almost 7 years ago
  • November 6, 2017
License

MIT License

Links
Synced at

Mon, 23 Dec 2024 03:55:55 GMT

Languages