Class: Pipely::Build::EnvironmentConfig

Inherits:
Hash
  • Object
show all
Defined in:
lib/pipely/build/environment_config.rb

Overview

Work with YAML config files that contain parallel configs for various environments.

Class Method Summary collapse

Class Method Details

.load(filename, environment) ⇒ Object



11
12
13
14
# File 'lib/pipely/build/environment_config.rb', line 11

def self.load(filename, environment)
  raw = YAML.load_file(filename)[environment.to_s]
  load_from_hash(raw)
end

.load_from_hash(attributes) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pipely/build/environment_config.rb', line 16

def self.load_from_hash(attributes)
  config = new

  attributes.each do |k, v|
    case v
    when Hash
      config[k.to_sym] = load_from_hash(v)
    else
      config[k.to_sym] = v.clone
    end
  end

  config
end