Class: Semantria::Authenticator
- Inherits:
-
Object
- Object
- Semantria::Authenticator
- Defined in:
- lib/semantria/auth.rb
Instance Attribute Summary collapse
-
#consumer_key ⇒ Object
readonly
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
readonly
Returns the value of attribute consumer_secret.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(consumer_key, consumer_secret) ⇒ Authenticator
constructor
A new instance of Authenticator.
- #parameters_hash ⇒ Object
- #path ⇒ Object
- #updated_uri ⇒ Object
Constructor Details
#initialize(consumer_key, consumer_secret) ⇒ Authenticator
Returns a new instance of Authenticator.
15 16 17 |
# File 'lib/semantria/auth.rb', line 15 def initialize(consumer_key, consumer_secret) @consumer_secret, @consumer_key = consumer_secret, consumer_key end |
Instance Attribute Details
#consumer_key ⇒ Object (readonly)
Returns the value of attribute consumer_key.
12 13 14 |
# File 'lib/semantria/auth.rb', line 12 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object (readonly)
Returns the value of attribute consumer_secret.
12 13 14 |
# File 'lib/semantria/auth.rb', line 12 def consumer_secret @consumer_secret end |
#uri ⇒ Object
Returns the value of attribute uri.
13 14 15 |
# File 'lib/semantria/auth.rb', line 13 def uri @uri end |
Instance Method Details
#headers ⇒ Object
19 20 21 |
# File 'lib/semantria/auth.rb', line 19 def headers {'Authorization' => parameters_hash.merge({'OAuth realm' => '', "oauth_signature" => signature}).map { |k, v| "#{k}=#{v}" }.join(',')} end |
#parameters_hash ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/semantria/auth.rb', line 23 def parameters_hash { "oauth_version" => '1.0', "oauth_timestamp" => , "oauth_nonce" => nonce, "oauth_signature_method" => "HMAC-SHA1", "oauth_consumer_key" => consumer_key } end |
#path ⇒ Object
36 37 38 |
# File 'lib/semantria/auth.rb', line 36 def path updated_uri.request_uri end |
#updated_uri ⇒ Object
31 32 33 34 |
# File 'lib/semantria/auth.rb', line 31 def updated_uri uri.query = parameters_hash.map {|k, v| "#{k}=#{v}"}.join('&').gsub('+', '%20').gsub('%7E', '~') uri end |