summaryrefslogtreecommitdiff
path: root/lib/bundler/graph.rb
diff options
context:
space:
mode:
authorhirochachacha <hirochachacha@gmail.com>2012-08-08 11:00:16 +0900
committerAndre Arko <andre@arko.net>2012-11-14 18:10:37 -0800
commite89a18e408733ecb778940a5770167b91dbc48f6 (patch)
treebdc154bc54ae76370bbb88dafdc6019f353c938c /lib/bundler/graph.rb
parentc227a40c4839be8a13094b5533bf45d5a832a7a3 (diff)
downloadbundler-e89a18e408733ecb778940a5770167b91dbc48f6.tar.gz
fix bundle viz error with git
Diffstat (limited to 'lib/bundler/graph.rb')
-rw-r--r--lib/bundler/graph.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb
index 897c9a806f..c85f83eaa1 100644
--- a/lib/bundler/graph.rb
+++ b/lib/bundler/graph.rb
@@ -15,6 +15,7 @@ module Bundler
@node_options = {}
@edge_options = {}
+ _patching_gem_dependency_class
_populate_relations
end
@@ -27,7 +28,6 @@ module Bundler
private
def _populate_relations
- relations = Hash.new {|h, k| h[k] = Set.new}
parent_dependencies = _groups.values.to_set.flatten
while true
if parent_dependencies.empty?
@@ -36,7 +36,6 @@ module Bundler
tmp = Set.new
parent_dependencies.each do |dependency|
child_dependencies = dependency.to_spec.runtime_dependencies.to_set
- relations[dependency.name] += child_dependencies.to_set
@relations[dependency.name] += child_dependencies.map(&:name).to_set
tmp += child_dependencies
@@ -48,7 +47,6 @@ module Bundler
parent_dependencies = tmp
end
end
- @relations
end
def _groups
@@ -87,6 +85,27 @@ module Bundler
label.nil? ? {} : { :label => label }
end
+ def _patching_gem_dependency_class
+ # method borrow from rubygems/dependency.rb
+ # redefinition of matching_specs will also redefine to_spec and to_specs
+ Gem::Dependency.class_eval do
+ def matching_specs platform_only = false
+ matches = Bundler.load.specs.select { |spec|
+ self.name === spec.name and # TODO: == instead of ===
+ requirement.satisfied_by? spec.version
+ }
+
+ if platform_only
+ matches.reject! { |spec|
+ not Gem::Platform.match spec.platform
+ }
+ end
+
+ matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
+ end
+ end
+ end
+
class GraphVizClient
def initialize(graph_instance)
@graph_name = graph_instance.class::GRAPH_NAME