diff options
author | Tim Moore <tmoore@incrementalism.net> | 2014-08-24 13:43:01 +1000 |
---|---|---|
committer | Tim Moore <tmoore@incrementalism.net> | 2014-08-24 13:43:01 +1000 |
commit | 1ce22ac8e0f3417f3ac89f799a1b80751ac7afe4 (patch) | |
tree | 3dc21055135f7d8f47ecc52ef2b6e1509aa4e8aa /lib/bundler/index.rb | |
parent | 473770c143ac720f5b115d3e82d395b01f12cb93 (diff) | |
parent | ea143105677c4e38a2ce57bf6faa3cb8b782ef68 (diff) | |
download | bundler-1ce22ac8e0f3417f3ac89f799a1b80751ac7afe4.tar.gz |
Merge tag 'v1.7.1'
Version 1.7.1
Conflicts:
CHANGELOG.md
lib/bundler/dsl.rb
lib/bundler/index.rb
lib/bundler/lockfile_parser.rb
lib/bundler/source/rubygems.rb
man/gemfile.5.ronn
Diffstat (limited to 'lib/bundler/index.rb')
-rw-r--r-- | lib/bundler/index.rb | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb index 55ea51745a..9d2966b7a8 100644 --- a/lib/bundler/index.rb +++ b/lib/bundler/index.rb @@ -10,13 +10,14 @@ module Bundler i end - attr_reader :specs, :sources - protected :specs + attr_reader :specs, :all_specs, :sources + protected :specs, :all_specs def initialize @sources = [] @cache = {} @specs = Hash.new { |h,k| h[k] = Hash.new } + @all_specs = Hash.new { |h,k| h[k] = [] } end def initialize_copy(o) @@ -24,10 +25,14 @@ module Bundler @sources = @sources.dup @cache = {} @specs = Hash.new { |h,k| h[k] = Hash.new } + @all_specs = Hash.new { |h,k| h[k] = [] } o.specs.each do |name, hash| @specs[name] = hash.dup end + o.all_specs.each do |name, array| + @all_specs[name] = array.dup + end end def inspect @@ -39,6 +44,14 @@ module Bundler true end + def search_all(name) + all_matches = @all_specs[name] + local_search(name) + @sources.each do |source| + all_matches.concat(source.search_all(name)) + end + all_matches + end + # Search this index's specs, and any source indexes that this index knows # about, returning all of the results. def search(query, base = nil) @@ -55,7 +68,7 @@ module Bundler end end - results + results.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] } end def local_search(query, base = nil) @@ -88,18 +101,18 @@ module Bundler # returns a list of the dependencies def unmet_dependency_names - dependency_names = specs.values.map do |hash_of_s| - hash_of_s.values.map do |s| - s.dependencies.map{|d| d.name } - end - end.flatten.uniq - dependency_names.select{|name| name != 'bundler' && specs_by_name(name).empty? } + names = [] + each{|s| names.push *s.dependencies.map{|d| d.name } } + names.uniq! + names.delete_if{|n| n == "bundler" } + names.select{|n| search(n).empty? } end def use(other, override_dupes = false) return unless other other.each do |s| if (dupes = search_by_spec(s)) && dupes.any? + @all_specs[s.name] = [s] + dupes next unless override_dupes self << s end @@ -155,7 +168,7 @@ module Bundler found.reject! { |spec| spec.version.prerelease? } end - found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] } + found end end |