summaryrefslogtreecommitdiff
path: root/lib/rubygems/resolver
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/resolver/activation_request.rb7
-rw-r--r--lib/rubygems/resolver/api_set.rb14
-rw-r--r--lib/rubygems/resolver/api_specification.rb6
-rw-r--r--lib/rubygems/resolver/best_set.rb28
-rw-r--r--lib/rubygems/resolver/composed_set.rb16
-rw-r--r--lib/rubygems/resolver/conflict.rb52
-rw-r--r--lib/rubygems/resolver/dependency_request.rb21
-rw-r--r--lib/rubygems/resolver/git_set.rb2
-rw-r--r--lib/rubygems/resolver/git_specification.rb26
-rw-r--r--lib/rubygems/resolver/index_set.rb6
-rw-r--r--lib/rubygems/resolver/installed_specification.rb20
-rw-r--r--lib/rubygems/resolver/installer_set.rb94
-rw-r--r--lib/rubygems/resolver/local_specification.rb25
-rw-r--r--lib/rubygems/resolver/lock_set.rb22
-rw-r--r--lib/rubygems/resolver/lock_specification.rb28
-rw-r--r--lib/rubygems/resolver/set.rb14
-rw-r--r--lib/rubygems/resolver/spec_specification.rb2
-rw-r--r--lib/rubygems/resolver/specification.rb25
-rw-r--r--lib/rubygems/resolver/vendor_set.rb4
-rw-r--r--lib/rubygems/resolver/vendor_specification.rb2
20 files changed, 378 insertions, 36 deletions
@@ -39,6 +39,13 @@ class Gem::Resolver::ActivationRequest
end
##
# Downloads a gem at +path+ and returns the file path.
def download path
@@ -34,6 +34,8 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
@data = Hash.new { |h,k| h[k] = [] }
@source = Gem::Source.new @uri
end
##
@@ -45,6 +47,10 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
return res unless @remote
versions(req.name).each do |ver|
if req.dependency.match? req.name, ver[:number]
res << Gem::Resolver::APISpecification.new(self, ver)
@@ -61,9 +67,13 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
def prefetch reqs
return unless @remote
names = reqs.map { |r| r.dependency.name }
- needed = names - @data.keys
- return if needed.empty?
uri = @dep_uri + "?gems=#{needed.sort.join ','}"
str = Gem::RemoteFetcher.fetcher.fetch_path uri
@@ -34,6 +34,12 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
@dependencies == other.dependencies
end
def installable_platform? # :nodoc:
Gem::Platform.match @platform
end
@@ -28,6 +28,10 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
pick_sets if @remote and @sets.empty?
super
end
def prefetch reqs # :nodoc:
@@ -46,5 +50,29 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
end
end
end
@@ -22,6 +22,18 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
end
##
# Sets the remote network access for all composed sets.
def remote= remote
@@ -30,6 +42,10 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
@sets.each { |set| set.remote = remote }
end
##
# Finds all specs matching +req+ in all sets.
@@ -52,11 +52,40 @@ class Gem::Resolver::Conflict
def explanation
activated = @activated.spec.full_name
- requirement = @failed_dep.dependency.requirement
- " Activated %s via:\n %s\n instead of (%s) via:\n %s\n" % [
- activated, request_path(@activated).join(', '),
- requirement, request_path(requester).join(', '),
]
end
@@ -95,10 +124,19 @@ class Gem::Resolver::Conflict
path = []
while current do
- requirement = current.request.dependency.requirement
- path << "#{current.spec.full_name} (#{requirement})"
- current = current.parent
end
path = ['user request (gem command or Gemfile)'] if path.empty?
@@ -35,7 +35,26 @@ class Gem::Resolver::DependencyRequest
end
##
- # Does this dependency request match +spec+
def matches_spec?(spec)
@dependency.matches_spec? spec
@@ -80,7 +80,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
prefetch nil
specs.values.select do |spec|
- req.matches_spec? spec
end
end
@@ -12,11 +12,15 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
@source == other.source
end
##
# Installing a git gem only involves building the extensions and generating
# the executables.
- def install options
require 'rubygems/installer'
installer = Gem::Installer.new '', options
@@ -31,5 +35,25 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
installer.run_post_install_hooks
end
end
@@ -18,7 +18,9 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
@all = Hash.new { |h,k| h[k] = [] }
- list, = @f.available_specs :released
list.each do |uri, specs|
specs.each do |n|
@@ -41,7 +43,7 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
name = req.dependency.name
@all[name].each do |uri, n|
- if req.dependency.match? n then
res << Gem::Resolver::IndexSpecification.new(
self, n.name, n.version, uri, n.platform)
end
@@ -14,7 +14,7 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
# This is a null install as this specification is already installed.
# +options+ are ignored.
- def install options
yield nil
end
@@ -29,6 +29,24 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
super
end
##
# The source for this specification
@@ -21,6 +21,11 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
attr_accessor :ignore_installed # :nodoc:
##
# Creates a new InstallerSet that will look for gems in +domain+.
def initialize domain
@@ -34,11 +39,53 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
@always_install = []
@ignore_dependencies = false
@ignore_installed = false
@remote_set = Gem::Resolver::BestSet.new
@specs = {}
end
##
# Should local gems should be considered?
def consider_local? # :nodoc:
@@ -53,6 +100,13 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
end
##
# Returns an array of IndexSpecification objects matching DependencyRequest
# +req+.
@@ -62,30 +116,53 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
dep = req.dependency
return res if @ignore_dependencies and
- @always_install.none? { |spec| dep.matches_spec? spec }
name = dep.name
dep.matching_specs.each do |gemspec|
- next if @always_install.include? gemspec
res << Gem::Resolver::InstalledSpecification.new(self, gemspec)
end unless @ignore_installed
if consider_local? then
local_source = Gem::Source::Local.new
- if spec = local_source.find_gem(name, dep.requirement) then
res << Gem::Resolver::IndexSpecification.new(
- self, spec.name, spec.version, local_source, spec.platform)
end
end
res.concat @remote_set.find_all req if consider_remote?
res
end
def inspect # :nodoc:
always_install = @always_install.map { |s| s.full_name }
@@ -108,6 +185,15 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
end
end
def pretty_print q # :nodoc:
q.group 2, '[InstallerSet', ']' do
q.breakable
@@ -12,5 +12,30 @@ class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification
super
end
end
@@ -6,13 +6,16 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
attr_reader :specs # :nodoc:
##
- # Creates a new LockSet from the given +source+
- def initialize source
super()
- @source = Gem::Source::Lock.new source
- @specs = []
end
##
@@ -25,13 +28,14 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
def add name, version, platform # :nodoc:
version = Gem::Version.new version
- spec =
- Gem::Resolver::LockSpecification.new self, name, version, @source,
platform
- @specs << spec
- spec
end
##
@@ -40,7 +44,7 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
def find_all req
@specs.select do |spec|
- req.matches_spec? spec
end
end
@@ -23,7 +23,7 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
# This is a null install as a locked specification is considered installed.
# +options+ are ignored.
- def install options
destination = options[:install_dir] || Gem.dir
if File.exist? File.join(destination, 'specifications', spec.spec_name) then
@@ -41,10 +41,36 @@ class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
@dependencies << dependency
end
##
# A specification constructed from the lockfile is returned
def spec
@spec ||= Gem::Specification.new do |s|
s.name = @name
s.version = @version
@@ -9,8 +9,20 @@ class Gem::Resolver::Set
attr_accessor :remote
def initialize # :nodoc:
- @remote = true
end
##
@@ -4,8 +4,6 @@
class Gem::Resolver::SpecSpecification < Gem::Resolver::Specification
- attr_reader :spec # :nodoc:
-
##
# A SpecSpecification is created for a +set+ for a Gem::Specification in
# +spec+. The +source+ is either where the +spec+ came from, or should be
@@ -31,6 +31,14 @@ class Gem::Resolver::Specification
attr_reader :source
##
# The version of the gem for this specification.
attr_reader :version
@@ -48,6 +56,13 @@ class Gem::Resolver::Specification
end
##
# The name and version of the specification.
#
# Unlike Gem::Specification#full_name, the platform is not included.
@@ -61,8 +76,11 @@ class Gem::Resolver::Specification
# install method yields a Gem::Installer instance, which indicates the
# gem will be installed, or +nil+, which indicates the gem is already
# installed.
- def install options
require 'rubygems/installer'
destination = options[:install_dir] || Gem.dir
@@ -75,7 +93,7 @@ class Gem::Resolver::Specification
yield installer if block_given?
- installer.install
end
##
@@ -85,5 +103,8 @@ class Gem::Resolver::Specification
Gem::Platform.match spec.platform
end
end
@@ -43,6 +43,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
@specs[spec.name] = spec
@directories[spec] = directory
end
##
@@ -51,7 +53,7 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
def find_all req
@specs.values.select do |spec|
- req.matches_spec? spec
end.map do |spec|
source = Gem::Source::Vendor.new @directories[spec]
Gem::Resolver::VendorSpecification.new self, spec, source
@@ -16,7 +16,7 @@ class Gem::Resolver::VendorSpecification < Gem::Resolver::SpecSpecification
# This is a null install as this gem was unpacked into a directory.
# +options+ are ignored.
- def install options
yield nil
end