Created
September 27, 2009 06:31
-
-
Save sferik/194634 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
nodes = [] | |
edges = {} | |
ObjectSpace.each_object(Class) do |klass| | |
# Skip classes outside the global namespace | |
next if klass.to_s.include?(':') | |
# Skip classes like ARGF.class | |
next if klass.to_s.include?('.') | |
nodes << klass | |
edges[klass] = klass.superclass unless klass.superclass.nil? | |
end | |
puts 'digraph classes {' | |
# Add (or remove) DOT formatting options here | |
puts ' graph [rotate=0, rankdir="RL", overlap=false, splines=true]' | |
puts ' node [shape="box", style="filled", color="#333333", fillcolor="#396da4", fontcolor="#ffffff", fontname="Helvetica Neue"]' | |
puts ' edge [arrowhead="open", color="#666666"]' | |
nodes.sort_by{|c| c.to_s}.each do |c| | |
puts " #{c}" | |
end | |
edges.map.each do |k, v| | |
puts " #{k} -> #{v}" | |
end | |
puts '}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment