Module: OpenAmplify::Configuration

Included in:
OpenAmplify
Defined in:
lib/openamplify/configuration.rb

Overview

Defines constants and methods for configuring a client

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:endpoint, :user_agent, :method, :adapter].freeze
VALID_OPTIONS_KEYS =
[:api_key, :analysis, :output_format, :scoring].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_ENDPOINT =
'http://portaltnx20.openamplify.com/AmplifyWeb_v21/AmplifyThis'
DEFAULT_HTTP_METHOD =
:get
DEFAULT_HTTP_ADAPTER =
:net_http
DEFAULT_USER_AGENT =
"OpenAmplify Ruby Gem #{OpenAmplify::VERSION}".freeze
DEFAULT_API_KEY =
nil
DEFAULT_ANALYSIS =
:all
DEFAULT_OUTPUT_FORMAT =
:xml
DEFAULT_SCORING =
:standard
DEFAULT_SOURCE_URL =
nil
DEFAULT_INPUT_TEXT =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



27
28
29
# File 'lib/openamplify/configuration.rb', line 27

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:



32
33
34
# File 'lib/openamplify/configuration.rb', line 32

def configure
  yield self
end

#optionsObject



36
37
38
# File 'lib/openamplify/configuration.rb', line 36

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

#resetObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/openamplify/configuration.rb', line 40

def reset
  self.endpoint      = DEFAULT_ENDPOINT
  self.method        = DEFAULT_HTTP_METHOD
  self.adapter       = DEFAULT_HTTP_ADAPTER
  self.user_agent    = DEFAULT_USER_AGENT

  self.api_key       = DEFAULT_API_KEY
  self.analysis      = DEFAULT_ANALYSIS
  self.output_format = DEFAULT_OUTPUT_FORMAT
  self.scoring       = DEFAULT_SCORING
end