Sha256: db56d72e8a10938773a2a6c69c356dc4d7ebae5f99aac72a99afea7f9310485c

Contents?: true

Size: 770 Bytes

Versions: 9

Compression:

Stored size: 770 Bytes

Contents

require 'fog'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/hash/reverse_merge'
require 'guignol/configuration'

module Guignol
  # Pool Fog connections to minimize latency
  module Connection
    def self.get(options)
      @connections ||= {}
      @connections[options] ||= Fog::Compute.new(credentials.merge options)
    end


    private


    # Find and return credentials
    def self.credentials
      if ENV['AWS_SECRET_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
        {
          :aws_access_key_id     => ENV['AWS_SECRET_KEY_ID'],
          :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
        }
      else
        Guignol.configuration.slice(:aws_access_key_id, :aws_secret_access_key)
      end
    end


  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
guignol-0.3.14 lib/guignol/connection.rb
guignol-0.3.13 lib/guignol/connection.rb
guignol-0.3.12 lib/guignol/connection.rb
guignol-0.3.10 lib/guignol/connection.rb
guignol-0.3.9 lib/guignol/connection.rb
guignol-0.3.8 lib/guignol/connection.rb
guignol-0.3.7 lib/guignol/connection.rb
guignol-0.3.6.2 lib/guignol/connection.rb
guignol-0.3.6.1 lib/guignol/connection.rb