I'm pleased to announce to new libraries written by members of the Seattle Ruby Brigade, mem_inspect and png!
···
===
mem_inspect is ObjectSpace.each_object on crack. mem_inspect gives you the contents of each slot in Ruby's heap. mem_inspect also includes viewers that let you visualize the contents of Ruby's heap.
To install:
$ sudo gem install mem_inspect
Then you'll need to build a patched ruby:
ruby_mem_inspect_build
You'll then have a ruby capable of running mem_inspect in mem_inspect_ruby_1_8.
You can make an image with:
mem_inspect_ruby_1_8/ruby_mem_inspect -S ruby_mem_dump
Which will give you a PNG in your current directory named:
mem_inspect.PID.TIMESTAMP.png
You'll get an image that looks something like this:
http://flickr.com/photos/drbrain/229482312/
Bigger:
http://flickr.com/photo_zoom.gne?id=229482312&size=o
To dump a PDF any time you want:
require 'meminspect/png_viewer'
MemInspect::PNGViewer.new(1024, 768).draw
You can also dump to an AquaTerm plot window if you have RubyCocoa and AquaTerm installed.
require 'meminspect/aquaterm_viewer'
MemInspect::AquatermViewer.new(1024, 768).draw
===
png is a pure-ruby PNG writing library written by Ryan Davis.
To install:
$ sudo gem install png
To use:
require 'png'
canvas = PNG::Canvas.new 200, 200
# Set a point to a color
canvas[100, 100] = PNG::Color::Black
# draw an anti-aliased line
canvas.line 50, 50, 100, 50, PNG::Color::Blue
png = PNG.new canvas
png.save 'blah.png'
--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant