eigenclass logo
MAIN  Index  Search  Changes  PageRank  Login

rcodetools: TDD/BDD++, automagic assertions, 100% accurate completion, doc/code browsing...

update.png Latest release: 2007-06-22 0.7.0


rcodetools is a collection of Ruby code manipulation tools. It includes xmpfilter and editor-independent Ruby development helper tools, as well as emacs and vim interfaces.

Currently, rcodetools comprises:

  • xmpfilter: automagic Test::Unit assertions/RSpec expectations and code annotations
  • rct-complete: 100% accurate method/class/constant etc. completion
  • rct-doc: document browsing and code navigator
  • rct-meth-args: precise method info (meta-prog. aware) and TAGS generation
  • rct-fork: pre-load heavy library(Rails etc) and speed up rct-complete/rct-doc (server)
  • rct-fork-client: run Ruby programs from the current state of the rct-fork server
  • ruby-toggle-file: toggle implementation file and test file
  • rbtest: embedded Test::Unit for small scripts


rcodetools can be installed with RubyGems:

 gem install rcodetools

If you try this shortly after a release and you get an old version/a 404 error, please allow some time until the packages propagate to RubyForge's mirrors.

rcodetools is available in tarball format. rcodetools' executables will run faster when installed this way, since RubyGems add a noticeable overhead. The last tarball is rcodetools-0.7.0.tar.gz (you might get a 404 error if the file hasn't propagated to rubyforge's mirrors yet).

You can also get it from http://eigenclass.org/static/rcodetools

Caveat emptor

The rcodetools execute your programs; in particular, rct-complete will run your code when you attempt to perform code completion! Keep this in mind if your code has got side-effects such as files being deleted, emails sent, etc...


See this page for more information on xmpfilter and how to use it to generate Test::Unit assertions and RSpec expectations automagically.

The rct-* programs can be used with any editor, but rcodetools includes emacs and vim interfaces (contributions for other editors are welcome); see README.emacs and README.vim in the sources for more information.


See this page.


Copyright (c)      2006 rubikitch <rubikitch@ruby-lang.org> http://www.rubyist.net/~rubikitch/
Copyright (c) 2005-2006 Mauricio Fernandez <mfp@acm.org>    http://eigenclass.org

Use and distribution subject to the terms of the Ruby license.

(Comments will be moved to a separate node eventually)

Hashbang - Wilson Bilkovich (2006-12-29 (Fri) 19:10:13)

The #! lines of the scripts in the 'bin' directory have a user-specific path, rather than the usual /usr/bin/env ruby

rubikitch 2006-12-29 (��) 19:53:53

The setup.rb rewrites #! lines.

stiff 2006-12-30 (Sat) 00:54:17

Is there a way to use the completion in Rails code? I get a "eval: -:2: uninitialized constant ApplicationController (NameError)" :| Otherwise it absolutely kicks ass...

mfp 2006-12-30 (Sat) 11:26:08

I guess you'd have to load environment.rb in order to have the appropriate directories added to $: and the const_missing (I assume) magic in place.

Fix for xmpfilter on Win32 platfrom - eao197 (2006-12-30 (Sat) 01:11:45)

There is a problem with completion in VIM by C-x+C-U: exception Errno::EACCESS is thrown in xmpfilter.rb:113 (when File.unlink tries to remove temporary file in at_exit block). I think it is because on Win32 it is impossible to unlink already opened file.

May be it is better to rewrite part of execute_tmpfile as such:

   stdin, stdout, stderr = (1..3).map do |i|
     fname = "xmpfilter.tmpfile_#{Process.pid}-#{i}.rb"
     f = File.open(fname, "w+")
     at_exit { f.close unless f.closed?; File.unlink fname }

mfp 2007-01-02 (Tue) 18:18:23

Thank you, patch applied.

James Strachan 2007-01-18 (Thr) 07:54:52

I wonder is it worth setting up a mailing list to discuss rcodetools? Its great stuff BTW!

I've been tinkering with the TextMate integration that James Edward Gray II put together which is working very nicely thanks! I wonder though, completion only seems to work at the top level of a script (or inside a block). But it doesn't seem to work inside a method declaration. Is there anything dumb I'm doing wrong or do you have a cunning plan for supporting that in the future?

mfp 2007-01-20 (Sat) 12:29:41

hmmm are there enough users for a ML? I'll think about it (I don't want to use rubyforge's MLs, since they always end badly spammed, so I'd have to set it up on my own).

rct-complete runs the program in order to obtain the actual types, so you'd need a call to the method somewhere in order to have that section executed. You can also use the --eval option to specify an expression to be evaluated (the method call), but it's probably too bothersome.

It might be possible to combine it with the rct-meth-args analysis in order to record the types of local variables and have auto-completion without running the code, maybe even storing a sort of fixture at test-time (a serialization of self plus the method arguments). (Just some ideas)

Jon 2007-01-29 (Mon) 13:13:30

Google Groups is good for a quick spamproof mailing list with no setup time.

Alex Soto 2007-01-29 (Mon) 16:55:46

I've googled for the TextMate integration and can't find it. Anyone got a link to it?

method_analysis - elbarto (2006-12-30 (Sat) 01:29:48)

I got problems while trying to use the "tags" goal with rake:

  • in RakeFile.method_analysis, the line:
 sh "method_args.rb -t lib/rt/*.rb > TAGS"

should be

 sh "rct-meth-args -t lib/rt/*.rb > TAGS"
  • and the command "rake tags" failed for my project:
 ./lib/kitty/apportioner.rb:6:in `require': no such file to load -- kitty/permutation (LoadError)
       from ./lib/kitty/apportioner.rb:6
       from /usr/local/bin/rct-meth-args:389:in `require'
       from /usr/local/bin/rct-meth-args:389
       from /usr/local/bin/rct-meth-args:389:in `each'
       from /usr/local/bin/rct-meth-args:389

I fixed it by invoking the following command:

 sh "cd lib; rct-meth-args -t **/*.rb > $OLDPWD/TAGS; cd $OLDPWD"

rubikitch 2006-12-30 (��) 08:58:02

`method_args.rb' is an old name, sorry for typo.

sh "ruby -Ilib -S rct-meth-args -t ./lib/**/*.rb > TAGS"

I'll add -I option to rct-meth-args.

mfp 2006-12-30 (Sat) 11:30:45

You can blame me for the typo, I forgot to modify the Rakefile when I imported method_args/rct-meth-args.

Problem with strftime - Adagios (2007-02-02 (Fri) 12:24:33)


I had a problem with the tmpfile name.

The strftime part was using '%T' which in my computer translates to something like 'hh:mm:ss' an that was giving an error, as ':' is an invalid char in a filename.

I've replaced




and the problem disappeared.

BTW this is on Cygwin, and my Locale is Portuguese.

mfp 2007-02-03 (Sat) 03:59:10

Thank you, I'm applying this fix.