Skip to content

Instantly share code, notes, and snippets.

@mvidner
Created December 11, 2013 14:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvidner/7911768 to your computer and use it in GitHub Desktop.
Save mvidner/7911768 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Usage: rake -P | rake-prereqs-dot | dotty -
# Convert the output of `rake -P/--prereqs`
# ("Display the tasks and dependencies, then exit.")
# to a graphviz graph
# Sample input
# -8<-
# rake check:osc
# rake check:syntax
# rake console
# rake osc:build
# check:osc
# package
# rake osc:commit
# osc:build
# rake osc:sr
# osc:commit
# rake package
# check:syntax
# tarball
# rake tarball
# -8<-
puts "digraph g {"
task = "?"
ARGF.each_line do |line|
line.chomp!
if line =~ /^rake (.*)/
task = $1
puts "\"#{task}\";"
else
puts "\"#{task}\" -> \"#{line.strip}\";"
end
end
puts "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment