Class: Vagrant::Action::VM::CheckBox

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

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ CheckBox

Returns a new instance of CheckBox.



5
6
7
# File 'lib/vagrant/action/vm/check_box.rb', line 5

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

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant/action/vm/check_box.rb', line 9

def call(env)
  box_name = env["config"].vm.box
  raise Errors::BoxNotSpecified if !box_name

  if !env.env.boxes.find(box_name)
    box_url = env["config"].vm.box_url
    raise Errors::BoxSpecifiedDoesntExist, :name => box_name if !box_url

    env.ui.info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name)
    Vagrant::Box.add(env.env, box_name, box_url)
    env["boxes"].reload!
    env.env.reload_config!
  end

  @app.call(env)
end