Class: VagrantPlugins::Invade::InvadeModule::Vagrant::Machine

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from InvadeModule

#get_template_path

Constructor Details

#initialize(machine_name, machine_data, result: nil) ⇒ Machine

Returns a new instance of Machine.



11
12
13
14
15
# File 'lib/vagrant-invade/module/vagrant/machine/machine.rb', line 11

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

Instance Attribute Details

#machine_dataObject

Returns the value of attribute machine_data.



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

def machine_data
  @machine_data
end

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/vagrant-invade/module/vagrant/machine/machine.rb', line 8

def result
  @result
end

Instance Method Details

#buildObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-invade/module/vagrant/machine/machine.rb', line 17

def build
  b = binding

  begin

    # Machine name
    machine_name = @machine_name

    # Data to build machine entry
    vm = @machine_data['vm']
    network = @machine_data['network']
    ssh = @machine_data['ssh']
    provider = @machine_data['provider']
    synced_folder = @machine_data['synced_folder']
    plugin = @machine_data['plugin']
    provision = @machine_data['provision']
    nfs = @machine_data['nfs']

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