module Envdocs

Constants

VERSION

Attributes

environment[R]
filename[R]
opts[R]

Public Class Methods

configure(filename:, environment:, opts: {}) click to toggle source

@param [String] filename @param [String] environment @param [Hash] opts

=> [Booleam] include_optional
# File lib/envdocs.rb, line 11
def configure(filename:, environment:, opts: {})
  @configured = true
  @environment = environment
  @filename = filename
  @opts = opts
  @sampler = Sampler.new(filename, environment)
end
find_missing_keys() click to toggle source

Returns an array of keys that were not found in the current ENV @return [Array]

# File lib/envdocs.rb, line 21
def find_missing_keys
  unless @configured
    raise StandardError, 'Envdocs environment must be configured before running this command'
  end

  # If optionals included, return all.
  # Otherwise, return only keys that are marked as required.
  result = {}
  keys_to_search = @sampler.env_keys.select { |ek| @opts[:include_optional] || ek['required'] }

  keys_to_search.each { |ek| result[ek['key']] = ENV.fetch(ek['key'], nil) }

  result.reject { |k,v| !v.nil? }.keys
end