Parent

Class Index [+]

Quicksearch

Bundler::Graph

Constants

GRAPH_NAME

Attributes

groups[R]
relations[R]
node_options[R]
edge_options[R]
output_file[R]
output_format[R]

Public Class Methods

new(env, output_file, show_version = false, show_requirements = false, output_format = "png") click to toggle source
    # File lib/bundler/graph.rb, line 6
 6:     def initialize(env, output_file, show_version = false, show_requirements = false, output_format = "png")
 7:       @env               = env
 8:       @output_file       = output_file
 9:       @show_version      = show_version
10:       @show_requirements = show_requirements
11:       @output_format     = output_format
12: 
13:       @groups            = []
14:       @relations         = Hash.new {|h, k| h[k] = Set.new}
15:       @node_options      = {}
16:       @edge_options      = {}
17: 
18:       _populate_relations
19:     end

Public Instance Methods

viz() click to toggle source
    # File lib/bundler/graph.rb, line 23
23:     def viz
24:       GraphVizClient.new(self).run
25:     end

Private Instance Methods

_groups() click to toggle source
    # File lib/bundler/graph.rb, line 54
54:     def _groups
55:       relations = Hash.new {|h, k| h[k] = Set.new}
56:       @env.current_dependencies.each do |dependency|
57:         dependency.groups.each do |group|
58:           relations[group.to_s].add(dependency)
59:           @relations[group.to_s].add(dependency.name)
60: 
61:           @node_options[group.to_s] ||= {:label => _make_label(group, :node)}
62:           @edge_options["#{group}_#{dependency.name}"] = {:label => _make_label(dependency, :edge)}
63:         end
64:       end
65:       @groups = relations.keys
66:       relations
67:     end
_make_label(symbol_or_string_or_dependency, element_type) click to toggle source
    # File lib/bundler/graph.rb, line 69
69:     def _make_label(symbol_or_string_or_dependency, element_type)
70:       case element_type.to_sym
71:       when :node
72:         if symbol_or_string_or_dependency.is_a?(Gem::Dependency)
73:           label = symbol_or_string_or_dependency.name.dup
74:           label << "\n#{symbol_or_string_or_dependency.to_spec.version.to_s}" if @show_version
75:         else
76:           label = symbol_or_string_or_dependency.to_s
77:         end
78:       when :edge
79:         label = nil
80:         if symbol_or_string_or_dependency.respond_to?(:requirements_list) && @show_requirements
81:           tmp = symbol_or_string_or_dependency.requirements_list.join(", ")
82:           label = tmp if tmp != ">= 0"
83:         end
84:       else
85:         raise ArgumentError, "2nd argument is invalid"
86:       end
87:       label
88:     end
_populate_relations() click to toggle source
    # File lib/bundler/graph.rb, line 29
29:     def _populate_relations
30:       relations = Hash.new {|h, k| h[k] = Set.new}
31:       parent_dependencies = _groups.values.to_set.flatten
32:       while true
33:         if parent_dependencies.empty?
34:           break
35:         else
36:           tmp = Set.new
37:           parent_dependencies.each do |dependency|
38:             child_dependencies = dependency.to_spec.runtime_dependencies.to_set
39:             relations[dependency.name] += child_dependencies.to_set
40:             @relations[dependency.name] += child_dependencies.map(&:name).to_set
41:             tmp += child_dependencies
42: 
43:             @node_options[dependency.name] = {:label => _make_label(dependency, :node)}
44:             child_dependencies.each do |c_dependency|
45:               @edge_options["#{dependency.name}_#{c_dependency.name}"] = {:label => _make_label(c_dependency, :edge)}
46:             end
47:           end
48:           parent_dependencies = tmp
49:         end
50:       end
51:       @relations
52:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.