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

Raises:

  • (NotImplementedError)


132
133
134
# File 'lib/miasma/contrib/aws.rb', line 132

def initialize(*args)
  raise NotImplementedError, "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)


142
143
144
# File 'lib/miasma/contrib/aws.rb', line 142

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



150
151
152
153
154
# File 'lib/miasma/contrib/aws.rb', line 150

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