class Pipely::Build::EnvironmentConfig

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

Constants

ENV_DEFAULTS

Continue supporting env-based defaults until pipely v1.0

Public Class Methods

load(filename, environment) click to toggle source
# File lib/pipely/build/environment_config.rb, line 28
def self.load(filename, environment)
  raw = YAML.load_file(filename)[environment.to_s]
  config = load_from_hash(raw)

  if defaults = ENV_DEFAULTS[environment.to_sym]
    defaults.merge(config)
  else
    config
  end
end
load_from_hash(attributes) click to toggle source
# File lib/pipely/build/environment_config.rb, line 39
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