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
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vagrant/action/box/unpackage.rb', line 48 def decompress Dir.chdir(@env["box_directory"]) do @env[:ui].info I18n.t("vagrant.actions.box.unpackage.extracting") begin Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box_directory"].to_s) rescue SystemCallError raise Errors::BoxUnpackageFailure end 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 45 46 |
# File 'lib/vagrant/action/box/unpackage.rb', line 39 def setup_box_directory if File.directory?(@env["box_directory"]) raise Errors::BoxAlreadyExists, :name => @env["box_name"] end FileUtils.mkdir_p(@env["box_directory"]) @box_directory = @env["box_directory"] end |