class Amigrind::Environments::Environment

Attributes

properties[R]

Public Class Methods

from_yaml(name, yaml_input) click to toggle source
# File lib/amigrind/environments/environment.rb, line 29
def self.from_yaml(name, yaml_input)
  yaml = YAML.load(yaml_input).deep_symbolize_keys

  yaml[:amigrind] ||= {}
  yaml[:aws] ||= {}
  yaml[:properties] ||= {}

  env = Environment.new
  env.name = name.to_s.strip.downcase

  env.aws = AWSConfig.new(yaml[:aws])

  env.properties.merge!(yaml[:properties])

  env.channels = (yaml[:amigrind][:channels] || []).map do |k, v|
    [ k.to_s, Channel.new(v.merge(name: k)) ]
  end.to_h

  # TODO: use these for validations
  valid_mappings = {
    'root' => env,
    'aws' => env.aws
  }

  env
end
load_yaml_file(path) click to toggle source
# File lib/amigrind/environments/environment.rb, line 56
def self.load_yaml_file(path)
  raise "'path' must be a String." unless path.is_a?(String)
  raise "'path' must be a file that exists." unless File.exist?(path)
  raise "'path' must end in .yml, .yaml, .yml.erb, or .yaml.erb." \
    unless path.end_with?('.yml', '.yaml', '.yml.erb', '.yaml.erb')

  Environment.from_yaml(File.basename(path, '.*'), Erubis::Eruby.new(File.read(path)).result)
end
new() click to toggle source
# File lib/amigrind/environments/environment.rb, line 23
def initialize
  @aws = AWSConfig.new
  @channels = []
  @properties = {}
end