Class: Vagrant::Butter::Action::VM::SetHostName

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/butter/action/vm/set_host_name.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ SetHostName

Returns a new instance of SetHostName.



8
9
10
# File 'lib/vagrant/butter/action/vm/set_host_name.rb', line 8

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/vagrant/butter/action/vm/set_host_name.rb', line 12

def call(env)
  if env[:vm].config.vm.host_name.nil?
    host = File.basename(env[:vm].env.root_path).gsub(/_/, '-')
    env[:vm].config.vm.host_name = "#{host}.vagrantup.com"
  end

  @app.call(env)
end