module Disqussion::Configuration

Defines constants and methods related to configuration

Constants

DEFAULT_ADAPTER

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

@note The default faraday adapter is Net::HTTP.

DEFAULT_API_KEY

By default, don’t set an application key

DEFAULT_API_SECRET

By default, don’t set an application secret

DEFAULT_API_VERSION

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

@note This is configurable in case you want to use HTTP instead of HTTPS, specify a different API version, or use a Disqussion-compatible endpoint. @see status.net/wiki/Disqussion-compatible_API @see en.blog.wordpress.com/2009/12/12/disqussion-api/ @see staff.tumblr.com/post/287703110/api @see developer.typepad.com/typepad-disqussion-api/disqussion-api.html

DEFAULT_AVATAR_SIZE
DEFAULT_COLOR
DEFAULT_CONTAINER_ID
DEFAULT_DEFAULT_TAB
DEFAULT_DEVELOPER
DEFAULT_ENDPOINT
DEFAULT_FORMAT

The response format appended to the path and sent in the ‘Accept’ header if none is set

@note JSON is preferred over XML because it is more concise and faster to parse.

DEFAULT_HIDE_AVATARS
DEFAULT_HIDE_MODS
DEFAULT_NUM_ITEMS
DEFAULT_ORIENTATION
DEFAULT_PROXY

By default, don’t use a proxy server

DEFAULT_SHOW_POWERED_BY
DEFAULT_USER_AGENT

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

VALID_FORMATS

An array of valid request/response formats

@note only json for now

VALID_OPTIONS_KEYS

An array of valid keys in the options hash when configuring a {Disqussion::API}

Public Class Methods

extended(base) click to toggle source

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

# File lib/disqussion/configuration.rb, line 79
def self.extended(base)
  base.reset
end

Public Instance Methods

configure() { |self| ... } click to toggle source

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

# File lib/disqussion/configuration.rb, line 84
def configure
  yield self
end
options() click to toggle source

Create a hash of options and their values

# File lib/disqussion/configuration.rb, line 89
def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }
  options
end
reset() click to toggle source

Reset all configuration options to defaults

# File lib/disqussion/configuration.rb, line 96
def reset
  self.adapter            = DEFAULT_ADAPTER
  self.endpoint           = DEFAULT_ENDPOINT
  self.api_key            = DEFAULT_API_KEY
  self.api_secret         = DEFAULT_API_SECRET
  self.developer          = DEFAULT_DEVELOPER
  self.container_id       = DEFAULT_CONTAINER_ID
  self.avatar_size        = DEFAULT_AVATAR_SIZE
  self.color              = DEFAULT_COLOR
  self.default_tab        = DEFAULT_DEFAULT_TAB
  self.hide_avatars       = DEFAULT_HIDE_AVATARS
  self.hide_mods          = DEFAULT_HIDE_MODS
  self.num_items          = DEFAULT_NUM_ITEMS
  self.show_powered_by    = DEFAULT_SHOW_POWERED_BY
  self.orientation        = DEFAULT_ORIENTATION
  self.format             = DEFAULT_FORMAT
  self.proxy              = DEFAULT_PROXY
  self.user_agent         = DEFAULT_USER_AGENT
  self
end