Module: TweetStream::Configuration

Included in:
TweetStream
Defined in:
lib/tweetstream/configuration.rb

Overview

Defines constants and methods related to configuration

Constant Summary

VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring TweetStream.

[
:parser,
:username,
:password,
:user_agent,
:auth_method,
:consumer_key,
:consumer_secret,
:oauth_token,
:oauth_token_secret].freeze
OAUTH_OPTIONS_KEYS =
[
:consumer_key,
:consumer_secret,
:oauth_token,
:oauth_token_secret].freeze
DEFAULT_PARSER =

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

MultiJson.default_engine
DEFAULT_USERNAME =

By default, don't set a username

nil
DEFAULT_PASSWORD =

By default, don't set a password

nil
DEFAULT_USER_AGENT =

The user agent that will be sent to the API endpoint if none is set

"TweetStream Ruby Gem #{TweetStream::VERSION}".freeze
DEFAULT_AUTH_METHOD =

The default authentication method

:oauth
VALID_FORMATS =
[
:basic,
:oauth].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_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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) extended(base)

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



60
61
62
# File 'lib/tweetstream/configuration.rb', line 60

def self.extended(base)
  base.reset
end

Instance Method Details

- (Object) configure {|_self| ... }

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

Yields:

  • (_self)

Yield Parameters:



65
66
67
# File 'lib/tweetstream/configuration.rb', line 65

def configure
  yield self
end

- (Object) oauth_options

Create a hash of options and their values



75
76
77
# File 'lib/tweetstream/configuration.rb', line 75

def oauth_options
  Hash[*OAUTH_OPTIONS_KEYS.map {|key| [key, send(key)] }.flatten]
end

- (Object) options

Create a hash of options and their values



70
71
72
# File 'lib/tweetstream/configuration.rb', line 70

def options
  Hash[*VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }.flatten]
end

- (Object) reset

Reset all configuration options to defaults



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/tweetstream/configuration.rb', line 80

def reset
  self.username           = DEFAULT_USERNAME
  self.password           = DEFAULT_PASSWORD
  self.user_agent         = DEFAULT_USER_AGENT
  self.auth_method        = DEFAULT_AUTH_METHOD
  self.consumer_key       = DEFAULT_CONSUMER_KEY
  self.consumer_secret    = DEFAULT_CONSUMER_SECRET
  self.oauth_token        = DEFAULT_OAUTH_TOKEN
  self.oauth_token_secret = DEFAULT_OAUTH_TOKEN_SECRET
  self
end