class ConfigReader

Process the input as ERB and then YAML and return results as OpenStruct

Constants

VERSION

Attributes

environment[R]
file_path[R]

Public Class Methods

new(file_path, environment) click to toggle source
# File lib/config-reader.rb, line 10
def initialize(file_path, environment)
  @file_path = file_path
  @environment = environment.to_s
end

Public Instance Methods

config() click to toggle source
# File lib/config-reader.rb, line 15
def config
  @config ||= OpenStruct.new(yaml)
end

Private Instance Methods

erb() click to toggle source
# File lib/config-reader.rb, line 25
def erb
  ERB.new(input).result
end
input() click to toggle source
# File lib/config-reader.rb, line 29
def input
  IO.read(file_path)
end
yaml() click to toggle source
# File lib/config-reader.rb, line 21
def yaml
  YAML.load(erb)[environment]
end