Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

envoker

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envoker

  • 2.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Envoker

Load environment variables from .env files.

Installation

Add this line to your application's Gemfile:

gem "envoker"

And then execute:

$ bundle

Or install it yourself as:

$ gem install envoker

Usage

Load your .env file in the application bootstrap process:

# .env
RACK_ENV=development

# boot.rb
require "envoker"

Envoker.load

ENV["RACK_ENV"]
# => "development"

You can use Envoker#overload to override existing values in ENV:

# .env.test
RACK_ENV=test

# boot.rb
# ...

Envoker.overload(".env.test")

ENV["RACK_ENV"]
# => "test"

Multiple Environments

Envoker::Rack adds support for multiple environments:

require "envoker/rack"

Envoker::Rack.load

You should store env vars that are general to all environments in .env, and store specific env vars in .env.<environment>.The default environment is development, but can be changed through ENV["RACK_ENV"].

ENV["RACK_ENV"] = "test"

# This will load `.env` and `.env.test`
Envoker::Rack.load

Settings

This is a common pattern I use in my applications:

require "envoker/rack"

Envoker::Rack.load

module Settings
  def self.fetch(key)
    return ENV.fetch(key) do
      raise(sprintf("ENV[%p] not found", key))
    end
  end

  REDIS_URL = fetch("REDIS_URL")
  SMTP_URL  = fetch("SMTP_URL")
end

Settings::SMTP_URL
# => redis://localhost:6379

Contributing

Fork the project with:

$ git clone https://github.com/frodsan/envoker.git

To install dependencies, use:

$ bundle install

To run the test suite, do:

$ rake test

For bug reports and pull requests use GitHub.

License

Envoker is released under the MIT License.

FAQs

Package last updated on 16 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc