]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
gettext: support anonymous modules (and thus plugins) with newer gettext
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 16 Apr 2008 21:49:41 +0000 (23:49 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 16 Apr 2008 21:49:41 +0000 (23:49 +0200)
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.

lib/rbot/load-gettext.rb

index 5738f19726fd069293cb8a970d4477f4f1b0f607..4d39b7e48fc6070f6c7e1394b1d2a5643a5ac8ed 100644 (file)
@@ -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'