Class: VagrantPlugins::Invade::InvadeModule::Vm

Inherits:
InvadeModule show all
Defined in:
lib/vagrant-invade/module/vm/vm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from InvadeModule

#get_template_path

Constructor Details

#initialize(machine_name, vm_data, result: nil) ⇒ Vm

Returns a new instance of Vm.



9
10
11
12
13
# File 'lib/vagrant-invade/module/vm/vm.rb', line 9

def initialize(machine_name, vm_data, result: nil)
  @machine_name = machine_name
  @vm_data  = vm_data
  @result   = result
end

Instance Attribute Details

#machine_nameObject

Returns the value of attribute machine_name.



7
8
9
# File 'lib/vagrant-invade/module/vm/vm.rb', line 7

def machine_name
  @machine_name
end

#resultObject (readonly)

Returns the value of attribute result.



6
7
8
# File 'lib/vagrant-invade/module/vm/vm.rb', line 6

def result
  @result
end

#vm_dataObject

Returns the value of attribute vm_data.



7
8
9
# File 'lib/vagrant-invade/module/vm/vm.rb', line 7

def vm_data
  @vm_data
end

Instance Method Details

#buildObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-invade/module/vm/vm.rb', line 15

def build
  b = binding

  begin

    # Get machine name
    machine_name = @machine_name

    # Values for vm section
    box  = @vm_data['box']
    url   = @vm_data['url']
    hostname = @vm_data['hostname']

    eruby = Erubis::Eruby.new(File.read(self.get_template_path(__FILE__)))
    @result = eruby.result b
  rescue TypeError, SyntaxError, SystemCallError => e
    raise(e)
  end
end