Sha256: 86a7dbe73628ce19490391f86827e11138cdddd432ecaacae3fbe550b74da286

Contents?: true

Size: 710 Bytes

Versions: 7

Compression:

Stored size: 710 Bytes

Contents

require 'aws-sdk'

module Alephant
  module Harness
    module AWS

      def self.configure(environment = nil)

        environment ||= ENV

        ::AWS.config(aws_properties_from(environment))
      end

      def self.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

      def self.config_key(original_key)
        original_key[/AWS_(.*)/,1].downcase.to_sym
      end

      def self.sanitise_value(value)
        if %w[ true false ].include?(value)
          value == 'true'
        else
          value
        end
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alephant-harness-0.2.2 lib/alephant/harness/aws.rb
alephant-harness-0.2.1 lib/alephant/harness/aws.rb
alephant-harness-0.2.0 lib/alephant/harness/aws.rb
alephant-harness-0.1.3 lib/alephant/harness/aws.rb
alephant-harness-0.1.2 lib/alephant/harness/aws.rb
alephant-harness-0.1.1 lib/alephant/harness/aws.rb
alephant-harness-0.1.0 lib/alephant/harness/aws.rb