Module: Cts::Mpx::Driver

Included in:
Entries
Defined in:
lib/cts/mpx/driver.rb,
lib/cts/mpx/service.rb,
lib/cts/mpx/driver/page.rb,
lib/cts/mpx/driver/helpers.rb,
lib/cts/mpx/driver/request.rb,
lib/cts/mpx/driver/response.rb,
lib/cts/mpx/driver/assemblers.rb,
lib/cts/mpx/driver/exceptions.rb,
lib/cts/mpx/driver/connections.rb

Overview

responsible for low level calls to MPX

Defined Under Namespace

Modules: Assemblers, Connections, Exceptions, Helpers Classes: ConnectionError, CredentialsError, Page, Request, Response, Service, ServiceError, TokenError

Class Method Summary collapse

Class Method Details

.config_dirString

path to our config files

Returns:

  • (String)

    full path to the root of our gem directory.



33
34
35
# File 'lib/cts/mpx/driver.rb', line 33

def config_dir
  "#{gem_dir}/config"
end

.gem_dirString

path to our gem directory, includes support for bundled env’s.

Returns:

  • (String)

    full path to the root of our gem directory.



25
26
27
28
29
# File 'lib/cts/mpx/driver.rb', line 25

def gem_dir
  return Dir.pwd unless Gem.loaded_specs.include? 'cts-mpx'

  Gem.loaded_specs['cts-mpx'].full_gem_path
end

.parse_json(string) ⇒ Hash

load a json file into a simple hash

Parameters:

  • filename (String)

    filename to load

Returns:

  • (Hash)

    data from the file

Raises:

  • (RuntimeError)

    if the filename does not exist.

  • (RuntimeError)

    if the file cannot be parsed, supplies the exception.



42
43
44
45
46
# File 'lib/cts/mpx/driver.rb', line 42

def parse_json(string)
  Oj.compat_load string
rescue Oj::ParseError => exception
  raise "#{string}: #{exception.message}"
end