module Spurious::Ruby::Awssdk::Helper

Constants

VERSION

Public Class Methods

config(type) click to toggle source
# File lib/spurious/ruby/awssdk/helper.rb, line 42
def self.config(type)
  case type
  when :cli
    port_config
  when :docker
    docker_config
  end
end
configure(type = :cli, strategy = nil) click to toggle source
# File lib/spurious/ruby/awssdk/helper.rb, line 51
def self.configure(type = :cli, strategy = nil)
  strategy ||= Spurious::Ruby::Awssdk::Strategy.new(true)
  strategy.apply(config(type))
end
docker_config() click to toggle source
# File lib/spurious/ruby/awssdk/helper.rb, line 19
def self.docker_config
  {
    "spurious-dynamo" => [
      {
        "Host"     => ENV['DYNAMODB.SPURIOUS.LOCALHOST_NAME'].split('/').last,
        "HostPort" => URI(ENV['DYNAMODB.SPURIOUS.LOCALHOST_PORT']).port
      }
    ],
    "spurious-sqs" => [
      {
        "Host"     => ENV['SQS.SPURIOUS.LOCALHOST_NAME'].split('/').last,
        "HostPort" => URI(ENV['SQS.SPURIOUS.LOCALHOST_PORT']).port
      }
    ],
    "spurious-s3" => [
      {
        "Host"     => ENV['S3.SPURIOUS.LOCALHOST_NAME'].split('/').last,
        "HostPort" => URI(ENV['S3.SPURIOUS.LOCALHOST_PORT']).port
      }
    ]
  }
end
port_config() click to toggle source
# File lib/spurious/ruby/awssdk/helper.rb, line 12
def self.port_config
  config = `spurious ports --json`
  JSON.parse(config)
rescue Exception
  raise("The spurious CLI tool didn't return the port configuration")
end