Class: D13n::Configuration::YamlSource

Inherits:
DottedHash
  • Object
show all
Defined in:
lib/d13n/configuration/yaml_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DottedHash

#inspect, symbolize, #to_hash

Constructor Details

#initialize(path, env) ⇒ YamlSource

Returns a new instance of YamlSource.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/d13n/configuration/yaml_source.rb', line 6

def initialize(path,env)
  config = {}
  @failures = []

  begin
    @file_path = validate_config_file(path)
    return unless @file_path

    D13n.logger.info("Reading configuration from #{path} (#{Dir.pwd})")
    raw_file = File.read(@file_path)
    erb_file = process_erb(raw_file)
    config   = process_yaml(erb_file, env, config, @file_path)
  rescue ScriptError, StandardError => e
    log_failure("Failed to read or parse configuration file at #{path}", e)
  end

  super(config, true)
end

Instance Attribute Details

#failuresObject

Returns the value of attribute failures.



4
5
6
# File 'lib/d13n/configuration/yaml_source.rb', line 4

def failures
  @failures
end

#file_pathObject

Returns the value of attribute file_path.



4
5
6
# File 'lib/d13n/configuration/yaml_source.rb', line 4

def file_path
  @file_path
end