From: Giuseppe Bilotta Date: Fri, 6 Mar 2009 20:55:12 +0000 (+0100) Subject: load rubygems if available X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=00f2fa9d625b19d6c8b33c62ea41460924e43634;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git load rubygems if available 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. --- diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb index f9912ebb..c47601c1 100644 --- a/lib/rbot/core/utils/utils.rb +++ b/lib/rbot/core/utils/utils.rb @@ -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|p|div|html|body|table|td|tr)(?:\s+[^>]*)?\/?>/im end end - end end module ::Irc diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 6279cfe2..35fc2dfd 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -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'