Friday 2 May 2008

Rorbby #rubyonrails api bot



An irc bot written in ruby to fuzzy search every method in the combined ruby and rails docs, returning definition, example and tinyurl (and currently working pretty well under ruby 1.9 without a database).

basic usage:

?api_method:args:args:args [nick]
??faq_keyword [nick]

You can also query rorbby via private message (although faq topics can only be defined in open channel)

Populating the faq

if the phrase begins with the keyword:

03:05 <@brough> rorbby, select is broken.
03:05 <@brough> ??select
03:05 <@rorbby> select is broken.

alternatively, define the keyword first:

03:11 <@brough> rorbby, scaling: Rails can instantaneously project solid matter to any point on the internet, in any shape or color you might imagine. For *any* purpose! Creation by mere thought. (Question about the 8,000 cubic miles of klystron relays? See: scaling_performance)
03:11 <@brough> ??scaling
03:11 <@rorbby> Rails can instantaneously project solid matter to any point on the internet, in any shape or color you might imagine. For *any* purpose! Creation by mere thought. (Question about the 8,000 cubic miles of klystron relays? See: scaling_performance)


to overwrite an existing definition, append a splat:


03:12 <@brough> rorbby, select is fixed. *
03:12 <@brough> ??select
03:12 <@rorrby> select is fixed.

FAQ definitions can be created as an array:

05:17 <> ??vps
05:18 <> rorbby, vps: <<> rorbby, vps: <<> ??vps
05:18 <> slicehost.com, bytemark.co.uk, linode.com

You can remove items from the list with '>>'

API definitions (for Rails api queries just omit the first ':ruby' param)

for example, targeting the following methods in the ruby api:


alive? (Thread)
alive? (DRb::DRbTCPSocket)
alive? (DRb::ExtServ)
alive? (Rinda::TupleEntry)
alive? (DRb::DRbServer)


return all methods that contain the query string:

02:59 <@brough> ?ali:ruby:fuzzy
02:59 <@rorbby> add_alias RUBY:RDoc; add_alias RUBY:RDoc; add_finalizer RUBY; alias_command
RUBY:She; alias_command RUBY; alias_extension RUBY:RDoc; alias_map RUBY:She;
alias_method RUBY; aliases RUBY:Gen; alive? RUBY (10 of 105)

return the first method name exactly matching the query string:

02:58 <@brough> ?alive?:ruby
02:59 <@rorbby> alive? (DRb::DRbServer) Is this server alive? ...

drill it down:

03:01 <@brough> ?alive?:ruby:th
03:01 <@rorbby> alive? (RUBY::Thread) Returns true if thr is running or sleeping. ... thr =
Thread.new { }; thr.join #=> #...


03:01 <@brough> ?alive?:ruby:drb
03:01 <@rorbby> alive? (DRb::DRbServer) Is this server alive? ...

03:02 <@brough> ?alive?:ruby:drb:tcp
03:02 <@rorbby> alive? (DRb::DRbTCPSocket) Check to see if this connection is alive. ...

private queries contain fuller descriptions and more usage examples:

02:55 <@brough> ?>>:ruby:proc brough
02:55 <@rorbby> >> (Process::Status) Shift the bits in stat right num places. fork { exit 99 } #=>
26563; Process.wait #=> 26563; $?.to_i #=> 25344; $? >> 8 #=> 99

http://github.com/broughcut/rorapi

No comments: