Class: Specinfra::Backend::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/specinfra/backend/base.rb

Direct Known Subclasses

Cmd, Dockerfile, Exec, ShellScript, Winrm

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/specinfra/backend/base.rb', line 11

def initialize(config = {})
  @config = config
end

Class Method Details

.instanceObject



7
8
9
# File 'lib/specinfra/backend/base.rb', line 7

def self.instance
  @instance ||= self.new
end

Instance Method Details

#commandObject



34
35
36
# File 'lib/specinfra/backend/base.rb', line 34

def command
  CommandFactory.new(os_info)
end

#get_config(key) ⇒ Object



15
16
17
# File 'lib/specinfra/backend/base.rb', line 15

def get_config(key)
  @config[key] || Specinfra.configuration.send(key)
end

#host_inventoryObject



38
39
40
# File 'lib/specinfra/backend/base.rb', line 38

def host_inventory
  @inventory ||= HostInventory.new(self)
end

#os_infoObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/specinfra/backend/base.rb', line 23

def os_info
  return @os_info if @os_info

  Specinfra::Helper::DetectOs.subclasses.each do |klass|
    if @os_info = klass.new(self).detect
      @os_info[:arch] ||= self.run_command('uname -m').stdout.strip
      return @os_info
    end
  end
end

#set_config(key, value) ⇒ Object



19
20
21
# File 'lib/specinfra/backend/base.rb', line 19

def set_config(key, value)
  @config[key] = value
end

#set_example(e) ⇒ Object



42
43
44
# File 'lib/specinfra/backend/base.rb', line 42

def set_example(e)
  @example = e
end