Module: EnvLoader
- Defined in:
- lib/env_loader.rb,
lib/env_loader/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.get(key) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/env_loader.rb', line 18 def self.get(key) if value = ENV[key.to_s.upcase] if value.match(/^\{.*\}$/) JSON.parse(value).with_indifferent_access else value end end end |
.read(env_yml_file = File.join('config', 'env_variables.yml')) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/env_loader.rb', line 6 def self.read(env_yml_file = File.join('config', 'env_variables.yml')) if File.exists? env_yml_file if hash = YAML.load_file(env_yml_file) hash.each do |key, value| if value ENV[key.upcase] = format_value(value) end end end end end |