From 6a2619be02efb1e68783ddce5b49fdc7e9db1d6b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 29 Jan 2010 20:22:50 -0800 Subject: [PATCH] Goodbye virtual_box.rb, hello virtualbox gem --- Gemfile | 4 ++- lib/hobo.rb | 1 - lib/hobo/virtual_box.rb | 60 ----------------------------------- test/hobo/virtual_box_test.rb | 46 --------------------------- 4 files changed, 3 insertions(+), 108 deletions(-) delete mode 100644 lib/hobo/virtual_box.rb delete mode 100644 test/hobo/virtual_box_test.rb diff --git a/Gemfile b/Gemfile index 3c9d250c4..8b8d7bca2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,9 @@ # Gems required for the lib to even run +gem "virtualbox", ">= 0.4.0" gem "net-ssh", ">= 2.0.19" -gem "jashmenn-git-style-binaries", ">= 0.1.10" + source "http://gems.github.com" +gem "jashmenn-git-style-binaries", ">= 0.1.10" # Gems required for testing only. To install run # gem bundle test diff --git a/lib/hobo.rb b/lib/hobo.rb index 7f0921558..87a6afd66 100644 --- a/lib/hobo.rb +++ b/lib/hobo.rb @@ -7,7 +7,6 @@ require 'ftools' require 'logger' require 'hobo/config' require 'hobo/env' -require 'hobo/virtual_box' require 'hobo/ssh' # TODO: Make this configurable diff --git a/lib/hobo/virtual_box.rb b/lib/hobo/virtual_box.rb deleted file mode 100644 index 7e9840449..000000000 --- a/lib/hobo/virtual_box.rb +++ /dev/null @@ -1,60 +0,0 @@ -class VirtualBox - class <= 1 - HOBO_LOGGER.error "VBoxManage command failed: #{cmd}" - # TODO: Raise error here that other commands can catch? - raise Exception.new("Failure: #{result}") - end - - return result - end - - # Parses the key value pairs from the VBoxManage key=value pair - # format and returns as a Ruby Hash - def parse_kv_pairs(raw) - parsed = {} - - raw.lines.each do |line| - # Some lines aren't configuration, we just ignore them - next unless line =~ /^"?(.+?)"?="?(.+?)"?$/ - - parsed[$1] = $2.strip - end - - parsed - end - end -end diff --git a/test/hobo/virtual_box_test.rb b/test/hobo/virtual_box_test.rb deleted file mode 100644 index 884d8d2f3..000000000 --- a/test/hobo/virtual_box_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -require File.join(File.dirname(__FILE__), '..', 'test_helper') - -class VirtualBoxTest < Test::Unit::TestCase - setup do - # Stub out command so nothing actually happens - VirtualBox.stubs(:command) - end - - context "parsing key value pairs" do - should "not parse the lines which don't contain key value pairs" do - result = VirtualBox.parse_kv_pairs("I'm not a key value pair") - assert result.empty? - end - - should "parse the lines which contain key value pairs" do - result = VirtualBox.parse_kv_pairs("foo=bar") - assert_equal 1, result.length - assert_equal "bar", result["foo"] - end - - should "ignore surrounding double quotes on keys and values" do - result = VirtualBox.parse_kv_pairs('"foo"="a value"') - assert_equal 1, result.length - assert_equal "a value", result["foo"] - end - - should "trim the values" do - result = VirtualBox.parse_kv_pairs("foo=bar ") - assert_equal 1, result.length - assert_equal "bar", result["foo"] - end - - should "parse multiple lines" do - result = VirtualBox.parse_kv_pairs(<<-raw) -This is some header - -foo=bar -"bar"=baz -raw - - assert_equal 2, result.length - assert_equal "bar", result["foo"] - assert_equal "baz", result["bar"] - end - end -end