Sha256: 937444667e0a3b332f758897e1cdb90fcd8a72f1fd08cf57d1d35b5c9e9912e9

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module Aws
  module Api

    # This class is responsible for calculating class names and method names
    # from AWS name.  The basic pattern for determining a class name is:
    #
    # * Start with the service full name or abbreviation if it has one
    # * Remove AWS/Amazon prefixes and suffixes
    # * Take the shorter of the name or the endpoint prefix
    #
    class ServiceNamer

      def initialize(endpoint_prefix, full_name, abbreviation = nil)
        @full_name = full_name
        @abbreviation = abbreviation
        @class_name = build_class_name(endpoint_prefix)
      end

      # @return [String]
      attr_reader :full_name

      # @return [String, nil]
      attr_reader :abbreviation

      alias abbr abbreviation

      # @return [String]
      attr_reader :class_name

      private

      def build_class_name(endpoint_prefix)
        name = @abbreviation || @full_name
        name = name.sub('Amazon', '').sub('AWS', '').gsub(/\W+/, '')
        [name, endpoint_prefix.upcase].sort_by(&:size).first
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.0.rc10 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc9 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc8 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc7 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc6 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc5 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc4 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc3 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc2 lib/aws/api/service_namer.rb
aws-sdk-core-2.0.0.rc1 lib/aws/api/service_namer.rb