Class: AuthenticImage::Request
- Inherits:
-
Object
- Object
- AuthenticImage::Request
- Defined in:
- lib/authentic_image/request.rb
Overview
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#rotation ⇒ Object
readonly
Returns the value of attribute rotation.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #identifier ⇒ Object
-
#initialize(host:, prefix:, signing_key:, digest: "sha1", bucket:, key:, region: "full", size: "full", rotation: "0", quality: "default", format: "jpg", version: 1) ⇒ Request
constructor
A new instance of Request.
- #path ⇒ Object
- #signature ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(host:, prefix:, signing_key:, digest: "sha1", bucket:, key:, region: "full", size: "full", rotation: "0", quality: "default", format: "jpg", version: 1) ⇒ Request
Returns a new instance of Request.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/authentic_image/request.rb', line 6 def initialize(host:, prefix:, signing_key:, digest: "sha1", bucket:, key:, region: "full", size: "full", rotation: "0", quality: "default", format: "jpg", version: 1) @host = host @prefix = prefix @signing_key = signing_key @digest = OpenSSL::Digest.new(digest) @bucket = bucket @key = key @region = region @size = size @rotation = rotation @quality = quality @format = format @version = version end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
23 24 25 |
# File 'lib/authentic_image/request.rb', line 23 def bucket @bucket end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
33 34 35 |
# File 'lib/authentic_image/request.rb', line 33 def format @format end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
21 22 23 |
# File 'lib/authentic_image/request.rb', line 21 def host @host end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
23 24 25 |
# File 'lib/authentic_image/request.rb', line 23 def key @key end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
21 22 23 |
# File 'lib/authentic_image/request.rb', line 21 def prefix @prefix end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
31 32 33 |
# File 'lib/authentic_image/request.rb', line 31 def quality @quality end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
25 26 27 |
# File 'lib/authentic_image/request.rb', line 25 def region @region end |
#rotation ⇒ Object (readonly)
Returns the value of attribute rotation.
29 30 31 |
# File 'lib/authentic_image/request.rb', line 29 def rotation @rotation end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
27 28 29 |
# File 'lib/authentic_image/request.rb', line 27 def size @size end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
35 36 37 |
# File 'lib/authentic_image/request.rb', line 35 def version @version end |
Instance Method Details
#identifier ⇒ Object
37 38 39 |
# File 'lib/authentic_image/request.rb', line 37 def identifier CGI.escape("#{bucket}/#{key}") end |
#path ⇒ Object
41 42 43 |
# File 'lib/authentic_image/request.rb', line 41 def path "#{prefix}/#{identifier}/#{region}/#{size}/#{rotation}/#{quality}.#{format}" end |
#signature ⇒ Object
45 46 47 |
# File 'lib/authentic_image/request.rb', line 45 def signature OpenSSL::HMAC.hexdigest(digest, signing_key, path) end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/authentic_image/request.rb', line 53 def to_s url end |
#url ⇒ Object
49 50 51 |
# File 'lib/authentic_image/request.rb', line 49 def url "#{host}#{path}?sig=#{signature}&ver=#{version}" end |