Class: Specinfra::HostInventory
- Inherits:
-
Object
- Object
- Specinfra::HostInventory
- Includes:
- Enumerable
- Defined in:
- lib/specinfra/host_inventory.rb,
lib/specinfra/host_inventory/cpu.rb,
lib/specinfra/host_inventory/ec2.rb,
lib/specinfra/host_inventory/base.rb,
lib/specinfra/host_inventory/fqdn.rb,
lib/specinfra/host_inventory/user.rb,
lib/specinfra/host_inventory/group.rb,
lib/specinfra/host_inventory/domain.rb,
lib/specinfra/host_inventory/kernel.rb,
lib/specinfra/host_inventory/memory.rb,
lib/specinfra/host_inventory/hostname.rb,
lib/specinfra/host_inventory/platform.rb,
lib/specinfra/host_inventory/filesystem.rb,
lib/specinfra/host_inventory/block_device.rb,
lib/specinfra/host_inventory/virtualization.rb,
lib/specinfra/host_inventory/platform_version.rb
Defined Under Namespace
Classes: Base, BlockDevice, Cpu, Domain, Ec2, Filesystem, Fqdn, Group, Hostname, Kernel, Memory, Platform, PlatformVersion, User, Virtualization
Constant Summary collapse
- KEYS =
%w{ memory ec2 hostname domain fqdn platform platform_version filesystem cpu virtualization kernel block_device user group }
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each ⇒ Object
- #each_key ⇒ Object
- #each_value ⇒ Object
-
#initialize(backend, inventory = {}) ⇒ HostInventory
constructor
A new instance of HostInventory.
Constructor Details
#initialize(backend, inventory = {}) ⇒ HostInventory
Returns a new instance of HostInventory.
29 30 31 32 |
# File 'lib/specinfra/host_inventory.rb', line 29 def initialize(backend, inventory = {}) @backend = backend @inventory = inventory end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
22 23 24 |
# File 'lib/specinfra/host_inventory.rb', line 22 def backend @backend end |
Class Method Details
Instance Method Details
#[](key) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/specinfra/host_inventory.rb', line 34 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.new(self).get rescue @inventory[key.to_sym] = nil end end @inventory[key.to_sym] end |
#each ⇒ Object
47 48 49 50 51 |
# File 'lib/specinfra/host_inventory.rb', line 47 def each KEYS.each do |k| yield k, self[k] end end |