Sha256: 43d7a836d66adf4fcef1454b0d3b56b8c339ab740abe2af55cc05cfec2ccbf1e
Contents?: true
Size: 718 Bytes
Versions: 2
Compression:
Stored size: 718 Bytes
Contents
# Provide a base class for syncing hosts entries on POSIX systems. class VagrantHosts::Cap::SyncHosts::POSIX < VagrantHosts::Cap::SyncHosts::Base private def upload_tmphosts cache = Tempfile.new('tmp-hosts') cache.write(format_hosts) cache.flush @machine.communicate.upload(cache.path, '/tmp/hosts') end def update_hosts upload_tmphosts @machine.communicate.sudo('install -m 644 /tmp/hosts /etc/hosts') end # Generates content appropriate for a linux hosts file # # @return [String] All hosts in the config joined into hosts records def format_hosts all_hosts.inject('') do |str, (address, aliases)| str << "#{address} #{aliases.join(' ')}\n" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-hosts-2.0.0 | lib/vagrant-hosts/cap/sync_hosts/posix.rb |
vagrant-hosts-2.0.0rc1 | lib/vagrant-hosts/cap/sync_hosts/posix.rb |