Sha256: 76791a08418c60d01d0541a780c826b32d70ba8b93b8cc31038bf012b60dcc24

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

# -*- ruby -*-

begin
  require 'rgl/dot'
  require 'rgl/implicit'
rescue Exception
  nil
end

# Example usage:
#
#  rake -R/home/hd/src/rgl/rakelib -f /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/Rakefile dep_graph
desc "Generate dependency graph of rake tasks"
task :dep_graph do |task|
  this_task = task.name
  dep = RGL::ImplicitGraph.new { |g|
    # vertices of the graph are all defined tasks without this task
	g.vertex_iterator do |b|
      Rake::Task.tasks.each do |t|
        b.call(t) unless t.name == this_task
      end
    end
    # neighbors of task t are its prerequisites
    g.adjacent_iterator { |t, b| t.prerequisites.each(&b) }
    g.directed = true
  }

  dep.write_to_graphic_file('png', this_task)
  puts "Wrote dependency graph to #{this_task}.png."
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rgl-0.4.0 rakelib/dep_graph.rake
rgl-0.3.0 rakelib/dep_graph.rake
rgl-0.3.1 rakelib/dep_graph.rake