Module: Envdocs
- Defined in:
- lib/envdocs.rb,
lib/envdocs/railtie.rb,
lib/envdocs/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.1.0'
Class Attribute Summary collapse
-
.environment ⇒ Object
readonly
Returns the value of attribute environment.
-
.filename ⇒ Object
readonly
Returns the value of attribute filename.
-
.opts ⇒ Object
readonly
Returns the value of attribute opts.
Class Method Summary collapse
- .configure(filename:, environment:, opts: {}) ⇒ Object
-
.find_missing_keys ⇒ Array[String]
Returns an array of keys that were not found in the current ENV.
Class Attribute Details
.environment ⇒ Object (readonly)
Returns the value of attribute environment.
5 6 7 |
# File 'lib/envdocs.rb', line 5 def environment @environment end |
.filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/envdocs.rb', line 5 def filename @filename end |
.opts ⇒ Object (readonly)
Returns the value of attribute opts.
5 6 7 |
# File 'lib/envdocs.rb', line 5 def opts @opts end |
Class Method Details
.configure(filename:, environment:, opts: {}) ⇒ Object
11 12 13 14 15 16 17 |
# 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 ⇒ Array[String]
Returns an array of keys that were not found in the current ENV
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |