Parent

Class Index [+]

Quicksearch

Bundler::Graph

Constants

USER_OPTIONS

Public Class Methods

new(env) click to toggle source
   # File lib/bundler/graph.rb, line 6
6:     def initialize(env)
7:       @env = env
8:     end

Public Instance Methods

groups() click to toggle source
    # File lib/bundler/graph.rb, line 15
15:     def groups
16:       populate
17:       @groups
18:     end
nodes() click to toggle source
    # File lib/bundler/graph.rb, line 10
10:     def nodes
11:       populate
12:       @nodes
13:     end
viz(output_file, show_gem_versions = false, show_dependency_requirements = false) click to toggle source
    # File lib/bundler/graph.rb, line 20
20:     def viz(output_file, show_gem_versions = false, show_dependency_requirements = false)
21:       require 'graphviz'
22:       populate
23: 
24:       graph_viz = GraphViz::new('Gemfile', {:concentrate => true, :normalize => true, :nodesep => 0.55})
25:       graph_viz.edge[:fontname] = graph_viz.node[:fontname] = 'Arial, Helvetica, SansSerif'
26:       graph_viz.edge[:fontsize] = 12
27: 
28:       viz_nodes = {}
29: 
30:       # populate all of the nodes
31:       nodes.each do |name, node|
32:         label = name.dup
33:         label << "\n#{node.version}" if show_gem_versions
34:         options = { :label => label }
35:         options.merge!( USER_OPTIONS ) if node.is_user
36:         viz_nodes[name] = graph_viz.add_node( name, options )
37:       end
38: 
39:       group_nodes = {}
40:       @groups.each do |name, dependencies|
41:         group_nodes[name] = graph_viz.add_node(name.to_s, { :shape => 'box3d', :fontsize => 16 }.merge(USER_OPTIONS))
42:         dependencies.each do |dependency|
43:           options = { :weight => 2 }
44:           if show_dependency_requirements && (dependency.requirement.to_s != ">= 0")
45:             options[:label] = dependency.requirement.to_s
46:           end
47:           graph_viz.add_edge( group_nodes[name], viz_nodes[dependency.name], options )
48:         end
49:       end
50: 
51:       @groups.keys.select { |group| group != :default }.each do |group|
52:         graph_viz.add_edge( group_nodes[group], group_nodes[:default], { :weight => 2 } )
53:       end
54: 
55:       viz_nodes.each do |name, node|
56:         nodes[name].dependencies.each do |dependency|
57:           options = { }
58:           if nodes[dependency.name].is_user
59:             options[:constraint] = false
60:           end
61:           if show_dependency_requirements && (dependency.requirement.to_s != ">= 0")
62:             options[:label] = dependency.requirement.to_s
63:           end
64: 
65:           graph_viz.add_edge( node, viz_nodes[dependency.name], options )
66:         end
67:       end
68: 
69:       graph_viz.output( :png => output_file )
70:     end

Private Instance Methods

populate() click to toggle source
     # File lib/bundler/graph.rb, line 74
 74:     def populate
 75:       return if @populated
 76: 
 77:       # hash of name => GraphNode
 78:       @nodes = {}
 79:       @groups = {}
 80: 
 81:       # Populate @nodes
 82:       @env.specs.each { |spec| @nodes[spec.name] = GraphNode.new(spec.name, spec.version) }
 83: 
 84:       # For gems in Gemfile, add details
 85:       @env.current_dependencies.each do |dependency|
 86:         next unless node = @nodes[dependency.name]
 87:         node.is_user = true
 88: 
 89:         dependency.groups.each do |group|
 90:           if @groups.has_key? group
 91:             group = @groups[group]
 92:           else
 93:             group = @groups[group] = []
 94:           end
 95:           group << dependency
 96:         end
 97:       end
 98: 
 99:       # walk though a final time and add edges
100:       @env.specs.each do |spec|
101: 
102:         from = @nodes[spec.name]
103:         spec.runtime_dependencies.each do |dependency|
104:           from.dependencies << dependency
105:         end
106: 
107:       end
108: 
109:       @nodes.freeze
110:       @groups.freeze
111:       @populated = true
112:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.