Class: VagrantPlugins::Hosts::BSD::Host
- Inherits:
-
Object
- Object
- VagrantPlugins::Hosts::BSD::Host
- Includes:
- Vagrant::Util
- Defined in:
- lib/vagrant-hosts/hosts/bsd/host.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Host
constructor
A new instance of Host.
- #remove_hosts_entry(name) ⇒ Object
- #update_hosts_entry(ip, name) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Host
Returns a new instance of Host.
20 21 22 |
# File 'lib/vagrant-hosts/hosts/bsd/host.rb', line 20 def initialize(*args) super end |
Class Method Details
.match? ⇒ Boolean
10 11 12 |
# File 'lib/vagrant-hosts/hosts/bsd/host.rb', line 10 def self.match? Vagrant::Util::Platform.darwin? || Vagrant::Util::Platform.bsd? end |
.precedence ⇒ Object
14 15 16 17 18 |
# File 'lib/vagrant-hosts/hosts/bsd/host.rb', line 14 def self.precedence # Set a lower precedence, since we're supposed to override # Vagrant's built-in BSD Host, but don't implement everything 3 end |
Instance Method Details
#remove_hosts_entry(name) ⇒ Object
30 31 32 33 |
# File 'lib/vagrant-hosts/hosts/bsd/host.rb', line 30 def remove_hosts_entry(name) `cat /etc/hosts | grep -v '#{name} \#VAGRANTHOSTS$' >/tmp/hosts.tmp` `sudo mv /tmp/hosts.tmp /etc/hosts` end |
#update_hosts_entry(ip, name) ⇒ Object
24 25 26 27 28 |
# File 'lib/vagrant-hosts/hosts/bsd/host.rb', line 24 def update_hosts_entry(ip, name) `cat /etc/hosts | grep -v '#{name} \#VAGRANTHOSTS$' >/tmp/hosts.tmp` `sudo mv /tmp/hosts.tmp /etc/hosts` `sudo echo '#{ip} #{name} \#VAGRANTHOSTS' >>/etc/hosts` end |