Sha256: ac1e538ba9e9bf1ef32786f0cf4385e07a3dfecd89648c3971bb3b3494064fe9

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 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 set_example(e)
      @example = e
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
specinfra-2.23.0 lib/specinfra/backend/base.rb
specinfra-2.22.0 lib/specinfra/backend/base.rb