Visually Inspect Ruby Object Models with DrX »
Created at: 29.04.2010 01:35, source: Ruby Inside, tagged: Linux Specific OS X Specific Tools
When you want to inspect your objects in Ruby, Object#inspect, p, or awesome_print are all valuable. You're stuck with plain-text, though, and primarily designed to look at object data rather than object models. If you want to drill down into parent classes, see object and class relationships, etc, then, check out DrX, a visual object inspector for Ruby!
DrX bills itself as a "small object inspector", but its key features are that it shows results visually (in a GUI interface) and that it focuses on showing the object model behind your objects, rather than the data contained within. A visual example of a DrX session should give you the idea:

Usage
Once DrX is installed (more on that in the next section), you just require 'drx' it into your app (or even within irb) and then use the Object#see method to get DrX into action:
require 'drx' 123.see
Even this rudimentary example will bring up an interesting graph. The DrX author does, however, provide a more interesting example to show off DrX's introspective features:
s = "wizard of oz" def s.strong "<strong>" + self + "!</strong>" end s.see
Installation and Prerequisites
Depending on your setup, DrX might take some serious work to get going. If you're running Linux and are heavy on your development experimentation, you might have everything ready to go. Just try gem install drx and see if the above examples work in irb.
Failing that, DrX uses Tk for its GUI work in order to be cross-platform and also requires GraphViz to be present. Install these with your package manager of choice and ensure that your Ruby installation has the Tk bindings installed (again, easier said than done).
On OS X 10.6 (Snow Leopard) I discovered that the stock Ruby installation does not include the Tk bindings, even though Tk is present otherwise. Rather than mess it up, I relied on the always-wonderful RVM and installed Ruby 1.9.2-preview1 (rvm install ruby-1.9.2-preview1). With this, Tk worked "out of the box" and gem install rbx was OK. For the Graphviz dependency, sudo port install graphviz did the trick and also "just worked." If you're one of the anti-Macports crowd, though, you might need to find a different approach.
more »
MagLev Alpha Released: A New, Scalable Ruby Implementation »
Created at: 21.11.2009 04:20, source: Ruby Inside, tagged: Cool Linux Specific News OS X Specific Tools
MagLev is a new(ish) Ruby implementation built by Gemstone Systems that focuses on providing an integrated object persistence layer and a distributed shared cache - a truly scalable Ruby implementation. Maglev has, however, had an air of vaporware about it, having been hyped up in early 2008 and only available to a small group of alpha testers till now. That changes today with the first public, alpha release!
Back in early 2008, MagLev program manager Bob Walker did an interview with InfoQ about the project where he said that 8 people were working on MagLev, so this is a pretty big deal for them. Developer Avi Bryant then did a short presentation at RailsConf 2008 where he gave a comprehensive overview of what MagLev is along with some live demonstrations.
Why Should You Care?
In short, MagLev is cool for a few reasons. Two key ones being that 1) MagLev runs on the SmallTalk virtual machine which, it is claimed, should yield significant performance increases for a language like Ruby, and 2) a MagLev environment allows multiple Ruby processes over multiple machines (if you wish) to use the same objects simultaneously for easy scalability. Avi's video is great if you want to get a grasp on it:
MagLev presentation at RailsConf 2008 from Monty Williams on Vimeo.
Developer Monty Williams is keen to stress that this is an alpha, not a beta, so you can't expect it to run Rails or any gems that require C extensions. That said, it does run Sinatra, Rack, and RubyGems, plus a significant effort has been put into passing the RubySpec, so it's not as if it's a crippled implementation as such.
If you want to learn more, consider following the MagLev team on Twitter @MagLev and checking out the official mailing list "maglev-discussion."
Installation (i.e. getting to an irb prompt that works)
Bear in mind that MagLev will only work on 64 bit versions of OS X, Linux, and Solaris, so if you're in the 32 bit club, there's no point in going any further (yet).
If you download the MagLev Installer script (small ZIP file), you can run the installMaglev.sh script and install the latest version like so:
./installMaglev.sh 22578
The announcement post doesn't make it clear you need to provide a version number of what version number to provide. 22578 was mentioned earlier in the day though, and it seems to work.
Once installed, MagLev provides some info about environment variables you need to add to your .bashrc or .bash_profile. Follow these, then open a new terminal and here's how you get to an irb session:
$ maglev start
startnetldi[Info]: Starting GemStone network server "gs64ldi".
startnetldi[Error]: could not start server
startstone[Info]: Starting Stone repository monitor "maglev".
startstone[Info]: GemStone server 'maglev' has been started.
$ maglev-irb
irb(main):001:0> 20 + 20
=> 40
irb(main):002:0> exit
error , SystemExit Error, nil,
during /Users/peter/Downloads/MagLev-installer/MagLev-22578.MacOSX/bin/maglev-irb
SystemExit Error, nil
Alternatively: GitHub installation
MagLev is also available from GitHub to clone. To install MagLev from GitHub:
git clone git://github.com/MagLev/maglev.git cd maglev ./install.sh
.. then follow the note about adding the path to your .bashrc or .bash_profile and running Rake in a new prompt (though still under the maglev project directory).
If you get any further with doing something interesting like, say, getting an IRB prompt up successfully on this, do post a comment ;-)
[ad] Find duplication, code smells, complex code and more in your Ruby code with Caliper! The metrics are free and setup takes just one click. Get started!
more »
