Class: Persey::Adapters::Yaml

Inherits:
Base
  • Object
show all
Defined in:
lib/persey/adapters/yaml.rb

Class Method Summary collapse

Methods inherited from Base

symbolize_keys

Class Method Details

.load(file, env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/persey/adapters/yaml.rb', line 10

def load(file, env)
  begin
    raw_hash = YAML.load(ERB.new(File.read(file)).result)
    symbolize_keys(raw_hash)
  rescue KeyError => e
    _, line, method = /\(erb\):(\d+):in `(.*)'/.match(e.backtrace[0]).to_a
    if method == 'fetch'
      raise MissingEnvVariable.new("Check line ##{line} in #{file}")
    else
      raise e
    end
  end
end