diff --git a/lib/vagrant/box.rb b/lib/vagrant/box.rb index f6ba478ad..3c1924b54 100644 --- a/lib/vagrant/box.rb +++ b/lib/vagrant/box.rb @@ -12,24 +12,8 @@ module Vagrant # The URI for a new box. This is not available for existing boxes. attr_accessor :uri - # The environment which this box belongs to. Although this could - # actually be many environments, this points to the environment - # of a specific instance. - attr_reader :env - - class << self - # Adds a new box with given name from the given URI. This method - # begins the process of adding a box from a given URI by setting up - # the {Box} instance and calling {#add}. - # - # @param [String] name The name of the box - # @param [String] uri URI to the box file - def add(env, name, uri) - box = new(env, name) - box.uri = uri - box.add - end - end + # The directory where this box is stored + attr_reader :directory # Creates a new box instance. Given an optional `name` parameter, # newly created instance will have that name, otherwise it defaults @@ -37,9 +21,9 @@ module Vagrant # # **Note:** This method does not actually _create_ the box, but merely # returns a new, abstract representation of it. To add a box, see {#add}. - def initialize(env=nil, name=nil) - @name = name - @env = env + def initialize(name, directory) + @name = name + @directory = directory end # Returns path to the OVF file of the box. The OVF file is an open @@ -71,15 +55,6 @@ module Vagrant env.actions.run(:box_repackage, { "box" => self, "validate" => false }.merge(options || {})) end - # Returns the directory to the location of this boxes content in the local - # filesystem. Note that if the box isn't imported yet, then the path may not - # yet exist, but still represents where the box will be imported to. - # - # @return [String] - def directory - env.boxes_path.join(name) - end - # Implemented for comparison with other boxes. Comparison is implemented # by simply comparing name. def <=>(other) diff --git a/lib/vagrant/box_collection.rb b/lib/vagrant/box_collection.rb index dc3198d66..9bd871ec3 100644 --- a/lib/vagrant/box_collection.rb +++ b/lib/vagrant/box_collection.rb @@ -2,15 +2,7 @@ require 'forwardable' module Vagrant # Represents a collection of boxes, providing helpful methods for - # finding boxes. An instance of this is returned by {Environment#boxes}. - # - # # Finding a Box - # - # To find a box, use the {#find} method with the name of the box. The name - # is an exact match search. - # - # env.boxes.find("base") # => # - # + # finding boxes. class BoxCollection include Enumerable extend Forwardable @@ -45,8 +37,7 @@ module Vagrant Dir.open(@directory) do |dir| dir.each do |d| next if d == "." || d == ".." || !@directory.join(d).directory? - # TODO: env???? - @boxes << Box.new(env, d) + @boxes << Box.new(d, @directory.join(d)) end end end