Class: Gem::Resolver::APISet
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Set
|
|
Instance Chain:
self,
Set
|
|
Inherits: |
Gem::Resolver::Set
|
Defined in: | lib/rubygems/resolver/api_set.rb |
Overview
The global rubygems pool, available via the rubygems.org API. Returns instances of APISpecification.
Class Method Summary
-
.new(dep_uri = 'https://rubygems.org/api/v1/dependencies') ⇒ APISet
constructor
Creates a new
APISet
that will retrieve gems from #uri using the RubyGems API URL #dep_uri which is described at guides.rubygems.org/rubygems-org-api.
Instance Attribute Summary
-
#source
readonly
The ::Gem::Source that gems are fetched from.
-
#uri
readonly
The corresponding place to fetch gems.
Set - Inherited
#errors | Errors encountered when resolving gems. |
#prerelease | When true, allows matching of requests to prerelease gems. |
#remote | Set to true to disable network access for this set. |
Instance Method Summary
-
#find_all(req)
Return an array of APISpecification objects matching DependencyRequest
req
. -
#prefetch(reqs)
A hint run by the resolver to allow the Set to fetch data for DependencyRequests
reqs
.
Set - Inherited
Constructor Details
.new(dep_uri = 'https://rubygems.org/api/v1/dependencies') ⇒ APISet
Creates a new APISet
that will retrieve gems from #uri using the RubyGems API URL #dep_uri which is described at guides.rubygems.org/rubygems-org-api
# File 'lib/rubygems/resolver/api_set.rb', line 27
def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies' super() dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8 @dep_uri = dep_uri @uri = dep_uri + '../..' @data = Hash.new { |h,k| h[k] = [] } @source = Gem::Source.new @uri @to_fetch = [] end
Instance Attribute Details
#source (readonly)
The ::Gem::Source that gems are fetched from
# File 'lib/rubygems/resolver/api_set.rb', line 15
attr_reader :source
#uri (readonly)
The corresponding place to fetch gems.
# File 'lib/rubygems/resolver/api_set.rb', line 20
attr_reader :uri
Instance Method Details
#find_all(req)
Return an array of APISpecification objects matching DependencyRequest req
.
# File 'lib/rubygems/resolver/api_set.rb', line 45
def find_all req res = [] return res unless @remote if @to_fetch.include?(req.name) prefetch_now end versions(req.name).each do |ver| if req.dependency.match? req.name, ver[:number] res << Gem::Resolver::APISpecification.new(self, ver) end end res end
#prefetch(reqs)
A hint run by the resolver to allow the Set to fetch data for DependencyRequests reqs
.
# File 'lib/rubygems/resolver/api_set.rb', line 67
def prefetch reqs return unless @remote names = reqs.map { |r| r.dependency.name } needed = names - @data.keys - @to_fetch @to_fetch += needed end