Class: Vagrant::Action::General::PackageSetupFolders

Inherits:
Object
  • Object
show all
Includes:
Util::Presence
Defined in:
lib/vagrant/action/general/package_setup_folders.rb

Instance Method Summary collapse

Methods included from Util::Presence

#presence, #present?

Constructor Details

#initialize(app, env) ⇒ PackageSetupFolders

Returns a new instance of PackageSetupFolders.



13
14
15
# File 'lib/vagrant/action/general/package_setup_folders.rb', line 13

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

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant/action/general/package_setup_folders.rb', line 17

def call(env)
  env["package.output"] ||= "package.box"
  env["package.directory"] ||= Dir.mktmpdir("vagrant-package-", env[:tmp_path])

  # Match up a couple environmental variables so that the other parts of
  # Vagrant will do the right thing.
  env["export.temp_dir"] = env["package.directory"]

  Vagrant::Action::General::Package.validate!(
      env["package.output"], env["package.directory"])

  @app.call(env)
end

#recover(env) ⇒ Object



31
32
33
34
35
36
# File 'lib/vagrant/action/general/package_setup_folders.rb', line 31

def recover(env)
  dir = env["package.directory"]
  if File.exist?(dir)
    FileUtils.rm_rf(dir)
  end
end