Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

recursive work to handle dependencies for Gemcutter Endpoint API

  • Loading branch information...
commit cc12adf7a161de088b213dee62c8790d59e2fb70 1 parent 0aef9ae
@hone hone authored
Showing with 24 additions and 10 deletions.
  1. +24 −10 lib/bundler/source.rb
View
34 lib/bundler/source.rb
@@ -211,7 +211,8 @@ def remote_specs(dependencies = nil)
remotes.each do |uri|
Bundler.ui.info "Fetching source index for #{uri}"
Gem.sources = ["#{uri}"]
- fetch_dependency_remote_specs(dependencies, uri) do |n,v|
+ gem_names = dependencies.map {|d| d.name }
+ fetch_remote_specs(gem_names, uri) do |n,v|
v.each do |name, version, platform|
next if name == 'bundler'
spec = RemoteSpecification.new(name, version, platform, uri)
@@ -227,21 +228,34 @@ def remote_specs(dependencies = nil)
end
end
- def fetch_dependency_remote_specs(dependencies, uri, &blk)
- return fetch_all_remote_specs(&blk) unless dependencies && uri.scheme != "file"
-
+ def fetch_remote_specs(gem_names, uri, full_dependency_list = [], last_spec_list = [], &blk)
require 'open-uri'
- gem_names = dependencies.map{|d| d.name }
+ return fetch_all_remote_specs(&blk) unless gem_names && uri.scheme != "file"
+
+ query_list = gem_names - full_dependency_list
+ Bundler.ui.debug "Query List: #{query_list.inspect}"
+ return {uri => last_spec_list}.each(&blk) if query_list.empty?
+
+ spec_list, deps_list = fetch_dependency_remote_specs(query_list, uri, &blk)
+ returned_gems = spec_list.map {|spec| spec.first }.uniq
+
+ fetch_remote_specs(deps_list, uri, full_dependency_list + returned_gems, spec_list + last_spec_list, &blk)
+ rescue OpenURI::HTTPError
+ fetch_all_remote_specs(&blk)
+ end
+
+ def fetch_dependency_remote_specs(gem_names, uri, &blk)
marshalled_deps = open("#{uri}api/v1/dependencies?gems=#{gem_names.join(",")}").read
- deps_list = Marshal.load(marshalled_deps)
+ gem_list = Marshal.load(marshalled_deps)
- spec_list = deps_list.map do |s|
+ spec_list = gem_list.map do |s|
[s[:name], Gem::Version.new(s[:number]), s[:platform]]
end
+ deps_list = gem_list.map do |s|
+ s[:dependencies].collect {|d| d.first }
+ end.flatten.uniq
- {uri => spec_list}.each(&blk)
- rescue OpenURI::HTTPError
- fetch_all_remote_specs(&blk)
+ [spec_list, deps_list]
end
def fetch_all_remote_specs(&blk)
Please sign in to comment.
Something went wrong with that request. Please try again.