Method: Dockit::Config#initialize

Defined in:
lib/dockit/config.rb

#initialize(file, locals = {}) ⇒ Config

Instantiate and parse the file.

file [String]

dockit yaml file

locals [Hash]

local variables to bind in the ERB context



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dockit/config.rb', line 17

def initialize(file, locals={})
  root = Dockit::Env.new.root
  Dotenv.load(File.join(root, ENVFILE))
  locals['root'] ||= root

  begin
    @config = YAML::load(ERB.new(File.read(file)).result(bindings(locals)))
  rescue NameError => e
    error(e)
  rescue ArgumentError => e
    error(e)
  end
end