Sha256: aca8b1f5d98c9f5dc15eb3f6fddefe8faf11bd5efd8a394b92628e34ca150c34

Contents?: true

Size: 939 Bytes

Versions: 209

Compression:

Stored size: 939 Bytes

Contents

require 'cgi'

module Seahorse
  # @api private
  module Util
    class << self

      def irregular_inflections(hash)
        @irregular_inflections.update(hash)
        @irregular_regex = Regexp.new(@irregular_inflections.keys.join('|'))
      end

      # @param [String] string
      # @return [String] Returns the underscored version of the given string.
      def underscore(string)
        string.
          gsub(@irregular_regex) { |word| '_' + @irregular_inflections[word] }.
          gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2').
          scan(/[a-z0-9]+|\d+|[A-Z0-9]+[a-z]*/).
          join('_').downcase
      end

      def uri_escape(string)
        CGI.escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
      end

      def uri_path_escape(path)
        path.gsub(/[^\/]+/) { |part| uri_escape(part) }
      end

    end

    @irregular_inflections = {}

    irregular_inflections('ETag' => 'etag')

  end
end

Version data entries

209 entries across 209 versions & 2 rubygems

Version Path
aws-sdk-core-2.6.48 lib/seahorse/util.rb
aws-sdk-core-2.6.47 lib/seahorse/util.rb
aws-sdk-core-2.6.46 lib/seahorse/util.rb
aws-sdk-core-2.6.44 lib/seahorse/util.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/aws-sdk-core-2.3.22/lib/seahorse/util.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/aws-sdk-core-2.3.22/lib/seahorse/util.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/aws-sdk-core-2.3.22/lib/seahorse/util.rb
aws-sdk-core-2.6.43 lib/seahorse/util.rb
aws-sdk-core-2.6.42 lib/seahorse/util.rb
aws-sdk-core-2.6.41 lib/seahorse/util.rb
aws-sdk-core-2.6.40 lib/seahorse/util.rb
aws-sdk-core-2.6.39 lib/seahorse/util.rb
aws-sdk-core-2.6.38 lib/seahorse/util.rb
aws-sdk-core-2.6.36 lib/seahorse/util.rb
aws-sdk-core-2.6.35 lib/seahorse/util.rb
aws-sdk-core-2.6.34 lib/seahorse/util.rb
aws-sdk-core-2.6.33 lib/seahorse/util.rb
aws-sdk-core-2.6.32 lib/seahorse/util.rb
aws-sdk-core-2.6.31 lib/seahorse/util.rb
aws-sdk-core-2.6.30 lib/seahorse/util.rb