Class: Vagrant::Box
- Inherits:
-
Object
- Object
- Vagrant::Box
- Defined in:
- lib/vagrant/box.rb
Overview
Represents a "box," which is simply a packaged vagrant environment.
Boxes are simply tar
files which contain an exported VirtualBox
virtual machine, at the least. They are created with vagrant package
and may contain additional files if specified by the creator. This
class serves to help manage these boxes, although most of the logic
is kicked out to middlewares.
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
The directory where this box is stored.
-
#name ⇒ Object
readonly
The name of the box.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Implemented for comparison with other boxes.
-
#destroy ⇒ Object
Begins the process of destroying this box.
-
#initialize(name, directory, action_runner) ⇒ Box
constructor
Creates a new box instance.
-
#repackage(options = nil) ⇒ Object
Begins sequence to repackage this box.
Constructor Details
#initialize(name, directory, action_runner) ⇒ Box
Creates a new box instance. Given an optional name
parameter,
newly created instance will have that name, otherwise it defaults
to nil
.
Note: This method does not actually create the box, but merely returns a new, abstract representation of it. To add a box, see #add.
21 22 23 24 25 |
# File 'lib/vagrant/box.rb', line 21 def initialize(name, directory, action_runner) @name = name @directory = directory @action_runner = action_runner end |
Instance Attribute Details
#directory ⇒ Object (readonly)
The directory where this box is stored
13 14 15 |
# File 'lib/vagrant/box.rb', line 13 def directory @directory end |
#name ⇒ Object (readonly)
The name of the box.
10 11 12 |
# File 'lib/vagrant/box.rb', line 10 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
Implemented for comparison with other boxes. Comparison is implemented by simply comparing name.
39 40 41 42 |
# File 'lib/vagrant/box.rb', line 39 def <=>(other) return super if !other.is_a?(self.class) name <=> other.name end |
#destroy ⇒ Object
Begins the process of destroying this box. This cannot be undone!
28 29 30 |
# File 'lib/vagrant/box.rb', line 28 def destroy @action_runner.run(:box_remove, { :box_name => @name, :box_directory => @directory }) end |
#repackage(options = nil) ⇒ Object
Begins sequence to repackage this box.
33 34 35 |
# File 'lib/vagrant/box.rb', line 33 def repackage(=nil) @action_runner.run(:box_repackage, { :box_name => @name, :box_directory => @directory }) end |