Project

env_json

0.0
Low commit activity in last 3 years
No release in over a year
Load ENV variables from a JSON file. Usefull with ejson https://github.com/Shopify/ejson
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

EnvJson

Build Status

Load ENV variables from a JSON file. (somehow similar to dotenv)

Intended to be used with ejson

Installation

Add this line to your application's Gemfile:

gem 'env_json'

And then execute:

$ bundle

Or install it yourself as:

$ gem install env_json

Usage

If you're using Rails create a config/env.json like this template

{
    "DATABASE_URL": "mysql://@localhost/development_db",
    "test" : {
        "DATABASE_URL": "mysql://login:password@mysql.com/test_db"
    }
}

But really have a look at ejson and ejson-capistrano

About the JSON format:

  • keys prefixed with _ will be ignored
  • keys development, test, staging, production will be ignored if they don't match with current environment

ElasticBeanstalk

export env variables defined in config/env.json to Amazon ElasticBeanstalk environment

RAILS_ENV=production bundle exec rake env_json:eb

You should pass RAILS_ENV. EnvJson can't figure out which environment you're targeting alone.

You can pass ENVIRONMENT_NAME to give AWS ElasticBeanstalk environment name

RAILS_ENV=production ENVIRONMENT_NAME=my-staging-env bundle exec rake env_json:eb

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hellvinz/env_json. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.