Sha256: 0b8502dc254a364eae3b85b86a5a6bc3e35502ba1ef08cb7869feb0ec2341264

Contents?: true

Size: 933 Bytes

Versions: 5

Compression:

Stored size: 933 Bytes

Contents

require 'specinfra/host_inventory/memory'
require 'specinfra/host_inventory/ec2'
require 'specinfra/host_inventory/hostname'
require 'specinfra/host_inventory/domain'
require 'specinfra/host_inventory/fqdn'
require 'specinfra/host_inventory/platform'
require 'specinfra/host_inventory/platform_version'
require 'specinfra/host_inventory/filesystem'
require 'specinfra/host_inventory/cpu'

module Specinfra
  class HostInventory
    include Singleton

    def initialize
      property[:host_inventory] ||= {}
      @inventory = property[:host_inventory]
    end

    def [](key)
      @inventory[key.to_sym] ||= {}
      if @inventory[key.to_sym].empty?
        begin
          inventory_class = Specinfra::HostInventory.const_get(key.to_s.to_camel_case)
          @inventory[key.to_sym] = inventory_class.get
        rescue
          @inventory[key.to_sym] = nil
        end
      end
      @inventory[key.to_sym]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
specinfra-2.17.0 lib/specinfra/host_inventory.rb
specinfra-2.16.0 lib/specinfra/host_inventory.rb
specinfra-2.15.2 lib/specinfra/host_inventory.rb
specinfra-2.15.1 lib/specinfra/host_inventory.rb
specinfra-2.15.0 lib/specinfra/host_inventory.rb