]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
chucknorris: read gzip stream before passing it to YAML.load
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 20 Feb 2014 20:06:10 +0000 (21:06 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sat, 29 May 2021 14:21:46 +0000 (16:21 +0200)
Prevents errors about external_encoding not being defined for the gzip
stream in ruby 1.9+

data/rbot/plugins/chucknorris.rb

index 42385ff303a2b0a109835c5c7f2f002a05abf596..177eccfb08b44fcacf2545179570d3b25d7a78da 100644 (file)
@@ -19,7 +19,7 @@ class ChuckNorrisPlugin < Plugin
 
     debug "+ [chucknorris] Loading #{path}..."
 
-    @@facts = YAML.load(fyml).map{|fact,(score,votes)| votes >= MIN_VOTES ? [score,fact] : nil}.compact
+    @@facts = YAML.load(fyml.read).map{|fact,(score,votes)| votes >= MIN_VOTES ? [score,fact] : nil}.compact
     debug "+ [chucknorris] #{@@facts.length} Chuck Norris facts loaded..."
     debug "  Random fact: #{@@facts[rand(@@facts.size)].inspect}"