Sha256: 6f91bf97234081be734501344a559febc8b298772fc1b731d5dc429ec52fb686

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

module Vacuum
  module Endpoint
    # An Amazon Web Services (AWS) API endpoint.
    class Base
      LOCALES = %w(CA CN DE ES FR IT JP UK US)

      # Raises a Not Implemented Error.
      #
      # When implemented, this should return a String AWS API host.
      def host
        raise NotImplementedError
      end

      # Returns the String AWS access key ID.
      #
      # Raises a Missing Key error if key is missing.
      def key
        @key or raise MissingKey
      end

      # Sets the String AWS access key ID.
      attr_writer :key

      # Returns the String AWS API locale (default: US).
      #
      # Raises a Bad Locale error if locale is not valid.
      def locale
        @locale ||= 'US'
        LOCALES.include? @locale or raise BadLocale

        @locale
      end

      # Sets the String AWS API locale.
      attr_writer :locale

      # Returns the String AWS access secret key.
      #
      # Raises a Missing Secret error if secret is missing.
      def secret
        @secret or raise MissingSecret
      end

      # Sets the String AWS access secret key.
      attr_writer :secret

      # Returns a String user agent for the AWS API request.
      def user_agent
        engine   = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
        language = [engine, RUBY_VERSION, "p#{RUBY_PATCHLEVEL}"].join ' '
        hostname = `hostname`.chomp
        version  = Vacuum::VERSION

        "Vacuum/#{version} (Language=#{language}; Host=#{hostname})"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vacuum-0.2.2 lib/vacuum/endpoint/base.rb
vacuum-0.2.1 lib/vacuum/endpoint/base.rb
vacuum-0.2.0 lib/vacuum/endpoint/base.rb
vacuum-0.2.0.pre.1 lib/vacuum/endpoint/base.rb
vacuum-0.2.0.pre lib/vacuum/endpoint/base.rb