class Rebi::EB

Attributes

client[R]

Public Class Methods

new(client=Aws::ElasticBeanstalk::Client.new) click to toggle source
# File lib/rebi/eb.rb, line 4
def initialize client=Aws::ElasticBeanstalk::Client.new
  @client = client
end

Public Instance Methods

applications() click to toggle source
# File lib/rebi/eb.rb, line 8
def applications
  client.describe_applications.applications.map(&:application_name)
end
get_solution_stack(platform, version) click to toggle source
# File lib/rebi/eb.rb, line 34
def get_solution_stack platform, version
  solution_stacks.find do |st|
    st["platform"] == platform && st["version"] == version
  end["solution_stack"]
end
method_missing(m, *args, &block) click to toggle source
# File lib/rebi/eb.rb, line 40
def method_missing(m, *args, &block)
  client.send(m, *args, &block)
end
platforms() click to toggle source
# File lib/rebi/eb.rb, line 18
def platforms
  @platforms ||= solution_stacks.map do |st|
    st["platform"]
  end.uniq
end
solution_stacks() click to toggle source
# File lib/rebi/eb.rb, line 12
def solution_stacks
  @solution_stacks = client.list_available_solution_stacks.solution_stacks.map do |s|
    stacks_from_string s
  end
end
versions_by_platform(platform) click to toggle source
# File lib/rebi/eb.rb, line 24
def versions_by_platform platform
  raise "Invalid platform" unless platforms.include?(platform)

  solution_stacks.select do |st|
    st["platform"] == platform
  end.map do |st|
    st["version"]
  end.uniq
end

Private Instance Methods

stacks_from_string(s) click to toggle source
# File lib/rebi/eb.rb, line 46
def stacks_from_string s
  res = {}.with_indifferent_access
  res[:platform] = s.match('.+running\s([^0-9]+).*')&.captures&.first.try(:strip)
  res[:version] = s.match('.+running\s(.*)')&.captures&.first.try(:strip)
  res[:server] = s.match('(.*)\srunning\s.*')&.captures&.first.try(:strip)
  res[:stack_version] = s.match('.+v([0-9.]+)\srunning\s.*')&.captures&.first.try(:strip)
  res[:solution_stack] = s
  res
end