Object
# File lib/simple_oauth/header.rb, line 23 def self.decode(value) URI.decode(value.to_s) end
# File lib/simple_oauth/header.rb, line 10 def self.default_options { :nonce => OpenSSL::Random.random_bytes(16).unpack('H*')[0], :signature_method => 'HMAC-SHA1', :timestamp => Time.now.to_i.to_s, :version => '1.0' } end
# File lib/simple_oauth/header.rb, line 19 def self.encode(value) URI.encode(value.to_s, /[^a-z0-9\-\.\_\~]/) end
# File lib/simple_oauth/header.rb, line 36 def initialize(method, url, params, oauth = {}) @method = method.to_s.upcase @uri = URI.parse(url.to_s) @uri.scheme = @uri.scheme.downcase @uri.normalize! @uri.fragment = nil @params = params @options = oauth.is_a?(Hash) ? self.class.default_options.merge(oauth) : self.class.parse(oauth) end
# File lib/simple_oauth/header.rb, line 27 def self.parse(header) header.to_s.sub(/^OAuth\s/, '').split(/,\s*/).inject({}) do |attributes, pair| match = pair.match(/^(\w+)\=\"([^\"]*)\"$/) attributes.merge(match[1].sub(/^oauth_/, '').to_sym => decode(match[2])) end end
# File lib/simple_oauth/header.rb, line 64 def signed_attributes attributes.merge(:oauth_signature => signature) end
# File lib/simple_oauth/header.rb, line 52 def to_s "OAuth #{normalized_attributes}" end
Generated with the Darkfish Rdoc Generator 2.