Giter Site home page Giter Site logo

envy's Introduction

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

envy's People

Contributors

petoem avatar thegreyfellow avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

thegreyfellow

envy's Issues

Add option to raise error, if .env file does not exist

Hi, love your work and the use of macros to make Envy. if there is only one thing that would make it perfect in my opinion is an optional load_with_exception! or something like that, that would raise an exception instead of just logging to the STDOUT.

that would make scripts where it's used to stop executing or even compiling if .env file does not exist. what are your thoughts on this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.