From 28b48929dfeef26f41c582b972fb8884ea40269c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 22 Feb 2010 18:17:43 -0800 Subject: [PATCH] Changed box actions and commands to use the Box class instead of passed in params. --- lib/vagrant/actions/box/add.rb | 8 +----- lib/vagrant/actions/box/download.rb | 7 +---- lib/vagrant/box.rb | 15 +++++++++++ lib/vagrant/commands.rb | 2 +- test/vagrant/actions/box/download_test.rb | 8 +++++- test/vagrant/box_test.rb | 32 +++++++++++++++++++++++ test/vagrant/commands_test.rb | 2 +- 7 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 test/vagrant/box_test.rb diff --git a/lib/vagrant/actions/box/add.rb b/lib/vagrant/actions/box/add.rb index 1786834e6..b46ba2c3d 100644 --- a/lib/vagrant/actions/box/add.rb +++ b/lib/vagrant/actions/box/add.rb @@ -2,14 +2,8 @@ module Vagrant module Actions module Box class Add < Base - def initialize(runner, name, path, *args) - super - @name = name - @uri = path - end - def prepare - @runner.add_action(Download, @uri) + @runner.add_action(Download) end end end diff --git a/lib/vagrant/actions/box/download.rb b/lib/vagrant/actions/box/download.rb index 0fbaee608..4d394e00a 100644 --- a/lib/vagrant/actions/box/download.rb +++ b/lib/vagrant/actions/box/download.rb @@ -7,11 +7,6 @@ module Vagrant BASENAME = "box" BUFFERSIZE = 1048576 # 1 MB - def initialize(runner, uri, *args) - super - @uri = uri - end - def execute! with_tempfile do |tempfile| copy_uri_to(tempfile) @@ -27,7 +22,7 @@ module Vagrant def copy_uri_to(f) logger.info "Copying box to temporary location..." - open(@uri) do |remote_file| + open(@runner.uri) do |remote_file| loop do break if remote_file.eof? f.write(remote_file.read(BUFFERSIZE)) diff --git a/lib/vagrant/box.rb b/lib/vagrant/box.rb index bc38c0e79..3be3223e6 100644 --- a/lib/vagrant/box.rb +++ b/lib/vagrant/box.rb @@ -1,5 +1,20 @@ module Vagrant class Box < Actions::Runner + attr_accessor :name + attr_accessor :uri + attr_accessor :temp_path + class <