Project

envdocs

0.0
No commit activity in last 3 years
No release in over 3 years
Envdocs allows you to find missing env keys, as well as create living documentation of the keys themselves.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 4.2, < 6.2
 Project Readme

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

  1. Create a sample_keys.yml file in your application's config 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.

  1. 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 }
)
  1. 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.