Sha256: db0fd1c5f6b1e566b489feb988b096b9c5b23b49f0e6223da343f0dbf4ed9f66

Contents?: true

Size: 894 Bytes

Versions: 4

Compression:

Stored size: 894 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'

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

4 entries across 4 versions & 1 rubygems

Version Path
specinfra-2.14.4 lib/specinfra/host_inventory.rb
specinfra-2.14.3 lib/specinfra/host_inventory.rb
specinfra-2.14.2 lib/specinfra/host_inventory.rb
specinfra-2.14.1 lib/specinfra/host_inventory.rb