Class: ConfigBuilder::Filter::Boxes

Inherits:
Object
  • Object
show all
Defined in:
lib/config_builder/filter/boxes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#boxesObject (readonly)

Returns the value of attribute boxes.



3
4
5
# File 'lib/config_builder/filter/boxes.rb', line 3

def boxes
  @boxes
end

Instance Method Details

#filter_vm(vm_hash) ⇒ Object



17
18
19
20
21
# File 'lib/config_builder/filter/boxes.rb', line 17

def filter_vm(vm_hash)
  if (box_name = vm_hash['box'])
    vm_hash['box_url'] ||= @boxes[box_name]
  end
end

#runObject



10
11
12
13
14
15
# File 'lib/config_builder/filter/boxes.rb', line 10

def run
  return @root_config if @root_config['vms'].nil?

  @root_config['vms'].each { |vm_hash| filter_vm(vm_hash) }
  @root_config
end

#set_config(root_config) ⇒ Object



5
6
7
8
# File 'lib/config_builder/filter/boxes.rb', line 5

def set_config(root_config)
  @root_config = root_config
  @boxes       = (@root_config.delete('boxes') || {})
end