Class: SecretsManager::Config
- Inherits:
-
Object
- Object
- SecretsManager::Config
- Defined in:
- lib/secrets_manager/config.rb
Defined Under Namespace
Classes: SecretConfig
Instance Attribute Summary collapse
-
#secrets ⇒ Object
readonly
Returns the value of attribute secrets.
Instance Method Summary collapse
- #config_string ⇒ Object
- #init ⇒ Object
-
#initialize(config_path, environment) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(config_path, environment) ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 |
# File 'lib/secrets_manager/config.rb', line 7 def initialize(config_path, environment) @config_path = config_path @environment = environment @secrets = [] end |
Instance Attribute Details
#secrets ⇒ Object (readonly)
Returns the value of attribute secrets.
5 6 7 |
# File 'lib/secrets_manager/config.rb', line 5 def secrets @secrets end |
Instance Method Details
#config_string ⇒ Object
24 25 26 |
# File 'lib/secrets_manager/config.rb', line 24 def config_string File.read(@config_path).gsub('$environment', @environment) end |
#init ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/secrets_manager/config.rb', line 13 def init return unless File.file?(@config_path) configuration = JSON.parse(config_string, symbolize_names: true) configuration.each do |k, v| @secrets << SecretConfig.new(k, v[:id], v[:input], v[:type], v[:path]) end self end |