Module: Specinfra::Configuration

Defined in:
lib/specinfra/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :backend,
  :env,
  :path,
  :shell,
  :pre_command,
  :stdout,
  :stderr,
  :sudo_path,
  :disable_sudo,
  :sudo_options,
  :docker_image,
  :docker_url,
  :lxc,
  :request_pty,
  :ssh_options,
].freeze

Class Method Summary collapse

Class Method Details

.defaultsObject



22
23
24
# File 'lib/specinfra/configuration.rb', line 22

def defaults
  VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
end

.method_missing(meth, val = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/specinfra/configuration.rb', line 36

def method_missing(meth, val=nil)
  key = meth.to_s
  key.gsub!(/=$/, '')
  if ! val.nil?
    instance_variable_set("@#{key}", val)
    RSpec.configuration.send(:"#{key}=", val) if defined?(RSpec)
  end

  ret = instance_variable_get("@#{key}")
  if ret.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(key)
    ret = RSpec.configuration.send(key)
  end
  ret
end

.os(value = nil) ⇒ Object

Define os method explicitly to avoid stack level too deep caused by Helpet::DetectOS#os



28
29
30
31
32
33
34
# File 'lib/specinfra/configuration.rb', line 28

def os(value=nil)
  @os = value if value
  if @os.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(:os)
    @os = RSpec.configuration.os
  end
  @os
end