Browse files

rescue/retry when loading gems (possibly without rubygems)

closes #901
  • Loading branch information...
1 parent 5e8c950 commit 62e1c092e0cdc0e6d57329ecd7a0c5b0cf93b1f9 @geemus geemus committed Dec 28, 2012
Showing with 19 additions and 3 deletions.
  1. +6 −1 lib/fog/libvirt/compute.rb
  2. +7 −1 lib/fog/virtual_box/compute.rb
  3. +6 −1 lib/fog/vmfusion/compute.rb
View
7 lib/fog/libvirt/compute.rb
@@ -82,7 +82,12 @@ def initialize(options={})
@ip_command = options[:libvirt_ip_command]
# libvirt is part of the gem => ruby-libvirt
- require 'libvirt'
+ begin
+ require 'libvirt'
+ rescue LoadError => e
+ retry if require('rubygems')
+ raise e.message
+ end
begin
if options[:libvirt_username] and options[:libvirt_password]
View
8 lib/fog/virtual_box/compute.rb
@@ -30,7 +30,13 @@ def initialize(options={})
class Real
def initialize(options={})
- require 'virtualbox'
+ begin
+ require 'virtualbox'
+ rescue LoadError => e
+ retry if require('rubygems')
+ raise e.message
+ end
+
@connection = ::VirtualBox::Global.global.lib.virtualbox
end
View
7 lib/fog/vmfusion/compute.rb
@@ -20,7 +20,12 @@ def initialize(options={})
class Real
def initialize(options={})
- require 'fission'
+ begin
+ require 'fission'
+ rescue LoadError => e
+ retry if require('rubygems')
+ raise e.message
+ end
end
end

0 comments on commit 62e1c09

Please sign in to comment.