Sha256: ae4b1c0db1bdc031c0ded219f43bc2acd40f97d155503bb1f00509687b399d47

Contents?: true

Size: 857 Bytes

Versions: 5

Compression:

Stored size: 857 Bytes

Contents

require 'singleton'
require 'specinfra/command_result'

module Specinfra::Backend
  class Base
    def self.instance
      @instance ||= self.new
    end

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

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

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

    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

    def command
      CommandFactory.new(os_info)
    end

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

    def set_example(e)
      @example = e
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
specinfra-2.25.1 lib/specinfra/backend/base.rb
specinfra-2.25.0 lib/specinfra/backend/base.rb
specinfra-2.24.2 lib/specinfra/backend/base.rb
specinfra-2.24.1 lib/specinfra/backend/base.rb
specinfra-2.24.0 lib/specinfra/backend/base.rb