Class: VagrantPlugins::Invade::InvadeModule::Plugin::Hostmanager

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from InvadeModule

#get_template_path

Constructor Details

#initialize(machine_name, hostmanager_data, result: nil) ⇒ Hostmanager

Returns a new instance of Hostmanager.



13
14
15
16
17
# File 'lib/vagrant-invade/module/plugin/hostmanager/hostmanager.rb', line 13

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

Instance Attribute Details

#hostmanager_dataObject

Returns the value of attribute hostmanager_data.



11
12
13
# File 'lib/vagrant-invade/module/plugin/hostmanager/hostmanager.rb', line 11

def hostmanager_data
  @hostmanager_data
end

#machine_nameObject

Returns the value of attribute machine_name.



11
12
13
# File 'lib/vagrant-invade/module/plugin/hostmanager/hostmanager.rb', line 11

def machine_name
  @machine_name
end

#resultObject (readonly)

Returns the value of attribute result.



10
11
12
# File 'lib/vagrant-invade/module/plugin/hostmanager/hostmanager.rb', line 10

def result
  @result
end

#uiObject

Returns the value of attribute ui.



11
12
13
# File 'lib/vagrant-invade/module/plugin/hostmanager/hostmanager.rb', line 11

def ui
  @ui
end

Instance Method Details

#buildObject



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

def build

  b = binding

  begin

    # Get machine name
    machine_name = @machine_name

    # Values for hostmanager section
    enabled = @hostmanager_data['enabled']
    aliases = @hostmanager_data['aliases']

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