Class: VagrantSpec::MachineData
- Inherits:
-
Object
- Object
- VagrantSpec::MachineData
- Defined in:
- lib/vagrant_spec/machine_data.rb
Overview
Handle machine data generation
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#env ⇒ Object
Returns the value of attribute env.
-
#m_finder ⇒ Object
Returns the value of attribute m_finder.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(env) ⇒ MachineData
constructor
A new instance of MachineData.
- #populate_data ⇒ Object
Constructor Details
#initialize(env) ⇒ MachineData
Returns a new instance of MachineData.
10 11 12 13 14 |
# File 'lib/vagrant_spec/machine_data.rb', line 10 def initialize(env) @env = env @m_finder = VagrantSpec::MachineFinder.new(@env) @data = [] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/vagrant_spec/machine_data.rb', line 9 def data @data end |
#env ⇒ Object
Returns the value of attribute env.
9 10 11 |
# File 'lib/vagrant_spec/machine_data.rb', line 9 def env @env end |
#m_finder ⇒ Object
Returns the value of attribute m_finder.
9 10 11 |
# File 'lib/vagrant_spec/machine_data.rb', line 9 def m_finder @m_finder end |
Instance Method Details
#generate ⇒ Object
16 17 18 19 |
# File 'lib/vagrant_spec/machine_data.rb', line 16 def generate populate_data IO.write('.vagrantspec_machine_data', JSON.pretty_generate(@data)) end |
#populate_data ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant_spec/machine_data.rb', line 21 def populate_data @m_finder.machines do |m| private_key = m.ssh_info[:private_key_path][0] @data << { name: m.name, host: m.ssh_info[:host], port: m.ssh_info[:port], username: m.ssh_info[:username], private_key: private_key } end end |