Skip to content

Commit

Permalink
Merge pull request jedi4ever#719 from Aigeruth/issue_locate-vboxmanage
Browse files Browse the repository at this point in the history
Adds new 'determine_vboxcmd' method.
  • Loading branch information
jedi4ever committed Jun 11, 2013
2 parents fdd0712 + 8c16b7d commit 291db2b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
24 changes: 19 additions & 5 deletions lib/veewee/provider/virtualbox/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
require 'veewee/provider/virtualbox/box/helper/console_type'
require 'veewee/provider/virtualbox/box/up'

require 'whichr'

module Veewee
module Provider
module Virtualbox
Expand All @@ -30,15 +32,27 @@ class Box < Veewee::Provider::Core::Box
include ::Veewee::Provider::Virtualbox::BoxCommand

def initialize(name,env)
@vboxcmd = self.class.determine_vboxcmd
super(name, env)
end

#require 'virtualbox'
@vboxcmd=determine_vboxcmd
super(name,env)
def self.windows_vboxcmd
# based on Vagrant/plugins/providers/virtualbox/driver/base.rb
if OS.windows? && ENV.has_key?("VBOX_INSTALL_PATH")
ENV["VBOX_INSTALL_PATH"].split(File::PATH_SEPARATOR).each do |path|
vboxmanage = File.join(path,"VBoxManage.exe")
return "\"#{vboxmanage}\"" if File.file?(vboxmanage)
end
end
nil
end

def self.default_vboxcmd
"VBoxManage"
end

def determine_vboxcmd
return "VBoxManage"
def self.determine_vboxcmd
@command ||= windows_vboxcmd || default_vboxcmd
end


Expand Down
4 changes: 3 additions & 1 deletion lib/veewee/provider/virtualbox/provider.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'veewee/provider/core/provider'
require 'veewee/provider/virtualbox/box'

module Veewee
module Provider
Expand All @@ -8,7 +9,8 @@ class Provider < Veewee::Provider::Core::Provider
# include ::Veewee::Provider::Virtualbox::ProviderCommand

def check_requirements
unless self.shell_exec("VBoxManage -v").status == 0
command = Box.determine_vboxcmd
unless self.shell_exec("#{command} -v").status == 0
raise Veewee::Error,"Could not execute VBoxManage command. Please install Virtualbox or make sure VBoxManage is in the Path"
end
end
Expand Down
1 change: 1 addition & 0 deletions veewee.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Gem::Specification.new do |s|
s.add_dependency "childprocess"
s.add_dependency "grit"
s.add_dependency "fission", "0.4.0"
s.add_dependency "whichr"

# Modified dependency version, as libxml-ruby dependency has been removed in version 2.1.1
# See : https://github.com/ckruse/CFPropertyList/issues/14
Expand Down

0 comments on commit 291db2b

Please sign in to comment.