From: David Gadling Date: Thu, 21 May 2009 18:53:19 +0000 (-0700) Subject: multiple plugins: Changes to remove parenthesize warnings. X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=7f244f32d974cafa74f449853f940f194d08d6d2;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git multiple plugins: Changes to remove parenthesize warnings. 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. --- diff --git a/data/rbot/plugins/games/shiritori.rb b/data/rbot/plugins/games/shiritori.rb index 92f4dda4..3cb3c7b5 100644 --- a/data/rbot/plugins/games/shiritori.rb +++ b/data/rbot/plugins/games/shiritori.rb @@ -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" diff --git a/data/rbot/plugins/keywords.rb b/data/rbot/plugins/keywords.rb index 58fcfe9b..da320780 100644 --- a/data/rbot/plugins/keywords.rb +++ b/data/rbot/plugins/keywords.rb @@ -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 diff --git a/data/rbot/plugins/lart.rb b/data/rbot/plugins/lart.rb index 4c945889..aeaad733 100644 --- a/data/rbot/plugins/lart.rb +++ b/data/rbot/plugins/lart.rb @@ -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 diff --git a/data/rbot/plugins/quotes.rb b/data/rbot/plugins/quotes.rb index 59234e70..bb5ae57e 100644 --- a/data/rbot/plugins/quotes.rb +++ b/data/rbot/plugins/quotes.rb @@ -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}" } diff --git a/data/rbot/plugins/urban.rb b/data/rbot/plugins/urban.rb index 24c11dd7..6f052fcf 100644 --- a/data/rbot/plugins/urban.rb +++ b/data/rbot/plugins/urban.rb @@ -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{
.*? 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 diff --git a/lib/rbot/core/irclog.rb b/lib/rbot/core/irclog.rb index 40266772..f60bcbfa 100644 --- a/lib/rbot/core/irclog.rb +++ b/lib/rbot/core/irclog.rb @@ -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 diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 70be2a90..2825f7e6 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -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