Module: Orkut::Config

Included in:
Orkut
Defined in:
lib/orkut/config.rb

Overview

Defines constants and methods related to configuration

Constant Summary collapse

VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring a API

[
:site,
:request_token_path,
:access_token_path,
:authorize_path,
:endpoint,
:endpoint_rest,
:endpoint_rpc,
:user_agent,
:consumer_key,
:consumer_secret,
:oauth_token,
:oauth_token_secret,
:client_id,
:client_secret,
:scope,
:redirect_uri,
:refresh_token,
:access_token,
:expires_in,
:issued_at,
:code].freeze
DEFAULT_SITE =
'https://www.google.com'.freeze
DEFAULT_REQUEST_TOKEN_PATH =
'/accounts/OAuthGetRequestToken'.freeze
DEFAULT_ACCESS_TOKEN_PATH =
'/accounts/OAuthGetAccessToken'.freeze
DEFAULT_AUTHORIZE_PATH =
'/accounts/OAuthAuthorizeToken'.freeze
DEFAULT_CONSUMER_KEY =

By default, don’t set an application key

nil
DEFAULT_CONSUMER_SECRET =

By default, don’t set an application secret

nil
DEFAULT_ENDPOINT =

The endpoint that will be used to connect if none is set

'http://www.orkut.com/social/rpc'.freeze
DEFAULT_ENDPOINT_REST =
'http://www.orkut.com/social/rest'.freeze
DEFAULT_ENDPOINT_RPC =
'http://www.orkut.com/social/rpc'.freeze
DEFAULT_OAUTH_TOKEN =

By default, don’t set a user oauth token

nil
DEFAULT_OAUTH_TOKEN_SECRET =

By default, don’t set a user oauth secret

nil
DEFAULT_USER_AGENT =

The value sent in the ‘User-Agent’ header if none is set

"Orkut Ruby Gem #{Orkut::Version}".freeze
DEFAULT_CLIENT_ID =
nil
DEFAULT_CLIENT_SECRET =
nil
DEFAULT_SCOPE =
'https://www.googleapis.com/auth/orkut'.freeze
DEFAULT_REDIRECT_URI =
''
DEFAULT_REFRESH_TOKEN =
nil
DEFAULT_ACCESS_TOKEN =
nil
DEFAULT_EXPIRES_IN =
nil
DEFAULT_ISSUED_AT =
nil
DEFAULT_CODE =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



81
82
83
# File 'lib/orkut/config.rb', line 81

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:

  • _self (Orkut::Config)

    the object that the method was called on



86
87
88
89
# File 'lib/orkut/config.rb', line 86

def configure
  yield self
  self
end

#optionsObject

Create a hash of options and their values



92
93
94
95
96
# File 'lib/orkut/config.rb', line 92

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
  options
end

#resetObject

Reset all configuration options to defaults



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/orkut/config.rb', line 99

def reset
  self.site               = DEFAULT_SITE
  self.request_token_path = DEFAULT_REQUEST_TOKEN_PATH
  self.access_token_path  = DEFAULT_ACCESS_TOKEN_PATH
  self.authorize_path     = DEFAULT_AUTHORIZE_PATH
  self.consumer_key       = DEFAULT_CONSUMER_KEY
  self.consumer_secret    = DEFAULT_CONSUMER_SECRET
  self.endpoint           = DEFAULT_ENDPOINT
  self.endpoint_rest      = DEFAULT_ENDPOINT_REST
  self.endpoint_rpc       = DEFAULT_ENDPOINT_RPC
  self.oauth_token        = DEFAULT_OAUTH_TOKEN
  self.oauth_token_secret = DEFAULT_OAUTH_TOKEN_SECRET
  self.user_agent         = DEFAULT_USER_AGENT
  self.client_id          = DEFAULT_CLIENT_ID
  self.client_secret      = DEFAULT_CLIENT_SECRET
  self.scope              = DEFAULT_SCOPE
  self.redirect_uri       = DEFAULT_REDIRECT_URI
  self.refresh_token      = DEFAULT_REFRESH_TOKEN
  self.access_token       = DEFAULT_ACCESS_TOKEN
  self.expires_in         = DEFAULT_EXPIRES_IN
  self.issued_at          = DEFAULT_ISSUED_AT
  self.code               = DEFAULT_CODE
  self
end