Racksh: A Rails-Console-A-Like for Rack-Based Ruby Apps
Have you ever yearned for something like Rails's script/console
or Merb's merb -i
in your other Rack based apps? If so, then Marcin Kulik's racksh, inspired by Heroku's console, might be for you.
Racksh is a console for Rack based ruby web applications. It allows you run a console in the context of an application environment for Rails, Merb, Sinatra, Camping, Ramaze (or even your own framework) provided there is a rackup file in the root directory.
When you run the racksh
command, it loads the whole application environment just like a Rack web server, but instead of running the app it starts an irb session where you can invoke commands.
$ racksh Rack::Shell v0.9.4 started in development environment. > Article.all => # returns all articles...
As of version 0.9.4 (released this week), racksh uses Bryan Helmkamp's rack-test to simulate HTTP requests to your Rack application via the $rack variable.
$ racksh Rack::Shell v0.9.4 started in development environment. > $rack.get "/" => # returns a Rack::MockResponse
Racksh also allows you to apply configuration through a .rackshrc file. This can be used to set headers which will be used for requests, or to make additional setup requests (e.g. to make sure a user is logged in).
Install as a gem from Gemcutter, or get the source from Github.
gem install racksh -s http://gemcutter.org
For more details, check out the project's README, and these recent posts on Marcin's blog.
November 23, 2009 at 6:12 pm
Racksh is great, I have support for it in my Rango framework http://github.com/botanicus/rango When you generate a project via rango create project myblog, cd myblog; gem bundle and run ./init.rb -i, you'll get racksh console if racksh is available.
PS: Unfortunately at the moment you have to use http://github.com/botanicus/racksh otherwise init.rb will fail, but I sent a pull request, so I hope Marcin will fix it soon.
November 23, 2009 at 7:38 pm
Hi there, I've already applied Botanicus' patch and relased gem to gemcutter :)
It's nice to see that new ruby frameworks are using racksh as a default. First was Pancake, now Rango :)
November 24, 2009 at 12:58 pm
Hi Marcin - thanks for your quick turnaround regarding the problems I initially had with racksh.