From aaac5fbf1e65af9d8c39ece92a79f939158f7ce1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 25 Aug 2010 23:21:23 -0700 Subject: [PATCH] Get rid of all Ruby warnings in Vagrant --- lib/vagrant/action/box/download.rb | 1 + lib/vagrant/active_list.rb | 3 ++- lib/vagrant/config.rb | 14 +++++++++----- lib/vagrant/environment.rb | 7 +++---- test/vagrant/action/general/package_test.rb | 2 +- test/vagrant/box_test.rb | 4 ++-- test/vagrant/config_test.rb | 2 ++ test/vagrant/environment_test.rb | 4 ++-- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/vagrant/action/box/download.rb b/lib/vagrant/action/box/download.rb index 66a4c2a5b..afd98bfb6 100644 --- a/lib/vagrant/action/box/download.rb +++ b/lib/vagrant/action/box/download.rb @@ -13,6 +13,7 @@ module Vagrant @env = env @env["download.classes"] ||= [] @env["download.classes"] += [Downloaders::HTTP, Downloaders::File] + @downloader = nil end def call(env) diff --git a/lib/vagrant/active_list.rb b/lib/vagrant/active_list.rb index 66874f4c9..e761bdb75 100644 --- a/lib/vagrant/active_list.rb +++ b/lib/vagrant/active_list.rb @@ -12,6 +12,7 @@ module Vagrant # Creates the instance of the ActiveList, with the given environment # if specified def initialize(env=nil) + @list = nil @env = env end @@ -80,4 +81,4 @@ module Vagrant File.join(env.home_path, FILENAME) end end -end \ No newline at end of file +end diff --git a/lib/vagrant/config.rb b/lib/vagrant/config.rb index 1d03aae71..7c357ef51 100644 --- a/lib/vagrant/config.rb +++ b/lib/vagrant/config.rb @@ -66,7 +66,7 @@ module Vagrant attr_accessor :forwarded_port_key attr_accessor :max_tries attr_accessor :timeout - attr_accessor :private_key_path + attr_writer :private_key_path attr_accessor :forward_agent # The attribute(s) below do nothing. They are just kept here to @@ -103,11 +103,11 @@ module Vagrant attr_reader :forwarded_ports attr_reader :shared_folders attr_reader :network_options - attr_accessor :hd_location + attr_reader :hd_location attr_accessor :disk_image_format attr_accessor :provisioner - attr_accessor :shared_folder_uid - attr_accessor :shared_folder_gid + attr_writer :shared_folder_uid + attr_writer :shared_folder_gid attr_accessor :system # Represents a SubVM. This class is only used here in the VMs @@ -197,9 +197,13 @@ module Vagrant class VagrantConfig < Base attr_accessor :dotfile_name attr_accessor :log_output - attr_accessor :home + attr_writer :home attr_accessor :host + def initialize + @home = nil + end + def home @home ? File.expand_path(@home) : nil end diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 425467ace..7003351b7 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -15,13 +15,12 @@ module Vagrant attr_reader :parent # Parent environment (in the case of multi-VMs) attr_reader :vm_name # The name of the VM (internal name) which this environment represents - attr_accessor :cwd + attr_writer :cwd attr_reader :root_path attr_reader :config attr_reader :host attr_reader :box attr_accessor :vm - attr_reader :vms attr_reader :active_list attr_reader :logger attr_reader :actions @@ -340,8 +339,8 @@ module Vagrant return parent.update_dotfile if parent # Generate and save the persisted VM info - data = vms.inject({}) do |acc, data| - key, value = data + data = vms.inject({}) do |acc, values| + key, value = values acc[key] = value.uuid if value.created? acc end diff --git a/test/vagrant/action/general/package_test.rb b/test/vagrant/action/general/package_test.rb index 71ab6b620..eba87c37b 100644 --- a/test/vagrant/action/general/package_test.rb +++ b/test/vagrant/action/general/package_test.rb @@ -37,7 +37,7 @@ class PackageGeneralActionTest < Test::Unit::TestCase assert_equal [], @env["package.include"] end - should "not set the output path if it is already set" do + should "not set the include path if it is already set" do @env["package.include"] = "foo" @klass.new(@app, @env) assert_equal "foo", @env["package.include"] diff --git a/test/vagrant/box_test.rb b/test/vagrant/box_test.rb index e30b43885..a5b5ae376 100644 --- a/test/vagrant/box_test.rb +++ b/test/vagrant/box_test.rb @@ -44,8 +44,8 @@ class BoxTest < Test::Unit::TestCase files = [true, false] Dir.expects(:open).yields(dir) dir_sequence = sequence("directory") - dir.each_with_index do |dir, index| - File.expects(:directory?).with(File.join(@boxes_path, dir)).returns(files[index]).in_sequence(dir_sequence) + dir.each_with_index do |value, index| + File.expects(:directory?).with(File.join(@boxes_path, value)).returns(files[index]).in_sequence(dir_sequence) end result = Vagrant::Box.all(@env) diff --git a/test/vagrant/config_test.rb b/test/vagrant/config_test.rb index 63ef22f46..2ec8c585f 100644 --- a/test/vagrant/config_test.rb +++ b/test/vagrant/config_test.rb @@ -240,6 +240,8 @@ class ConfigTest < Test::Unit::TestCase context "VM configuration" do setup do + @username = "mitchellh" + @env = mock_environment @config = @env.config.vm @env.config.ssh.username = @username diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index 34a0b5665..65403a4de 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -581,10 +581,10 @@ class EnvironmentTest < Test::Unit::TestCase should "blank the VMs" do @env = mock_environment do |config| - config.vm.define :foo do |config| + config.vm.define :foo do |foo_config| end - config.vm.define :bar do |config| + config.vm.define :bar do |bar_config| end end