Envdocs
Simple and Lightweight Gem to handle Environment(ENV) variable sanity-checks and documentation. Providing teams with the ability to sanity-check their expected loaded ENV variables at any point.
Every team documents, stores and persists ENV variables differently. One of the most draining experiences for a team is forgetting to update an ENV key for an environment, pushing things through, and trying to understand why things aren't working. This gem aims to fix that.
Installation
Add this line to your application's Gemfile:
gem 'envdocs'
And then execute:
$ bundle
Or install it yourself as:
$ gem install envdocs
Usage
- Create a
sample_keys.yml
file in your application'sconfig
directory: Example:
- development:
- key: RAILS_ENV
description: Provides info on the rails env
required: true
- key: FOO
description: Testing
required: false
- test:
- key: RAILS_ENV
description: Provides info on the rails env
required: true
The top-level key denotes the environment name we'd like to check against(ie. development, test, etc...). The nested objects each represent a key we'd like to validate for that environment.
- Initialize the gem by pointing it to your
sample_keys.yml
file in your application's./config
folder.
# initializers/envdocs.rb
Envdocs.configure(
filename: 'sample_keys.yml',
environment: Rails.env,
opts: { include_optional: false }
)
- Anywhere in your code that you'd like to validate the proper keys exist, call:
Envdocs.find_missing_keys
When called, an array of strings will be returned containing any missing keys. If no keys are missing, an empty array will be returned.
Contributing
Features, bug fixes and other changes to envdocs-ruby are gladly accepted. Please open issues or a pull request with your change.
License
The gem is available as open source under the terms of the LGPLv3 License.