Class: AllscriptsUnityClient::ClientOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/allscripts_unity_client/client_options.rb

Overview

Contains various options for Unity configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ClientOptions

Constructor.

options
  • :username - Unity license username __(required)__.

  • :password - Unity license password __(required)__.

  • :appname - Unity license appname __(required)__.

  • :proxy - A string URL pointing to an HTTP proxy (optional, primarily for debugging)

  • :logger - A Ruby object that adheres to the same interface as Logger.

  • :ca_file - A string path for a CA File on the OS (JSON only).

  • :cs_path - A string path for a CA directory (JSON only).

  • :timeout - The number of seconds to set the HTTP response timeout and keepalive timeout (JSON only).

  • :base_unity_url - The URL where a Unity server is located (i.e. unity.server.com) __(required)__



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/allscripts_unity_client/client_options.rb', line 21

def initialize(options = {})
  @username = options[:username]
  @password = options[:password]
  @appname = options[:appname]
  @proxy = options[:proxy]
  @logger = options[:logger]
  @ca_file = options[:ca_file]
  @ca_path = options[:ca_path]
  @timeout = options[:timeout]

  self.timezone = options[:timezone]
  self.base_unity_url = options[:base_unity_url]

  validate_options
end

Instance Attribute Details

#appnameObject

Returns the value of attribute appname.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def appname
  @appname
end

#base_unity_urlObject

Returns the value of attribute base_unity_url.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def base_unity_url
  @base_unity_url
end

#ca_fileObject

Returns the value of attribute ca_file.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def ca_file
  @ca_file
end

#ca_pathObject

Returns the value of attribute ca_path.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def ca_path
  @ca_path
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def password
  @password
end

#proxyObject

Returns the value of attribute proxy.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def proxy
  @proxy
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/allscripts_unity_client/client_options.rb', line 5

def timeout
  @timeout
end

#timezoneObject

Returns the value of attribute timezone.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def timezone
  @timezone
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/allscripts_unity_client/client_options.rb', line 6

def username
  @username
end

Instance Method Details

#ca_file?Boolean

Return true if ca_file is not empty.

Returns:

  • (Boolean)


106
107
108
# File 'lib/allscripts_unity_client/client_options.rb', line 106

def ca_file?
  !@ca_file.to_s.strip.empty?
end

#ca_path?Boolean

Return true if ca_path is not empty.

Returns:

  • (Boolean)


111
112
113
# File 'lib/allscripts_unity_client/client_options.rb', line 111

def ca_path?
  !@ca_path.to_s.strip.empty?
end

#logger?Boolean

Return true if logger is not nil.

Returns:

  • (Boolean)


101
102
103
# File 'lib/allscripts_unity_client/client_options.rb', line 101

def logger?
  !@logger.nil?
end

#proxy?Boolean

Return true if proxy is set and not empty.

Returns:

  • (Boolean)


96
97
98
# File 'lib/allscripts_unity_client/client_options.rb', line 96

def proxy?
  !@proxy.to_s.strip.empty?
end

#timeout?Boolean

Return true if timeout is not empty.

Returns:

  • (Boolean)


116
117
118
# File 'lib/allscripts_unity_client/client_options.rb', line 116

def timeout?
  !@timeout.to_s.strip.empty?
end

#validate_options(options = {}) ⇒ Object

Validates options by ensuring that all required options are present.

See #initialize.

Raises:

  • (ArgumentError)


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

def validate_options(options = {})
  base_unity_url = options.has_key?(:base_unity_url) ? options[:base_unity_url] : @base_unity_url
  username = options.has_key?(:username) ? options[:username] : @username
  password = options.has_key?(:password) ? options[:password] : @password
  appname = options.has_key?(:appname) ? options[:appname] : @appname

  raise ArgumentError, 'base_unity_url can not be nil' if base_unity_url.nil?
  raise ArgumentError, 'username can not be nil' if username.nil?
  raise ArgumentError, 'password can not be nil' if password.nil?
  raise ArgumentError, 'appname can not be nil' if appname.nil?
end