]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
load rubygems if available
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 6 Mar 2009 20:55:12 +0000 (21:55 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 6 Mar 2009 20:55:12 +0000 (21:55 +0100)
Try loading rubygems as soon as we're set up, since it can be needed for
gettext and a number of other things. This also allows us to get rid of
some stupid convoluted tricks in utils.

lib/rbot/core/utils/utils.rb
lib/rbot/ircbot.rb

index f9912ebb0b367b8e1e450b80b0e340644080ad44..c47601c1baf89386d0801fb5d5458670866e7e24 100644 (file)
@@ -16,15 +16,6 @@ require 'set'
 begin
   require 'htmlentities'
 rescue LoadError
-  gems = nil
-  begin
-    gems = require 'rubygems'
-  rescue LoadError
-    gems = false
-  end
-  if gems
-    retry
-  else
     module ::Irc
       module Utils
         UNESCAPE_TABLE = {
@@ -108,7 +99,6 @@ rescue LoadError
         }
       end
     end
-  end
 end
 
 begin
@@ -121,15 +111,6 @@ begin
     end
   end
 rescue LoadError
-  gems = nil
-  begin
-    gems = require 'rubygems'
-  rescue LoadError
-    gems = false
-  end
-  if gems
-    retry
-  else
     module ::Irc
       module Utils
         # Some regular expressions to manage HTML data
@@ -150,7 +131,6 @@ rescue LoadError
         AFTER_PAR2_REGEX = /<br(?:\s+[^>]*)?\/?>.*?<\/?(?:br|p|div|html|body|table|td|tr)(?:\s+[^>]*)?\/?>/im
       end
     end
-  end
 end
 
 module ::Irc
index 6279cfe2b9fb3c7872ced17372613e9efa38c2fa..35fc2dfd4ac128e548d0bb2ae42245048c2b950e 100644 (file)
@@ -135,6 +135,12 @@ $interrupted = 0
 
 # these first
 require 'rbot/rbotconfig'
+begin
+  require 'rubygems'
+rescue LoadError
+  log "rubygems unavailable"
+end
+
 require 'rbot/load-gettext'
 require 'rbot/config'
 require 'rbot/config-compat'