Class: AWS::URL
- Inherits:
-
Object
- Object
- AWS::URL
- Defined in:
- lib/aws/url.rb,
lib/aws/url/version.rb,
lib/aws/url/signature.rb
Overview
A Signed Amazon Web Services (AWS) URL.
Supports Signature Version 2.
Defined Under Namespace
Classes: Signature
Constant Summary collapse
- UNRESERVED =
/([^\w.~-]+)/
- VERSION =
'0.2.0'
Instance Method Summary collapse
-
#initialize(base_url, action, key, secret) ⇒ URL
constructor
Initializes a new URL.
-
#params ⇒ Object
Returns the Hash AWS parameters.
-
#query ⇒ Object
Returns the signed query String.
-
#to_s ⇒ Object
Returns the signed URL String.
-
#update(hash) ⇒ Object
Updates the AWS parameters.
Constructor Details
#initialize(base_url, action, key, secret) ⇒ URL
Initializes a new URL.
base_url - The String base URL, including scheme, host and path, of the
AWS endpoint.
action - The String-like HTTP action. key - The String AWS access key id. secret - The String AWS secret key.
24 25 26 27 28 29 30 |
# File 'lib/aws/url.rb', line 24 def initialize(base_url, action, key, secret) @base_url = URI base_url @action = action.to_s.upcase @key = key @secret = secret @params = {} end |
Instance Method Details
#params ⇒ Object
Returns the Hash AWS parameters.
33 34 35 |
# File 'lib/aws/url.rb', line 33 def params default_params.merge @params end |
#query ⇒ Object
Returns the signed query String.
38 39 40 |
# File 'lib/aws/url.rb', line 38 def query "#{unsigned_query}&Signature=#{escape signature}" end |
#to_s ⇒ Object
Returns the signed URL String.
43 44 45 |
# File 'lib/aws/url.rb', line 43 def to_s "#{@base_url}?#{query}" end |
#update(hash) ⇒ Object
Updates the AWS parameters.
hash - A Hash.
Returns self.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/aws/url.rb', line 52 def update(hash) @unsigned_query = nil hash.each do |key, val| # Syntactic sugar: Camelize symbol keys. if key.is_a? Symbol key = key.to_s.split('_').map(&:capitalize).join end @params[key] = val end self end |