diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-07-26 13:57:04 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-08-02 15:04:28 -0500 |
commit | 9d7f18e444c4c3481552c5b9805532c592f5e9b1 (patch) | |
tree | 783e692ce407bd619add001c5a86c85317d4a9c7 | |
parent | ededbe5e987879a0c88c0ac30552a5772ff94d1f (diff) | |
download | bundler-9d7f18e444c4c3481552c5b9805532c592f5e9b1.tar.gz |
[Graph] Remove monkey-patching of Gem::Dependency
-rw-r--r-- | lib/bundler/graph.rb | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb index c7e957ad7a..e145590430 100644 --- a/lib/bundler/graph.rb +++ b/lib/bundler/graph.rb @@ -17,7 +17,6 @@ module Bundler @node_options = {} @edge_options = {} - _patching_gem_dependency_class _populate_relations end @@ -36,10 +35,7 @@ module Bundler tmp = Set.new parent_dependencies.each do |dependency| - # if the dependency is a prerelease, allow to_spec to be non-nil - dependency.prerelease = true - - child_dependencies = dependency.to_spec.runtime_dependencies.to_set + child_dependencies = spec_for_dependency(dependency).runtime_dependencies.to_set @relations[dependency.name] += child_dependencies.map(&:name).to_set tmp += child_dependencies @@ -74,7 +70,7 @@ module Bundler when :node if symbol_or_string_or_dependency.is_a?(Gem::Dependency) label = symbol_or_string_or_dependency.name.dup - label << "\n#{symbol_or_string_or_dependency.to_spec.version}" if @show_version + label << "\n#{spec_for_dependency(symbol_or_string_or_dependency).version}" if @show_version else label = symbol_or_string_or_dependency.to_s end @@ -90,25 +86,8 @@ 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 do |spec| - name == spec.name && - requirement.satisfied_by?(spec.version) - end - - if platform_only - matches.select! do |spec| - Gem::Platform.match spec.platform - end - end - - matches = matches.sort_by(&:sort_obj) # HACK: shouldn't be needed - end - end + def spec_for_dependency(dependency) + @env.requested_specs.find {|s| s.name == dependency.name } end class GraphVizClient |