class Project
Attributes
config[RW]
project_path[RW]
Public Class Methods
new(project_path)
click to toggle source
# File lib/project.rb, line 5 def initialize(project_path) @config = YAML.load_file("#{project_path}/config/config.yaml") @project_path = project_path end
Public Instance Methods
account_env_map()
click to toggle source
# File lib/project.rb, line 22 def account_env_map hash = {} config['environments'].each do |env, properties| if hash[properties['account']].nil? hash[properties['account']] = [] hash[properties['account']] << env else hash[properties['account']] << env end end hash end
env_region_map()
click to toggle source
# File lib/project.rb, line 35 def env_region_map hash = {} config['environments'].each do |env, properties| if hash[env].nil? hash[env] = properties['region'] else raise("An environment cannot map to more than one region ENV: #{env} Region: #{properties['region']}") end end hash end
environments()
click to toggle source
# File lib/project.rb, line 10 def environments config['environments'] end
get_lambdas()
click to toggle source
# File lib/project.rb, line 14 def get_lambdas lambdas = {} environments.keys.each do |env| lambdas[env] = YAML.load_file("#{project_path}/environments/#{env}.yaml") if File.exist?("#{project_path}/environments/#{env}.yaml") end lambdas end
update_by_artifact(lambda_env_map, artifact, version, sha1=nil)
click to toggle source
# File lib/project.rb, line 55 def update_by_artifact(lambda_env_map, artifact, version, sha1=nil) #iterate through all lambdas and update the ones with version changes lambda_env_map.each do |env, lambda| pp env pp lambda lambda.each do |lambda_name, properties| if properties['artifact_name'] == artifact properties['version'] = version properties['sha1'] = sha1 unless sha1.nil? end end end lambda_env_map end
write_new_files(lambda_env_map)
click to toggle source
# File lib/project.rb, line 49 def write_new_files(lambda_env_map) lambda_env_map.each do |env, contents| File.write("#{project_path}/environments/#{env}.yaml", contents.to_yaml) end end