Class: Vagrant::Action::Box::Unpackage
- Inherits:
-
Object
- Object
- Vagrant::Action::Box::Unpackage
- Defined in:
- lib/vagrant/action/box/unpackage.rb
Overview
Instance Attribute Summary collapse
-
#box_directory ⇒ Object
readonly
Returns the value of attribute box_directory.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #decompress ⇒ Object
-
#initialize(app, env) ⇒ Unpackage
constructor
A new instance of Unpackage.
- #recover(env) ⇒ Object
- #setup_box_directory ⇒ Object
Constructor Details
#initialize(app, env) ⇒ Unpackage
Returns a new instance of Unpackage.
19 20 21 22 |
# File 'lib/vagrant/action/box/unpackage.rb', line 19 def initialize(app, env) @app = app @env = env end |
Instance Attribute Details
#box_directory ⇒ Object (readonly)
Returns the value of attribute box_directory.
17 18 19 |
# File 'lib/vagrant/action/box/unpackage.rb', line 17 def box_directory @box_directory end |
Instance Method Details
#call(env) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/vagrant/action/box/unpackage.rb', line 24 def call(env) @env = env setup_box_directory decompress @app.call(@env) end |
#decompress ⇒ Object
46 47 48 49 50 51 |
# File 'lib/vagrant/action/box/unpackage.rb', line 46 def decompress Dir.chdir(@env["box"].directory) do @env.ui.info I18n.t("vagrant.actions.box.unpackage.extracting") Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box"].directory.to_s) end end |
#recover(env) ⇒ Object
33 34 35 36 37 |
# File 'lib/vagrant/action/box/unpackage.rb', line 33 def recover(env) if box_directory && File.directory?(box_directory) FileUtils.rm_rf(box_directory) end end |
#setup_box_directory ⇒ Object
39 40 41 42 43 44 |
# File 'lib/vagrant/action/box/unpackage.rb', line 39 def setup_box_directory raise Errors::BoxAlreadyExists, :name => @env["box"].name if File.directory?(@env["box"].directory) FileUtils.mkdir_p(@env["box"].directory) @box_directory = @env["box"].directory end |