From: Rocky Bernstein Date: 2007-07-27T11:12:14+09:00 Subject: Columnize, irb, and ruby-debug ------=_Part_205197_16469187.1185502337390 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I've been working on/with Kent SIbilev's ruby-debug. The current sources in SVN on rubyforge work with Ruby 1.9. In showing a list of possible debugger commands, I like to see this list in sorted column order. For example: backtrace delete exit info next ps run source undisplay break display finish irb p quit save step up catch down frame list pc reload set thread var continue eval help method pp restart show trace where In order to make this happen, I took a method called "columnize" from Python's command-handling class (Cmd), and converted it to Ruby. (II think the code is cleaner in Ruby. And if you want the sorting to go horizontally rather than vertically the code becomes much simpler in either language.) I then realized that I'd like this kind of display when showing various lists. For example, a list of methods or a list of instance variables. Easily added. Lots of mileage from that one little class/routine. The next step was to add the ability to show sorted and column-ordered lists in irb. So I added to my .irbrc a "ps" method to take a list sort it into columns and "pc" which does the same without sorting. (And if you look above you'll see this is also there right now in ruby-debug). So now here's the thing I've been puzzling over. It seems silly to make a package out of this one little class module. And although it can live inside ruby-debug, there's probably a better place for it to live so it can be used by irb, and ruby-debug and other places. Thoughts? ------=_Part_205197_16469187.1185502337390 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I've been working on/with Kent SIbilev's ruby-debug. The current sources in SVN on rubyforge  work with Ruby 1.9.

In showing a list of possible debugger commands, I like to see this list in sorted column order. For example:

backtrace  delete   exit    info    next  ps       run   source  undisplay
break      display  finish  irb     p     quit     save  step    up      
catch      down     frame   list    pc    reload   set   thread  var     
continue   eval     help    method  pp    restart  show  trace   where   

In order to make this happen, I  took a method called "columnize" from Python's command-handling class (Cmd), and converted it to Ruby.

(II think the code is cleaner in Ruby. And if you want the sorting to go horizontally rather than vertically the code becomes much simpler in either language.)

I then realized that I'd like this kind of display when showing various lists. For example, a list of methods or a list of instance variables.  Easily added. Lots of mileage from that one  little class/routine.

The next step was to add the ability to show sorted and column-ordered lists in irb. So I added to my .irbrc a "ps" method to take a list sort it into columns and "pc" which does the same without sorting. (And if you look above you'll see this is also there right now in ruby-debug).

So now here's the thing I've been puzzling over. It seems silly to make a package out of this one little class module. And although it can live inside ruby-debug, there's probably a better place for it to live so it can be used by irb, and ruby-debug and other places.

Thoughts?
------=_Part_205197_16469187.1185502337390--