Module: SemaApiRuby::Configuration

Included in:
SemaApiRuby
Defined in:
lib/sema_api_ruby/configuration.rb

Constant Summary collapse

VALID_CONFIG_KEYS =
[
  :access_token,
  :api_endpoint,
  :api_version,
  :user_agent,
  :content_type,
  :ocr_settings,
  :debug_output
]
DEFAULT_API_ENDPOINT =

1.0/ocr/

'https://semamediadata.com/api'.freeze
DEFAULT_API_VERSION =
1.0
DEFAULT_USER_AGENT =
"SemaApiRuby Gem #{SemaApiRuby::VERSION}".freeze
DEFAULT_CONTENT_TYPE =
'multipart/form-data'
DEFAULT_DEBUG_OUTPUT =

$stdout

false
DEFAULT_OCR_SETTINGS =
{
  lang: 'en',      # english language
  outform: 'json', # output as json
  sp: 'True',      # perform spellcheck
  mh: 'True',      # multi-hypothesis... increases accuracy at slight performance cost
  df: 'True',      # dictionary based word filtering
  noempty: 'True'  # only return detected objects that are not empty
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



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

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject



40
41
42
# File 'lib/sema_api_ruby/configuration.rb', line 40

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

#resetObject



44
45
46
47
48
49
50
51
52
# File 'lib/sema_api_ruby/configuration.rb', line 44

def reset
  self.access_token  = nil
  self.api_endpoint  = DEFAULT_API_ENDPOINT
  self.api_version   = DEFAULT_API_VERSION
  self.user_agent    = DEFAULT_USER_AGENT
  self.content_type  = DEFAULT_CONTENT_TYPE
  self.debug_output  = DEFAULT_DEBUG_OUTPUT
  self.ocr_settings  = DEFAULT_OCR_SETTINGS
end