module Alephant::Harness::AWS

Constants

ACCESS_CONFIG_KEYS
DYNAMO_CONFIG_KEYS
S3_CONFIG_KEYS
SQS_CONFIG_KEYS

Public Class Methods

config=(environment) click to toggle source
# File lib/alephant/harness/aws.rb, line 13
def config=(environment)
  @environment = environment
end
dynamo_config() click to toggle source
# File lib/alephant/harness/aws.rb, line 33
def dynamo_config
  environment.select do |key, _|
    (ACCESS_CONFIG_KEYS + DYNAMO_CONFIG_KEYS).include?(key)
  end.map do |key, value|
    [key.to_s.gsub('dynamo_db_', '').to_sym, value]
  end.to_h
end
environment() click to toggle source
# File lib/alephant/harness/aws.rb, line 9
def environment
  aws_properties_from(@environment || ENV)
end
s3_config() click to toggle source
# File lib/alephant/harness/aws.rb, line 17
def s3_config
  environment.select do |key, _|
    (ACCESS_CONFIG_KEYS + S3_CONFIG_KEYS).include?(key)
  end.map do |key, value|
    [key.to_s.gsub('s3_', '').to_sym, value]
  end.to_h
end
sqs_config() click to toggle source
# File lib/alephant/harness/aws.rb, line 25
def sqs_config
  environment.select do |key, _|
    (ACCESS_CONFIG_KEYS + SQS_CONFIG_KEYS).include?(key)
  end.map do |key, value|
    [key.to_s.gsub('sqs_', '').to_sym, value]
  end.to_h
end

Private Class Methods

aws_properties_from(env) click to toggle source
# File lib/alephant/harness/aws.rb, line 48
def aws_properties_from(env)
  env.inject({}) do |hash, (key, value)|
    hash.tap do |h|
      h[config_key(key)] = sanitise_value(value) if key =~ /^AWS_/
    end
  end
end
config_key(original_key) click to toggle source
# File lib/alephant/harness/aws.rb, line 56
def config_key(original_key)
  original_key[/AWS_(.*)/,1].downcase.to_sym
end
sanitise_value(value) click to toggle source
# File lib/alephant/harness/aws.rb, line 60
def sanitise_value(value)
  if %w[ true false ].include?(value)
    value == 'true'
  else
    value
  end
end