Created
January 31, 2011 01:56
-
-
Save o-sam-o/803527 to your computer and use it in GitHub Desktop.
Use GraphViz to construct a diagram of a Rails act as dag relation
This file contains 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
desc 'Uses graphviz to construct a graph of SuperCategories' | |
task :super_category_graph => :environment do | |
File.open('super_categories.dot', 'w') do |f| | |
f.puts "digraph super_categories {\n" | |
SuperCategory.all.each do |super_category| | |
super_category.children.each do |child| | |
f.puts %{"#{super_category.name}" -> "#{child.name}";\n} | |
end | |
end | |
f.puts '}' | |
end | |
`dot -Tpng -o'super_categories.png' 'super_categories.dot'` | |
`open super_categories.png` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment