# File lib/simple_oauth/header.rb, line 18 def self.decode(value) URI.decode(value.to_s) end
# File lib/simple_oauth/header.rb, line 5 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 14 def self.encode(value) URI.encode(value.to_s, /[^a-z0-9\-\.\_\~]/) end
# File lib/simple_oauth/header.rb, line 31 def initialize(method, url, params, oauth = {}) @method = method.to_s.upcase @uri = URI.parse(url).tap do |uri| uri.scheme = uri.scheme.downcase uri.normalize! uri.fragment = nil end @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 22 def self.parse(header) header.to_s.sub(/^OAuth\s/, '').split(', ').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 58 def signed_attributes attributes.merge(:oauth_signature => signature) end
# File lib/simple_oauth/header.rb, line 46 def to_s "OAuth #{normalized_attributes}" end
Generated with the Darkfish Rdoc Generator 2.