Class: Bundler::Fetcher::Dependency
- Inherits:
-
Base
- Object
- Base
- Bundler::Fetcher::Dependency
show all
- Defined in:
- lib/bundler/fetcher/dependency.rb
Instance Attribute Summary
Attributes inherited from Base
#display_uri, #downloader, #gem_remote_fetcher, #remote
Instance Method Summary
collapse
Methods inherited from Base
#fetch_uri, #initialize, #remote_uri
Instance Method Details
#api_fetcher? ⇒ Boolean
20
21
22
|
# File 'lib/bundler/fetcher/dependency.rb', line 20
def api_fetcher?
true
end
|
#dependency_api_uri(gem_names = []) ⇒ Object
71
72
73
74
75
|
# File 'lib/bundler/fetcher/dependency.rb', line 71
def dependency_api_uri(gem_names = [])
uri = fetch_uri + "api/v1/dependencies"
uri.query = "gems=#{CGI.escape(gem_names.sort.join(","))}" if gem_names.any?
uri
end
|
#dependency_specs(gem_names) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/bundler/fetcher/dependency.rb', line 43
def dependency_specs(gem_names)
Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(",")}"
gem_list = unmarshalled_dep_gems(gem_names)
get_formatted_specs_and_deps(gem_list)
end
|
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/bundler/fetcher/dependency.rb', line 59
def get_formatted_specs_and_deps(gem_list)
deps_list = []
spec_list = []
gem_list.each do |s|
deps_list.concat(s[:dependencies].map(&:first))
deps = s[:dependencies].map {|n, d| [n, d.split(", ")] }
spec_list.push([s[:name], s[:number], s[:platform], deps])
end
[spec_list, deps_list]
end
|
#specs(gem_names, full_dependency_list = [], last_spec_list = []) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/bundler/fetcher/dependency.rb', line 24
def specs(gem_names, full_dependency_list = [], last_spec_list = [])
query_list = gem_names.uniq - full_dependency_list
log_specs { "Query List: #{query_list.inspect}" }
return last_spec_list if query_list.empty?
spec_list, deps_list = Bundler::Retry.new("dependency api", FAIL_ERRORS).attempts do
dependency_specs(query_list)
end
returned_gems = spec_list.map(&:first).uniq
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
rescue MarshalError, HTTPError, GemspecError
Bundler.ui.info "" unless Bundler.ui.debug? Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
nil
end
|
#unmarshalled_dep_gems(gem_names) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/bundler/fetcher/dependency.rb', line 50
def unmarshalled_dep_gems(gem_names)
gem_list = []
gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
marshalled_deps = downloader.fetch(dependency_api_uri(names)).body
gem_list.concat(Bundler.safe_load_marshal(marshalled_deps))
end
gem_list
end
|