Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. # Output a DOT file of the include structure of a project
  3. #
  4. # Usage:
  5. # cd <the include path of the project>
  6. # <path of this script>/make-include-graph.rb > includes.dot
  7.  
  8. require 'find'
  9.  
  10. def output_edges(path)
  11. File.open(path) do |f|
  12. f.each_line do |line|
  13. match = line.match(/^\s*#\s*include\s*[<"](.*)[">]/)
  14. if match
  15. puts "\t\"#{path}\" -> \"#{match[1]}\";"
  16. end
  17. end
  18. end
  19. end
  20.  
  21. puts 'digraph includes {'
  22. Find.find('.') do |path|
  23. unless FileTest.directory?(path)
  24. path = path[2..-1]
  25. output_edges(path)
  26. end
  27. end
  28. puts '}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement