Class: BarkingIguana::Compound::Vagrant
- Inherits:
-
Object
- Object
- BarkingIguana::Compound::Vagrant
- Extended by:
- Forwardable
- Includes:
- Benchmark, Logging::Helper
- Defined in:
- lib/barking_iguana/compound/vagrant.rb
Instance Method Summary collapse
- #assign_ip_addresses ⇒ Object
-
#initialize(manager, options = {}) ⇒ Vagrant
constructor
A new instance of Vagrant.
- #prepare ⇒ Object
- #refresh_status ⇒ Object
- #vagrant_file_content ⇒ Object
- #vagrant_file_path ⇒ Object
- #vagrant_file_template ⇒ Object
- #write_vagrant_file ⇒ Object
Constructor Details
#initialize(manager, options = {}) ⇒ Vagrant
Returns a new instance of Vagrant.
17 18 19 20 21 22 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 17 def initialize manager, = {} self.manager = manager self.vagrant_file_template_path = [:vagrant_file_template_path] || File.('../../../../resources/Vagrantfile.erb', __FILE__) self.root = [:root] || Dir.pwd self.environment = [:environment] || {} end |
Instance Method Details
#assign_ip_addresses ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 56 def assign_ip_addresses hosts.each do |h| next if valid_ip_address? h.ip_address ip_address = next_available_ip_address logger.debug { "Assigning #{h.name} an IP address: #{ip_address}" } h.assign_ip_address ip_address end end |
#prepare ⇒ Object
65 66 67 68 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 65 def prepare assign_ip_addresses write_vagrant_file end |
#refresh_status ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 82 def refresh_status current_status = status.split(/\n/) hosts.each do |host| current_status.each do |line| if line =~ /^#{host.name}\b/ host.state = line.sub(host.name, '').sub('(virtualbox)', '').strip end end end end |
#vagrant_file_content ⇒ Object
70 71 72 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 70 def vagrant_file_content ERB.new(vagrant_file_template).result binding end |
#vagrant_file_path ⇒ Object
78 79 80 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 78 def vagrant_file_path File.join root, 'Vagrantfile' end |
#vagrant_file_template ⇒ Object
74 75 76 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 74 def vagrant_file_template File.read vagrant_file_template_path end |
#write_vagrant_file ⇒ Object
49 50 51 52 53 54 |
# File 'lib/barking_iguana/compound/vagrant.rb', line 49 def write_vagrant_file logger.debug { "Writing Vagrantfile to #{vagrant_file_path}" } File.open vagrant_file_path, 'w' do |f| f.puts vagrant_file_content end end |