Debugging

Checking rails routes

Checking rails routes

I just had to debug a strange problem with the Routing in JRuby. So in case you need to test the routing mechanism “by hand” go

> jruby script/console
>> ActionController::Routing::Routes.recognize_path('/my/path', {:method => :get})
Debugger messes up rdoc

Debugger messes up rdoc

Sometimes it seems that ruby still has a way to go in terms of maturity. Today I got a strange error message when trying to build the rdoc files:

uninitialized constant RubyToken::AlreadyDefinedToken (NameError)

Any idea what it means? It turns out that I forgot to remove a require 'ruby-debug' somewhere in the code, which in turn includes some files from irb, which in turn is incompatible with rdoc. Duh…

Runtime Assertions in Ruby

Runtime Assertions in Ruby

I’ve published my first gem on rubyforge: assit. It does runtime assertions for Ruby.

When I got started with Ruby, I was flabbergasted that there weren’t any runtime assertions at all. I have no idea why – even though there are one gadzillion different unit testing whatnots, a decent debugger and even a profiler. But this basic debugging tool, that has been there since the dawning days of C, is flatly missing; although it’d be even more useful in a language that doesn’t do any static checking.

So I’ve written my own little thing, and put it on for everyone to use. Getting started is easy: Just do

sudo gem install assit

and you’ll be ready to use it.

In the code, it’ll work like this:

require 'assit'

# Just some examples, there are more assertions
assit(defined?(assit)) # Yes, this is self-referential ;-)

x = 2 + 3
assit_equal(5, x, "There seems to be a problem with the addition")

foo = Foo.new
assit_kind_of(Foo, foo)

Read more…

And one more note…

And one more note…

For the last two posts, a spend half the day researching Ruby weirdness instead, quite “unproductively” instead of hacking in a solution for my original problem.

After posting the two entries, I went back to my code, and was able to make the unit tests pass by just deleting four characters…

Win32 dll exports
Comments off

Win32 dll exports

If you’d like to see the exported functions of an win32 dll, call dumpbin.exe -exports mydll.dll from the command line.