Class: Loom::Inventory::InventoryFileSet
- Inherits:
-
Object
- Object
- Loom::Inventory::InventoryFileSet
- Defined in:
- lib/loom/inventory.rb
Instance Method Summary collapse
- #hostgroup_map ⇒ Object
- #hostlist ⇒ Object
-
#initialize(inventory_files) ⇒ InventoryFileSet
constructor
A new instance of InventoryFileSet.
Constructor Details
#initialize(inventory_files) ⇒ InventoryFileSet
Returns a new instance of InventoryFileSet.
84 85 86 87 88 89 90 91 92 |
# File 'lib/loom/inventory.rb', line 84 def initialize(inventory_files) @hostgroup_map = nil @hostlist = nil @raw_inventories = inventory_files.map do |path| Loom.log.debug "loading inventory file #{path}" YAML.load_file path end end |
Instance Method Details
#hostgroup_map ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/loom/inventory.rb', line 94 def hostgroup_map @hostgroup_map ||= @raw_inventories.reduce({}) do |map, i| i.each do |entry| if entry.is_a? Hash Loom.log.debug "merging groups in #{entry}" entry.each do |k,v| map[k.to_sym] = v end end end map end end |
#hostlist ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/loom/inventory.rb', line 108 def hostlist @hostlist ||= @raw_inventories.map do |i| i.map do |entry| case entry when String entry when Hash entry.values else raise InventoryFileEntryError, "unexpected entry #{entry}" end end end.flatten end |