Sha256: 637da1eb4f2bfe99093c1c8b6586c7bb2163dcb67bb41724cf663ee5f89e692b

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 KB

Contents

module Fog
  class << self

    def credential=(new_credential)
      @credential = new_credential
      @credentials = nil
    end

    def credential
      @credential || :default
    end

    def credentials
      @credentials ||= begin
        path = File.expand_path('~/.fog')
        credentials = if File.exists?(path)
          File.open(path) do |file|
            YAML.load(file.read)
          end
        else
          nil
        end
        unless credentials && credentials[credential]
          print("\n  To run as '#{credential}', add the following to ~/.fog\n")
          yml = <<-YML

:#{credential}:
  :aws_access_key_id:     INTENTIONALLY_LEFT_BLANK
  :aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
  :rackspace_api_key:     INTENTIONALLY_LEFT_BLANK
  :rackspace_username:    INTENTIONALLY_LEFT_BLANK
  :slicehost_password:    INTENTIONALLY_LEFT_BLANK
  :terremark_username:    INTENTIONALLY_LEFT_BLANK
  :terremark_password:    INTENTIONALLY_LEFT_BLANK

YML
          print(yml)
          raise(ArgumentError.new("Missing Credentials"))
        end
        credentials[credential]
      end
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fog-0.0.84 lib/fog/credentials.rb
fog-0.0.83 lib/fog/credentials.rb
fog-0.0.82 lib/fog/credentials.rb
fog-0.0.81 lib/fog/credentials.rb
fog-0.0.80 lib/fog/credentials.rb
fog-0.0.79 lib/fog/credentials.rb
fog-0.0.78 lib/fog/credentials.rb
fog-0.0.77 lib/fog/credentials.rb
fog-0.0.76 lib/fog/credentials.rb
fog-0.0.75 lib/fog/credentials.rb
fog-0.0.74 lib/fog/credentials.rb
fog-0.0.73 lib/fog/credentials.rb
fog-0.0.72 lib/fog/credentials.rb
fog-0.0.71 lib/fog/credentials.rb
fog-0.0.70 lib/fog/credentials.rb
fog-0.0.69 lib/fog/credentials.rb
fog-0.0.68 lib/fog/credentials.rb
fog-0.0.67 lib/fog/credentials.rb