Module: AylienTextApi::Configuration

Included in:
AylienTextApi
Defined in:
lib/aylien_text_api/configuration.rb

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:base_uri, :user_agent, :method].freeze
VALID_OPTIONS_KEYS =
[:app_id, :app_key].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_BASE_URI =
'https://api.aylien.com/api/v1/'.freeze
DEFAULT_METHOD =
:post
DEFAULT_USER_AGENT =
"Aylien Text API Ruby Gem #{AylienTextApi::VERSION}".freeze
DEFAULT_APP_ID =
nil
DEFAULT_APP_KEY =
nil
ENDPOINTS =
{
  extract:  'extract',
  classify: 'classify',
  classify_by_taxonomy: 'classify/:taxonomy',
  concepts: 'concepts',
  entities: 'entities',
  hashtags: 'hashtags',
  language: 'language',
  sentiment: 'sentiment',
  summarize: 'summarize',
  image_tags: 'image-tags',
  combined: 'combined',
  absa: 'absa/:domain',
  elsa: 'elsa'
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Make sure we have the default values set when we get ‘extended’



49
50
51
# File 'lib/aylien_text_api/configuration.rb', line 49

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



62
63
64
# File 'lib/aylien_text_api/configuration.rb', line 62

def configure
  yield self
end

#optionsObject



66
67
68
# File 'lib/aylien_text_api/configuration.rb', line 66

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

#resetObject



53
54
55
56
57
58
59
60
# File 'lib/aylien_text_api/configuration.rb', line 53

def reset
  self.base_uri    = DEFAULT_BASE_URI
  self.method      = DEFAULT_METHOD
  self.user_agent  = DEFAULT_USER_AGENT

  self.app_id     = DEFAULT_APP_ID
  self.app_key    = DEFAULT_APP_KEY
end