diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-04 06:21:53 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-04 06:21:53 +0000 |
commit | 395d8788565b8fca8cd55c81dd2be2448517a6ad (patch) | |
tree | 729ecf1549356e45f778666a8806420c8223d05d /lib | |
parent | f104dc7fe7649c1f8fd12ca32381e5db71b20d91 (diff) | |
download | ruby-395d8788565b8fca8cd55c81dd2be2448517a6ad.tar.gz |
* lib/rubygems: Update to RubyGems 2.5.0+ HEAD(fdab4c4).
this version includes #1396, #1397, #1398, #1399
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/basic_specification.rb | 25 | ||||
-rwxr-xr-x | lib/rubygems/core_ext/kernel_require.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/requirement.rb | 6 | ||||
-rw-r--r-- | lib/rubygems/specification.rb | 24 | ||||
-rw-r--r-- | lib/rubygems/stub_specification.rb | 2 |
5 files changed, 35 insertions, 26 deletions
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 3e411f33bc..53beb43402 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -65,22 +65,17 @@ class Gem::BasicSpecification # Return true if this spec can require +file+. def contains_requirable_file? file - @contains_requirable_file ||= {} - @contains_requirable_file[file] ||= - begin - if @ignored then - return false - elsif missing_extensions? then - @ignored = true - - warn "Ignoring #{full_name} because its extensions are not built. " + - "Try: gem pristine #{name} --version #{version}" - return false - end + if @ignored then + return false + elsif missing_extensions? then + @ignored = true + + warn "Ignoring #{full_name} because its extensions are not built. " + + "Try: gem pristine #{name} --version #{version}" + return false + end - have_file? file, Gem.suffixes - end ? :yes : :no - @contains_requirable_file[file] == :yes + have_file? file, Gem.suffixes end def default_gem? diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb index 0a073adb7b..f9b67ea5a6 100755 --- a/lib/rubygems/core_ext/kernel_require.rb +++ b/lib/rubygems/core_ext/kernel_require.rb @@ -60,9 +60,7 @@ module Kernel #-- # TODO request access to the C implementation of this to speed up RubyGems - spec = Gem::Specification.stubs.find { |s| - s.activated? and s.contains_requirable_file? path - } + spec = Gem::Specification.find_active_stub_by_path path begin RUBYGEMS_ACTIVATION_MONITOR.exit diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb index 572bf9673e..de16926573 100644 --- a/lib/rubygems/requirement.rb +++ b/lib/rubygems/requirement.rb @@ -89,9 +89,9 @@ class Gem::Requirement # specification, like <tt>">= 1.2"</tt>, or a simple version number, # like <tt>"1.2"</tt>. # - # parse("> 1.0") # => [">", "1.0"] - # parse("1.0") # => ["=", "1.0"] - # parse(Gem::Version.new("1.0")) # => ["=, "1.0"] + # parse("> 1.0") # => [">", Gem::Version.new("1.0")] + # parse("1.0") # => ["=", Gem::Version.new("1.0")] + # parse(Gem::Version.new("1.0")) # => ["=, Gem::Version.new("1.0")] def self.parse obj return ["=", obj] if Gem::Version === obj diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 1be285e4ef..50c27aa272 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -175,6 +175,11 @@ class Gem::Specification < Gem::BasicSpecification @@stubs_by_name = {} + # Sentinel object to represent "not found" stubs + NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc: + @@spec_with_requirable_file = {} + @@active_stub_with_requirable_file = {} + ###################################################################### # :section: Required gemspec attributes @@ -1027,10 +1032,10 @@ class Gem::Specification < Gem::BasicSpecification def self.find_by_path path path = path.dup.freeze - stub = stubs.find { |spec| - spec.contains_requirable_file? path - } - stub && stub.to_spec + spec = @@spec_with_requirable_file[path] ||= (stubs.find { |s| + s.contains_requirable_file? path + } || NOT_FOUND) + spec.to_spec end ## @@ -1044,6 +1049,13 @@ class Gem::Specification < Gem::BasicSpecification stub && stub.to_spec end + def self.find_active_stub_by_path path + stub = @@active_stub_with_requirable_file[path] ||= (stubs.find { |s| + s.activated? and s.contains_requirable_file? path + } || NOT_FOUND) + stub.this + end + ## # Return currently unresolved specs that contain the file matching +path+. @@ -1261,6 +1273,8 @@ class Gem::Specification < Gem::BasicSpecification @@all = nil @@stubs = nil @@stubs_by_name = {} + @@spec_with_requirable_file = {} + @@active_stub_with_requirable_file = {} _clear_load_cache unresolved = unresolved_deps unless unresolved.empty? then @@ -2847,7 +2861,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use: end warning_messages << "prerelease dependency on #{dep} is not recommended" if - prerelease_dep + prerelease_dep && !version.prerelease? overly_strict = dep.requirement.requirements.length == 1 && dep.requirement.requirements.any? do |op, version| diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index 7ba0964d15..482a75bd48 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -88,6 +88,8 @@ class Gem::StubSpecification < Gem::BasicSpecification end end + def this; self; end + def default_gem? @default_gem end |