Skip to content

Instantly share code, notes, and snippets.

@fujin
Forked from anonymous/gist:143316
Created July 9, 2009 00:03
Show Gist options
  • Select an option

  • Save fujin/143318 to your computer and use it in GitHub Desktop.

Select an option

Save fujin/143318 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# Requirements
require "csv"
file = File.open("/tmp/play.dot","w")
file.puts "graph G { "
#file.puts "\trankdir=LR "
file.puts "\tratio=expand;"
#file.puts "\tnode [shape=record];"
#file.puts "\tnode [shape=tab shapefile=\"/usr/share/dia/shapes/Network/router-symbol.png\"];"
CSV.open("site_list.csv", "r") do |records|
parents = records[4].strip.split(',')
parents.each do |parent|
parent && parent.strip!
host = records[0].strip
hostname = records[0].strip
ipaddr = records[2].strip
puts "Parent is #{parent} and host is #{host} and ip is #{ipaddr} and name is #{hostname}"
file.puts "\t\"#{host}\" [bottomlabel=\"#{host}\"];"
# image=\"/usr/share/dia/shapes/Network/router-symbol.png\"];"
#####
#file.puts "\t \"#{host}\" [label=< "
#file.puts "\t <table border=\"0\" cellborder=\"1\" cellspacing=\"0\"> "
#file.puts "\t <tr> "
#file.puts "\t <td href="\"#{hostname}\"];"
file.puts "\t\"#{parent}\" -- \"#{host}\""
end
end
time = Time.now
#file.puts "label = \"\n\n\(C\) Kanji Group Pty Ltd\n\nCreated #{time}\" ;"
#file.puts "fontsize=20;"
#file.puts "overlap=false;"
file.puts "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment