Class: SecretConfig::Parser
- Inherits:
-
Object
- Object
- SecretConfig::Parser
- Defined in:
- lib/secret_config/parser.rb
Instance Attribute Summary collapse
-
#interpolator ⇒ Object
readonly
Returns the value of attribute interpolator.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#initialize(path, registry, interpolate: true) ⇒ Parser
constructor
A new instance of Parser.
-
#parse(key, value) ⇒ Object
Returns a flat path of keys and values from the provider without looking in the local path.
-
#render ⇒ Object
Returns a flat Hash of the rendered paths.
Constructor Details
#initialize(path, registry, interpolate: true) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 9 10 11 12 |
# File 'lib/secret_config/parser.rb', line 5 def initialize(path, registry, interpolate: true) @path = path @registry = registry @fetch_list = {} @import_list = {} @tree = {} @interpolator = interpolate ? SettingInterpolator.new : nil end |
Instance Attribute Details
#interpolator ⇒ Object (readonly)
Returns the value of attribute interpolator.
3 4 5 |
# File 'lib/secret_config/parser.rb', line 3 def interpolator @interpolator end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/secret_config/parser.rb', line 3 def path @path end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
3 4 5 |
# File 'lib/secret_config/parser.rb', line 3 def registry @registry end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
3 4 5 |
# File 'lib/secret_config/parser.rb', line 3 def tree @tree end |
Instance Method Details
#parse(key, value) ⇒ Object
Returns a flat path of keys and values from the provider without looking in the local path. Keys are returned with path names relative to the supplied path.
16 17 18 19 20 |
# File 'lib/secret_config/parser.rb', line 16 def parse(key, value) relative_key = relative_key?(key) ? key : key.sub("#{path}/", "") value = interpolator.parse(value) if interpolator && value.is_a?(String) && value.include?("${") tree[relative_key] = value end |
#render ⇒ Object
Returns a flat Hash of the rendered paths.
23 24 25 26 |
# File 'lib/secret_config/parser.rb', line 23 def render apply_imports if interpolator tree end |