Class: Miasma::Contrib::AwsApiCore::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/miasma/contrib/aws.rb

Overview

Base signature class

Direct Known Subclasses

SignatureV4

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Signature

Create new instance



107
108
109
# File 'lib/miasma/contrib/aws.rb', line 107

def initialize(*args)
  raise NotImplementedError.new 'This class should not be used directly!'
end

Instance Method Details

#generate(http_method, path, opts = {}) ⇒ String

Generate the signature

Parameters:

  • http_method (Symbol)

    HTTP request method

  • path (String)

    request path

  • opts (Hash) (defaults to: {})

    request options

Returns:

  • (String)

    signature

Raises:

  • (NotImplementedError)


117
118
119
# File 'lib/miasma/contrib/aws.rb', line 117

def generate(http_method, path, opts={})
  raise NotImplementedError
end

#safe_escape(string) ⇒ String

URL string escape compatible with AWS requirements

Parameters:

  • string (String)

    string to escape

Returns:

  • (String)

    escaped string



125
126
127
128
129
# File 'lib/miasma/contrib/aws.rb', line 125

def safe_escape(string)
  string.to_s.gsub(/([^a-zA-Z0-9_.\-~])/) do
    '%' << $1.unpack('H2' * $1.bytesize).join('%').upcase
  end
end