Giving wings to RAKA - graphing ability!

May 28th, 2008

Brightest ideas hit you when you least expect them. I was trying so hard all evening to put RAKA’s output into a format Graphviz could understand - but had no luck. I tried arrays, hashes, stack and what not - but nothing seemed right (or I wasn’t doing it right :) ) - and at 4am - right at the moment when I was packing up for the night - it hit me! - Just like a big bright Bulb!

Why not XML? Graphviz can very well render an XML (Some examples from ruby-graphviz gem) - and I was already able to output my tree in much similar format - whoa! 5 more minutes and I had this…


Read the graph - left to right, top to bottom. If X is displayed before Y in the graph, X is coded before Y.

And this is the code it corresponds to…

  1.  
  2. require "pp"
  3.  
  4. module Junk
  5.  
  6.   class Maku
  7.  
  8.     def say_hello(str)
  9.       puts "hello #{str}"
  10.       a = 1+1
  11.       if a == 2
  12.         if a == 1
  13.           puts "Yahoo"
  14.           if a == 10
  15.             puts "Microsoft"
  16.           else
  17.             puts "Google"
  18.           end
  19.         end
  20.         pp a
  21.       else
  22.         puts "bye"
  23.       end
  24.       puts ""
  25.       puts ""
  26.     end
  27.   end
  28.  
  29. end

Here is a side-by-side comparison of the output

The graph seems more like in vertical direction - however a more horizontal direction would look much better - what say?

Oh yes, I have a new expansion for RAKA - “A Ruby Klass Analyzer” :)

Posted in RAKA, Ruby | Comments (2)

2 Responses to “Giving wings to RAKA - graphing ability!”

  1. suneeta Says:

    Gr8 work dude. :)

    u totally r RORD :)

    only thing is “Oh yes, I have a new expansion for RAKA - “A Ruby Klass Analyzer””

    i guess it should be ARKA for suggested expansion unless ur suggesting jumbled acronyms :P
    lol only leg pulling .. no offences ….

  2. Mayank Jain (makuchaku) Says:

    One line answer!
    Ever heard of GNU?
    lol

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image