François Vaux has recently published a Ruby module called Rackable which allows you to make any Ruby object Rack-friendly, providing it with a REST-like interface.
What does this mean? Well, a Rack application is essentially a Ruby object that responds to call(). Rackable just gives your object a call method which uses the Rack environment to dispatch to a method.
So, you just need to include Rackable in your class and implement methods for the the appropriate REST verbs. This means you can create a hello_world.ru file like this:
require 'rackable'
class HelloWorld
include Rackable
def get()
"Hello, world!"
end
end
run HelloWorld.new
... start it with rackup, and then use something like curl (or even your browser) to call the methods.
Thanks to Alex Young for putting me on to this.
Also.. Got a slow Test::Unit or RSpec suite? Run them up to three times faster on Devver's cloud! Setup is simple and requires no code changes. Request a beta invite today!