From: Giuseppe Bilotta Date: Wed, 16 Apr 2008 21:49:41 +0000 (+0200) Subject: gettext: support anonymous modules (and thus plugins) with newer gettext X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=b371854ac64eab8601b4a013e7ab5dd0c5db9ef5;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git gettext: support anonymous modules (and thus plugins) with newer gettext While older ruby-gettext raised when trying to bind for anonymous modules (such as the ones that wrap rbot plugins), newer versions just provide an empty array. This makes the previous fix (which used rescue) ineffective. Solve by rescuing with [] (so that older gettext behaves like the new one) and then adding Object if the list is indeed empty. --- diff --git a/lib/rbot/load-gettext.rb b/lib/rbot/load-gettext.rb index 5738f197..4d39b7e4 100644 --- a/lib/rbot/load-gettext.rb +++ b/lib/rbot/load-gettext.rb @@ -34,7 +34,8 @@ begin alias :orig_bound_targets :bound_targets end def bound_targets(*a) # :nodoc: - orig_bound_targets(*a) rescue orig_bound_targets(Object) + bt = orig_bound_targets(*a) rescue [] + bt.empty? ? orig_bound_targets(Object) : bt end require 'stringio'