Module: Secrets::Helpers

Defined in:
lib/secrets_parser/helpers.rb

Class Method Summary collapse

Class Method Details

.expand_param_from_env(value) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/secrets_parser/helpers.rb', line 3

def self.expand_param_from_env(value)
  dollar_match_expression = /\$([A-Za-z0-9_]*)/
  value.scan(dollar_match_expression).each do |match|
    break unless ENV.include? match[0]
    value = value.gsub("$#{match[0]}", ENV[match[0]])
  end
  value
end