aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/resolver
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-25 19:14:49 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-25 19:14:49 +0000
commit04817ae6d3e1d898d6fbf09ad146850d26d2b404 (patch)
tree7e5482d13830cacf363d21a087b490588a960095 /lib/rubygems/resolver
parentc107372597586e1ad0fea03c00a14bdd7205b5d8 (diff)
downloadruby-04817ae6d3e1d898d6fbf09ad146850d26d2b404.tar.gz
* lib/rubygems: Update to RubyGems master 612f85a. Notable changes:
Fixed installation and activation of git: and path: gems via Gem.use_gemdeps Improved documentation coverage * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/resolver')
-rw-r--r--lib/rubygems/resolver/activation_request.rb41
-rw-r--r--lib/rubygems/resolver/api_specification.rb4
-rw-r--r--lib/rubygems/resolver/conflict.rb1
-rw-r--r--lib/rubygems/resolver/dependency_request.rb36
-rw-r--r--lib/rubygems/resolver/git_specification.rb19
-rw-r--r--lib/rubygems/resolver/installed_specification.rb16
-rw-r--r--lib/rubygems/resolver/installer_set.rb3
-rw-r--r--lib/rubygems/resolver/local_specification.rb16
-rw-r--r--lib/rubygems/resolver/requirement_list.rb24
-rw-r--r--lib/rubygems/resolver/specification.rb29
-rw-r--r--lib/rubygems/resolver/vendor_set.rb2
-rw-r--r--lib/rubygems/resolver/vendor_specification.rb8
12 files changed, 178 insertions, 21 deletions
diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb
index ca82ac408a..2d48cfa927 100644
--- a/lib/rubygems/resolver/activation_request.rb
+++ b/lib/rubygems/resolver/activation_request.rb
@@ -1,21 +1,33 @@
##
-# Specifies a Specification object that should be activated.
-# Also contains a dependency that was used to introduce this
-# activation.
+# Specifies a Specification object that should be activated. Also contains a
+# dependency that was used to introduce this activation.
class Gem::Resolver::ActivationRequest
+ ##
+ # The parent request for this activation request.
+
attr_reader :request
+ ##
+ # The specification to be activated.
+
attr_reader :spec
- def initialize spec, req, others_possible = true
+ ##
+ # Creates a new ActivationRequest that will activate +spec+. The parent
+ # +request+ is used to provide diagnostics in case of conflicts.
+ #
+ # +others_possible+ indicates that other specifications may also match this
+ # activation request.
+
+ def initialize spec, request, others_possible = true
@spec = spec
- @request = req
+ @request = request
@others_possible = others_possible
end
- def == other
+ def == other # :nodoc:
case other
when Gem::Specification
@spec == other
@@ -26,6 +38,9 @@ class Gem::Resolver::ActivationRequest
end
end
+ ##
+ # Downloads a gem at +path+ and returns the file path.
+
def download path
if @spec.respond_to? :source
source = @spec.source
@@ -38,10 +53,16 @@ class Gem::Resolver::ActivationRequest
source.download full_spec, path
end
+ ##
+ # The full name of the specification to be activated.
+
def full_name
@spec.full_name
end
+ ##
+ # The Gem::Specification for this activation request.
+
def full_spec
Gem::Specification === @spec ? @spec : @spec.spec
end
@@ -66,7 +87,7 @@ class Gem::Resolver::ActivationRequest
end
##
- # Indicates if the requested gem has already been installed.
+ # True if the requested gem has already been installed.
def installed?
case @spec
@@ -81,6 +102,9 @@ class Gem::Resolver::ActivationRequest
end
end
+ ##
+ # The name of this activation request's specification
+
def name
@spec.name
end
@@ -130,6 +154,9 @@ class Gem::Resolver::ActivationRequest
end
end
+ ##
+ # The version of this activation request's specification
+
def version
@spec.version
end
diff --git a/lib/rubygems/resolver/api_specification.rb b/lib/rubygems/resolver/api_specification.rb
index 0ab8e830c6..67052af82e 100644
--- a/lib/rubygems/resolver/api_specification.rb
+++ b/lib/rubygems/resolver/api_specification.rb
@@ -34,6 +34,10 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
@dependencies == other.dependencies
end
+ def installable_platform? # :nodoc:
+ Gem::Platform.match @platform
+ end
+
def pretty_print q # :nodoc:
q.group 2, '[APISpecification', ']' do
q.breakable
diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb
index 20c6eced31..8830e8d1fb 100644
--- a/lib/rubygems/resolver/conflict.rb
+++ b/lib/rubygems/resolver/conflict.rb
@@ -95,7 +95,6 @@ class Gem::Resolver::Conflict
path = []
while current do
- spec_name = current.spec.full_name
requirement = current.request.dependency.requirement
path << "#{current.spec.full_name} (#{requirement})"
diff --git a/lib/rubygems/resolver/dependency_request.rb b/lib/rubygems/resolver/dependency_request.rb
index e63b443c62..1d51db4945 100644
--- a/lib/rubygems/resolver/dependency_request.rb
+++ b/lib/rubygems/resolver/dependency_request.rb
@@ -4,16 +4,26 @@
class Gem::Resolver::DependencyRequest
+ ##
+ # The wrapped Gem::Dependency
+
attr_reader :dependency
+ ##
+ # The request for this dependency.
+
attr_reader :requester
- def initialize(dep, act)
- @dependency = dep
- @requester = act
+ ##
+ # Creates a new DependencyRequest for +dependency+ from +requester+.
+ # +requester may be nil if the request came from a user.
+
+ def initialize dependency, requester
+ @dependency = dependency
+ @requester = requester
end
- def ==(other)
+ def == other # :nodoc:
case other
when Gem::Dependency
@dependency == other
@@ -24,26 +34,39 @@ class Gem::Resolver::DependencyRequest
end
end
+ ##
+ # Does this dependency request match +spec+
+
def matches_spec?(spec)
@dependency.matches_spec? spec
end
+ ##
+ # The name of the gem this dependency request is requesting.
+
def name
@dependency.name
end
+ ##
# Indicate that the request is for a gem explicitly requested by the user
+
def explicit?
@requester.nil?
end
- # Indicate that the requset is for a gem requested as a dependency of another gem
+ ##
+ # Indicate that the request is for a gem requested as a dependency of
+ # another gem
+
def implicit?
!explicit?
end
+ ##
# Return a String indicating who caused this request to be added (only
# valid for implicit requests)
+
def request_context
@requester ? @requester.request : "(unknown)"
end
@@ -59,6 +82,9 @@ class Gem::Resolver::DependencyRequest
end
end
+ ##
+ # The version requirement for this dependency request
+
def requirement
@dependency.requirement
end
diff --git a/lib/rubygems/resolver/git_specification.rb b/lib/rubygems/resolver/git_specification.rb
index ac8d4e9aeb..113e7ea9de 100644
--- a/lib/rubygems/resolver/git_specification.rb
+++ b/lib/rubygems/resolver/git_specification.rb
@@ -12,5 +12,24 @@ 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
+ installer.spec = spec
+
+ yield installer if block_given?
+
+ installer.run_pre_install_hooks
+ installer.build_extensions
+ installer.run_post_build_hooks
+ installer.generate_bin
+ installer.run_post_install_hooks
+ end
+
end
diff --git a/lib/rubygems/resolver/installed_specification.rb b/lib/rubygems/resolver/installed_specification.rb
index 647ff7499a..a9438129fb 100644
--- a/lib/rubygems/resolver/installed_specification.rb
+++ b/lib/rubygems/resolver/installed_specification.rb
@@ -11,16 +11,22 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
end
##
+ # This is a null install as this specification is already installed.
+ # +options+ are ignored.
+
+ def install options
+ yield nil
+ end
+
+ ##
# Returns +true+ if this gem is installable for the current platform.
def installable_platform?
# BACKCOMPAT If the file is coming out of a specified file, then we
# ignore the platform. This code can be removed in RG 3.0.
- if @source.kind_of? Gem::Source::SpecificFile
- return true
- else
- Gem::Platform.match @spec.platform
- end
+ return true if @source.kind_of? Gem::Source::SpecificFile
+
+ super
end
##
diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
index 73d9e39651..e35e0aabec 100644
--- a/lib/rubygems/resolver/installer_set.rb
+++ b/lib/rubygems/resolver/installer_set.rb
@@ -20,6 +20,9 @@ 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
@domain = domain
diff --git a/lib/rubygems/resolver/local_specification.rb b/lib/rubygems/resolver/local_specification.rb
new file mode 100644
index 0000000000..dcca6c736a
--- /dev/null
+++ b/lib/rubygems/resolver/local_specification.rb
@@ -0,0 +1,16 @@
+##
+# A LocalSpecification comes from a .gem file on the local filesystem.
+
+class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification
+
+ ##
+ # Returns +true+ if this gem is installable for the current platform.
+
+ def installable_platform?
+ return true if @source.kind_of? Gem::Source::SpecificFile
+
+ super
+ end
+
+end
+
diff --git a/lib/rubygems/resolver/requirement_list.rb b/lib/rubygems/resolver/requirement_list.rb
index 04e437b2a9..fe1d77afc3 100644
--- a/lib/rubygems/resolver/requirement_list.rb
+++ b/lib/rubygems/resolver/requirement_list.rb
@@ -1,19 +1,28 @@
##
-# Used internally to hold the requirements being considered
-# while attempting to find a proper activation set.
+# The RequirementList is used to hold the requirements being considered
+# while resolving a set of gems.
+#
+# The RequirementList acts like a queue where the oldest items are removed
+# first.
class Gem::Resolver::RequirementList
include Enumerable
+ ##
+ # Creates a new RequirementList.
+
def initialize
@list = []
end
- def initialize_copy(other)
+ def initialize_copy other # :nodoc:
@list = @list.dup
end
+ ##
+ # Adds Resolver::DependencyRequest +req+ to this requirements list.
+
def add(req)
@list.push req
req
@@ -30,14 +39,23 @@ class Gem::Resolver::RequirementList
end
end
+ ##
+ # Is the list empty?
+
def empty?
@list.empty?
end
+ ##
+ # Remove the oldest DependencyRequest from the list.
+
def remove
@list.shift
end
+ ##
+ # Returns the oldest five entries from the list.
+
def next5
@list[0,5]
end
diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb
index 7dd4c2e829..d158225474 100644
--- a/lib/rubygems/resolver/specification.rb
+++ b/lib/rubygems/resolver/specification.rb
@@ -56,5 +56,34 @@ class Gem::Resolver::Specification
"#{@name}-#{@version}"
end
+ ##
+ # Installs this specification using the Gem::Installer +options+. The
+ # 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
+
+ Gem.ensure_gem_subdirectories destination
+
+ gem = source.download spec, destination
+
+ installer = Gem::Installer.new gem, options
+
+ yield installer if block_given?
+
+ installer.install
+ end
+
+ ##
+ # Returns true if this specification is installable on this platform.
+
+ def installable_platform?
+ Gem::Platform.match spec.platform
+ end
+
end
diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb
index e9cbcd8303..c8826005a7 100644
--- a/lib/rubygems/resolver/vendor_set.rb
+++ b/lib/rubygems/resolver/vendor_set.rb
@@ -32,6 +32,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
raise Gem::GemNotFoundException,
"unable to find #{gemspec} for gem #{name}" unless spec
+ spec.full_gem_path = File.expand_path directory
+
key = "#{spec.name}-#{spec.version}-#{spec.platform}"
@specs[key] = spec
diff --git a/lib/rubygems/resolver/vendor_specification.rb b/lib/rubygems/resolver/vendor_specification.rb
index 24e033d084..c6a8e58d9b 100644
--- a/lib/rubygems/resolver/vendor_specification.rb
+++ b/lib/rubygems/resolver/vendor_specification.rb
@@ -12,5 +12,13 @@ class Gem::Resolver::VendorSpecification < Gem::Resolver::SpecSpecification
@source == other.source
end
+ ##
+ # This is a null install as this gem was unpacked into a directory.
+ # +options+ are ignored.
+
+ def install options
+ yield nil
+ end
+
end