4 # :title: 'ri' -- ruby documentation plugin
6 # Author: Michael Brailsford <brailsmt@yahoo.com> aka brailsmt
7 # Author:: dmitry kim <dmitry dot kim at gmail dot com>
8 # Copyright:: (C) 2007, dmitry kim
9 # Copyright:: (C) Michael Brailsford
13 class RiPlugin < Plugin
15 RI_COMMAND = %w{ri -f simple -T}
17 BotConfig.register BotConfigIntegerValue.new('ri.max_length',
19 :desc => "Maximum length of ri entry (in bytes) which is ok to be sent to channels")
21 def help(plugin, topic="")
22 "ri <something> => returns ruby documentation for <something>"
27 if a = params[:something]
36 ret = Utils.safe_exec(*args)
38 ret = "failed to execute ri"
40 ret = ret.gsub(/\t/, " ").split(/\n/).join(" ").gsub(/\s\s+/, ' ')
42 if ret.length > @bot.config['ri.max_length'] && !m.private?
43 ret = 'entry is too long to send to the channel, use /msg to ask me about it'
51 plugin.map 'ri :something', :requirements => {:something => /^((-c)|(\w\S+))$/}