From: Ralph Amissah Date: 2004-11-13T20:48:25+09:00 Subject: Re: Trivial trick for looking at complex code On Sat, 13 Nov 2004 19:11:44 +0900, Brian Schr�der wrote: > On Sat, 13 Nov 2004 08:30:44 +0900 > Hal Fulton wrote: > >> I was looking at some really complex code today (someone else's) and >> felt a need to see its structure a little better. >> >> You'd be surprised how helpful this is: >> >> grep -E "^ *(class|module|attr|def)" file.rb >> >> It shows fairly clearly all the hierarchies, the method signatures, >> and the attributes. >> >> That's making certain assumptions about common coding style. >> >> Below is an example of running it against cgi.rb... >> >> OK, it's not rocket science, but I felt like sharing it. > I have grown fond of glark http://glark.sourceforge.net/ a ruby enhanced grep (probably first read about on this list), so i do: glark -F "blue bold on black" -T "red on black" -B 0 -A 0 \ "^\s*(module|class|def|attr_|require|include)" file.rb rather as that string is faily long, i have the following function in my shell (zsh): ,glrb() { glark -F "blue bold on black" -T "red on black" -B 0 -A 0 \ "^\s*(module|class|def|attr_|require|include)" $1 } # ,glrb file.rb