]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
multiple plugins: Changes to remove parenthesize warnings.
authorDavid Gadling <dave@toasterwaffles.com>
Thu, 21 May 2009 18:53:19 +0000 (11:53 -0700)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 21 May 2009 20:09:28 +0000 (22:09 +0200)
All of these modules/plugins were generating warnings like this:
  warning: parenthesize argument(s) for future version
This patch should fix all the warnings without affecting functionality.

data/rbot/plugins/games/shiritori.rb
data/rbot/plugins/keywords.rb
data/rbot/plugins/lart.rb
data/rbot/plugins/quotes.rb
data/rbot/plugins/urban.rb
lib/rbot/core/irclog.rb
lib/rbot/ircbot.rb

index 92f4dda4c7068e0d02c0de33066b67d50edc5119..3cb3c7b5c3056e7f68e273142043f86b6451b46b 100644 (file)
@@ -390,7 +390,7 @@ class ShiritoriPlugin < Plugin
       if ruleset.has_key?(:wordlist_file)
         begin
           ruleset[:words] =
-            File.new(datafile ruleset[:wordlist_file]).grep(
+            File.new(datafile(ruleset[:wordlist_file])).grep(
               ruleset[:listen]) {|l| ruleset[:normalize].call l.chomp}
         rescue
           raise "unable to load word list"
index 58fcfe9b112d388052616e94976421e86cb839f9..da32078096152ccc33fe71f6064eb48fe0764a83 100644 (file)
@@ -138,7 +138,7 @@ class Keywords < Plugin
   # have been added
   def scan
     # first scan for old DBHash files, and convert them
-    Dir[datafile '*'].each {|f|
+    Dir[datafile('*')].each {|f|
       next unless f =~ /\.db$/
       log "upgrading keyword db #{f} (rbot 0.9.5 or prior) database format"
       newname = f.gsub(/\.db$/, ".kdb")
@@ -153,7 +153,7 @@ class Keywords < Plugin
     }
 
     # then scan for current DBTree files, and load them
-    Dir[@bot.path 'keywords', '*'].each {|f|
+    Dir[@bot.path('keywords', '*')].each {|f|
       next unless f =~ /\.kdb$/
       hsh = DBTree.new @bot, f, true
       key = File.basename(f).gsub(/\.kdb$/, "")
@@ -162,7 +162,7 @@ class Keywords < Plugin
     }
 
     # then scan for non DB files, and convert/import them and delete
-    Dir[@bot.path 'keywords', '*'].each {|f|
+    Dir[@bot.path('keywords', '*')].each {|f|
       next if f =~ /\.kdb$/
       next if f =~ /CVS$/
       log "auto converting keywords from #{f}"
@@ -202,7 +202,7 @@ class Keywords < Plugin
       File.rename(olds, olds + ".old")
     end
 
-    olds.replace(@bot.path 'keyword.db')
+    olds.replace(@bot.path('keyword.db'))
     if File.exist? olds
       log "upgrading old keywords (rbot 0.9.9 or prior) database format"
       old = BDB::CIBtree.open olds, nil, "r+", 0600
@@ -221,7 +221,7 @@ class Keywords < Plugin
   end
 
   def oldsave
-    File.open(@bot.path "keywords.rbot", "w") do |file|
+    File.open(@bot.path("keywords.rbot"), "w") do |file|
       @keywords.each do |key, value|
         file.puts "#{key}<=#{value.type}=>#{value.dump}"
       end
index 4c9458891b96c3ecc1ba291337da4bf93b26a28f..aeaad7333246153b731d6e613f1e60ac0ba1d32a 100644 (file)
@@ -45,8 +45,8 @@ class LartPlugin < Plugin
       @oldpraise = datafile 'praise'
     end
 
-    @lartfile.replace(datafile "larts-#{lang}")
-    @praisefile.replace(datafile "praises-#{lang}")
+    @lartfile.replace(datafile("larts-#{lang}"))
+    @praisefile.replace(datafile("praises-#{lang}"))
     @larts.clear
     @praises.clear
     if File.exists? @lartfile
index 59234e705a4b289a7e4ab98ad10c19f37a2903aa..bb5ae57e04e4cc2bbeba8a57225d4f20b917e355 100644 (file)
@@ -16,7 +16,7 @@ class QuotePlugin < Plugin
     super
     @lists = Hash.new
     @changed = Hash.new
-    Dir[datafile '*'].each {|f|
+    Dir[datafile('*')].each {|f|
       next if File.directory?(f)
       channel = File.basename(f)
       @lists[channel] = Array.new if(!@lists.has_key?(channel))
@@ -36,7 +36,7 @@ class QuotePlugin < Plugin
       begin
         if @changed[channel]
           debug "Writing new quotefile for channel #{channel} ..."
-          Utils.safe_save(datafile channel) {|file|
+          Utils.safe_save(datafile(channel)) {|file|
             quotes.compact.each {|q|
               file.puts "#{q.num} | #{q.date} | #{q.source} | #{q.quote}"
             }
index 24c11dd7f3167272225e417ad3abcf88e4247bc6..6f052fcf9d92d907f066ad942a0cc869993d760d 100644 (file)
@@ -17,7 +17,7 @@ class UrbanPlugin < Plugin
     u = URBAN + URI.escape(word)
     u += '&page=' + p.to_s if p > 1
     s = @bot.httputil.get(u)
-    return m.reply "Couldn't get the urban dictionary definition for #{word}" if s.nil?
+    return m.reply("Couldn't get the urban dictionary definition for #{word}") if s.nil?
 
     notfound = s.match %r{<div style="color: #669FCE"><i>.*?</i> isn't defined}
 
@@ -48,7 +48,7 @@ class UrbanPlugin < Plugin
       resp = @bot.httputil.head('http://www.urbandictionary.com/random.php',
                                :max_redir => -1,
                                :cache => false)
-      return m.reply "Couldn't get a random urban dictionary word" if resp.nil?
+      return m.reply("Couldn't get a random urban dictionary word") if resp.nil?
       if resp.code == "302" && (loc = resp['location'])
         words = URI.unescape(loc.match(/define.php\?term=(.*)$/)[1]) rescue nil
       end
index 40266772c70cc6d8cf2e538da546cc60c9a99f5d..f60bcbfaddb1805ea9a270724912c0d1ed69dd00 100644 (file)
@@ -47,7 +47,7 @@ class IrcLogModule < CoreBotModule
   end
 
   def timestamp(time)
-    return time.strftime @bot.config['irclog.timestamp_format']
+    return time.strftime(@bot.config['irclog.timestamp_format'])
   end
 
   def event_irclog_list_changed(nolist, dolist)
@@ -289,7 +289,7 @@ class IrcLogModule < CoreBotModule
           # If it's a file, we rename to filename.old.filedate
           up = dir.dup
           until File.exist? up
-            up.replace File.dirname up
+            up.replace(File.dirname(up))
           end
           unless File.directory? up
             backup = up.dup
index 70be2a901648a45f8fa720b3ec1d3b57903ddba9..2825f7e6092a0b3804e962206b3b9a23eb44304f 100644 (file)
@@ -789,7 +789,7 @@ class Bot
       missing = Dir.chdir(template_dir) { Dir.glob('*/**') } - Dir.chdir(@botclass) { Dir.glob('*/**') }
       missing.map do |f|
         dest = File.join(@botclass, f)
-        FileUtils.mkdir_p(File.dirname dest)
+        FileUtils.mkdir_p(File.dirname(dest))
         FileUtils.cp File.join(template_dir, f), dest
       end
     else