class RSpec::Hive::Configuration

Constants

DEFAULT_TIMEOUT
DEFAULT_VERSION

Attributes

connection_timeout[RW]
docker_shared_directory_path[RW]
hive_options[RW]
hive_version[RW]
host[RW]
host_shared_directory_path[RW]
logger[RW]
port[RW]

Public Class Methods

new(path_to_config_file = nil) click to toggle source
# File lib/rspec/hive/configuration.rb, line 20
def initialize(path_to_config_file = nil)
  if path_to_config_file.nil?
    load_default_variables
  else
    interpolated = ERB.new(File.read(path_to_config_file)).result
    config = YAML.safe_load(interpolated)['hive']
    load_variables_from_config(config)
  end
  @logger = Logger.new(STDOUT)
end

Private Instance Methods

load_default_variables() click to toggle source
# File lib/rspec/hive/configuration.rb, line 33
def load_default_variables
  @host = '127.0.0.1'
  @port = 10_000
  @host_shared_directory_path = platform_specific_host_shared_dir_path
  @docker_shared_directory_path = '/tmp/spec-tmp-files'
  @hive_version = DEFAULT_VERSION
  @connection_timeout = DEFAULT_TIMEOUT
  @hive_options = {}
end
load_variables_from_config(config) click to toggle source
# File lib/rspec/hive/configuration.rb, line 43
def load_variables_from_config(config)
  @host = config['host']
  @port = config['port']
  @host_shared_directory_path = config['host_shared_directory_path']
  @docker_shared_directory_path = config['docker_shared_directory_path']
  @hive_version = (config['hive_version'] || DEFAULT_VERSION).to_i
  @connection_timeout = (config['timeout'] || DEFAULT_TIMEOUT).to_i
  @hive_options = config['hive_options'].to_h
end
mac?() click to toggle source
# File lib/rspec/hive/configuration.rb, line 53
def mac?
  host_os = RbConfig::CONFIG['host_os']
  host_os =~ /darwin|mac os/
end
platform_specific_host_shared_dir_path() click to toggle source
# File lib/rspec/hive/configuration.rb, line 58
def platform_specific_host_shared_dir_path
  if mac?
    File.join(Dir.mktmpdir(nil, '/Users/Shared'), 'spec-tmp-files')
  else
    File.join(Dir.mktmpdir, 'spec-tmp-files')
  end
end