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.


10
11
12
# File 'lib/vagrant/action/general/package_setup_folders.rb', line 10

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

Instance Method Details

#call(env) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant/action/general/package_setup_folders.rb', line 14

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


28
29
30
31
32
33
# File 'lib/vagrant/action/general/package_setup_folders.rb', line 28

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