gen-env

More than often, a typical java project requires you to manage multiple properties or env files across different environments. For example, local.env, sit.env, qa.env etc etc. And there are multiple problems managing these sort of environment files.

Problems with multiple .properties/.env files

  1. No better mechanism of logically grouping multiple key/value pairs in .properties/.env file, other than developer's discipline. For example, order of individual configurations for database, load-balancer etc. can vary a lot from one environment's configuration file to other's.
  2. It becomes difficult and cumbersome to find a single key/value pair in all .properties/.env file and change it without juggling with your favorite editor's find and replace feature.
  3. No way of testing if a particular key/value pair is available in the corresponding .properties/.env file other than manually doing grep on the file. This can cause lots of surprises when you actually deploy an app in environment.

Solutions to above problems

  1. A simple DSL that can logically group different configurations and produce the final .properties/.env file having same order of key/value pair for different configurations across multiple environments.
  2. Rather than managing .properties/.env files in plain text files, an ability to write your configurations in ruby language allows you to unit test your configuration files for presence or absense of particular key/value pair.

Installation

Add this line to your application's Gemfile:

gem 'gen-env'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gen-env

Usage

Development

After checking out the repo, run bundle install --path vendor/bundle to install dependencies. Then, run bundle exec rake spec to run the tests.

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/davcdhanesh1/gen-env. 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.

License

The gem is available as open source under the terms of the MIT License.