Parent

Included Modules

OAuth::Client::Helper

Public Class Methods

new(request, options = {}) click to toggle source
    # File lib/oauth/client/helper.rb, line 11
11:     def initialize(request, options = {})
12:       @request = request
13:       @options = options
14:       @options[:signature_method] ||= 'HMAC-SHA1'
15:     end

Public Instance Methods

amend_user_agent_header(headers) click to toggle source
    # File lib/oauth/client/helper.rb, line 63
63:     def amend_user_agent_header(headers)
64:       @oauth_ua_string ||= "OAuth gem v#{OAuth::VERSION}"
65:       # Net::HTTP in 1.9 appends Ruby
66:       if headers['User-Agent'] && headers['User-Agent'] != 'Ruby' 
67:         headers['User-Agent'] += " (#{@oauth_ua_string})"
68:       else
69:         headers['User-Agent'] = @oauth_ua_string
70:       end
71:     end
hash_body() click to toggle source
    # File lib/oauth/client/helper.rb, line 59
59:     def hash_body
60:       @options[:body_hash] = OAuth::Signature.body_hash(@request, :parameters => oauth_parameters)
61:     end
header() click to toggle source
    # File lib/oauth/client/helper.rb, line 73
73:     def header
74:       parameters = oauth_parameters
75:       parameters.merge!('oauth_signature' => signature(options.merge(:parameters => parameters)))
76: 
77:       header_params_str = parameters.sort.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(', ')
78: 
79:       realm = "realm=\"#{options[:realm]}\", " if options[:realm]
80:       "OAuth #{realm}#{header_params_str}"
81:     end
nonce() click to toggle source
    # File lib/oauth/client/helper.rb, line 21
21:     def nonce
22:       options[:nonce] ||= generate_key
23:     end
oauth_parameters() click to toggle source
    # File lib/oauth/client/helper.rb, line 29
29:     def oauth_parameters
30:       {
31:         'oauth_body_hash'        => options[:body_hash],
32:         'oauth_callback'         => options[:oauth_callback],
33:         'oauth_consumer_key'     => options[:consumer].key,
34:         'oauth_token'            => options[:token] ? options[:token].token : '',
35:         'oauth_signature_method' => options[:signature_method],
36:         'oauth_timestamp'        => timestamp,
37:         'oauth_nonce'            => nonce,
38:         'oauth_verifier'         => options[:oauth_verifier],
39:         'oauth_version'          => (options[:oauth_version] || '1.0'),
40:         'oauth_session_handle'   => options[:oauth_session_handle]
41:       }.reject { |k,v| v.to_s == "" }
42:     end
options() click to toggle source
    # File lib/oauth/client/helper.rb, line 17
17:     def options
18:       @options
19:     end
parameters() click to toggle source
    # File lib/oauth/client/helper.rb, line 83
83:     def parameters
84:       OAuth::RequestProxy.proxy(@request).parameters
85:     end
parameters_with_oauth() click to toggle source
    # File lib/oauth/client/helper.rb, line 87
87:     def parameters_with_oauth
88:       oauth_parameters.merge(parameters)
89:     end
signature(extra_options = {}) click to toggle source
    # File lib/oauth/client/helper.rb, line 44
44:     def signature(extra_options = {})
45:       OAuth::Signature.sign(@request, { :uri      => options[:request_uri],
46:                                         :consumer => options[:consumer],
47:                                         :token    => options[:token],
48:                                         :unsigned_parameters => options[:unsigned_parameters]
49:       }.merge(extra_options) )
50:     end
signature_base_string(extra_options = {}) click to toggle source
    # File lib/oauth/client/helper.rb, line 52
52:     def signature_base_string(extra_options = {})
53:       OAuth::Signature.signature_base_string(@request, { :uri        => options[:request_uri],
54:                                                          :consumer   => options[:consumer],
55:                                                          :token      => options[:token],
56:                                                          :parameters => oauth_parameters}.merge(extra_options) )
57:     end
timestamp() click to toggle source
    # File lib/oauth/client/helper.rb, line 25
25:     def timestamp
26:       options[:timestamp] ||= generate_timestamp
27:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.