Object
# File lib/simple_oauth/header.rb, line 12 def 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 28 def escape(value) uri_parser.escape(value.to_s, /[^a-z0-9\-\.\_\~]/) end
# File lib/simple_oauth/header.rb, line 46 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 21 def 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 33 def unescape(value) uri_parser.unescape(value.to_s) end
# File lib/simple_oauth/header.rb, line 74 def signed_attributes attributes.merge(:oauth_signature => signature) end
# File lib/simple_oauth/header.rb, line 62 def to_s "OAuth #{normalized_attributes}" end
Generated with the Darkfish Rdoc Generator 2.