class AwsRds::Profile

Public Class Methods

new(options) click to toggle source
# File lib/aws_rds/profile.rb, line 5
def initialize(options)
  @options = options
end

Public Instance Methods

check!() click to toggle source
# File lib/aws_rds/profile.rb, line 17
def check!
  return if File.exist?(profile_file)

  puts "Unable to find a #{profile_file.colorize(:green)} profile file."
  puts "Please double check that it exists or that you specified the right profile."
  exit # EXIT HERE
end
load() click to toggle source
# File lib/aws_rds/profile.rb, line 9
def load
  return @profile_params if @profile_params

  check!

  @profile_params = load_profile(profile_file)
end
load_profile(file) click to toggle source
# File lib/aws_rds/profile.rb, line 25
def load_profile(file)
  return {} unless File.exist?(file)

  puts "Using profile: #{file}"
  data = YAML.load(erb_result(file))
  data ? data : {} # in case the file is empty
  data.has_key?("create_db_instance") ? data["create_db_instance"] : data
end
profile_file() click to toggle source
# File lib/aws_rds/profile.rb, line 34
def profile_file
  "#{AwsRds.root}/profiles/#{profile_name}.yml"
end
profile_name() click to toggle source
# File lib/aws_rds/profile.rb, line 38
def profile_name
  # allow user to specify the path also
  if @options[:profile] && File.exist?(@options[:profile])
    profile = File.basename(@options[:profile], '.yml')
  end

  # conventional profile is the name of the ec2 instance
  profile || @options[:profile] || "default"
end