Skip to content

Instantly share code, notes, and snippets.

@pfhawkins
Created January 9, 2014 18:20
Show Gist options
  • Save pfhawkins/8339205 to your computer and use it in GitHub Desktop.
Save pfhawkins/8339205 to your computer and use it in GitHub Desktop.
require 'spidr'
require 'graphviz'
url_map = Hash.new { |hash,key| hash[key] = [] }
Spidr.site('http://hypervers.es/') do |spider|
spider.every_link do |origin, dest|
if dest.host == "hypervers.es"
if dest.path == '/stylesheets/all.css'
elsif dest.path == '/javascripts/all.js'
else
url_map[dest] << origin
end
end
end
end
graph = GraphViz.new( :G, :type => :digraph )
graph.node[:shape] = "box"
url_map.each do |urlto, urlfrom|
graph.add_nodes( urlto.to_s )
urlfrom.each do |x|
graph.add_edges(urlto.to_s, x.to_s)
end
end
filename = "hyperverses-" + Time.new.to_s + ".png"
filename.gsub! " ", "_"
puts filename
graph.output( :png => filename )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment