Skip to content

Fork of the Environment Gem on

Notifications You must be signed in to change notification settings

bandlab/environment

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Environment

Depending on how you start a Ruby process, it may not pick up all of the Bash Env Vars. To rectify this, This gem employs two mechanisms. First if tries to load some code from a .env file in the process root dir. Then it fires up a full login shell and sucks out all of the vars.

The final authority is the login shell variables. They will override any conflicts stemming from .env files.

This Gem also purges standard ENV of any Env Vars that start with SEC_ This was added to prevent some debugging tools from leaking secure env vars.

Some code was borrowed from teh dotenv gem project.

Installation

# gem install environment

Usage

The global constant ENV is mostly left untouched by default. The global ENV will be purged of anything matching ^SEC_. To read an environment variable, use Environment.get or Environment[].

Example usage:

require "rubygems"
require "environment"

# the following two are the same
path = Environment['PATH']
home = Environment.get('HOME')

Environment.to_a

If you want to override the default ENV constant, use the override! method ##Warning, this can be full of suprises with some ruby products

Example usage:

require "rubygems"
require "environment"

host = ENV['HOSTNAME'] #nil
Environment.override!
host = ENV['HOSTNAME'] #yourdomain.com

About

Fork of the Environment Gem on

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%