1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980).

this version includes #1367 , #1373 , #1375
* test/rubygems: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2015-11-12 04:50:06 +00:00
parent 8b129406c6
commit a2ba489e2e
10 changed files with 190 additions and 128 deletions

View file

@ -37,6 +37,14 @@ class Gem::BasicSpecification
File.join(Gem.default_dir, "specifications", "default")
end
##
# The path to the gem.build_complete file within the extension install
# directory.
def gem_build_complete_path # :nodoc:
File.join extension_dir, 'gem.build_complete'
end
##
# True when the gem has been activated
@ -50,12 +58,7 @@ class Gem::BasicSpecification
# eg: /usr/local/lib/ruby/gems/1.8
def base_dir
return Gem.dir unless loaded_from
@base_dir ||= if default_gem? then
File.dirname File.dirname File.dirname loaded_from
else
File.dirname File.dirname loaded_from
end
raise NotImplementedError
end
##
@ -65,7 +68,7 @@ class Gem::BasicSpecification
@contains_requirable_file ||= {}
@contains_requirable_file[file] ||=
begin
if instance_variable_defined?(:@ignored) then
if @ignored then
return false
elsif missing_extensions? then
@ignored = true
@ -75,12 +78,7 @@ class Gem::BasicSpecification
return false
end
suffixes = Gem.suffixes
full_require_paths.any? do |dir|
base = "#{dir}/#{file}"
suffixes.any? { |suf| File.file? "#{base}#{suf}" }
end
have_file? file, Gem.suffixes
end ? :yes : :no
@contains_requirable_file[file] == :yes
end
@ -94,7 +92,7 @@ class Gem::BasicSpecification
# Returns full path to the directory where gem's extensions are installed.
def extension_dir
@extension_dir ||= File.expand_path File.join(extensions_dir, full_name)
@extension_dir ||= File.expand_path(File.join(extensions_dir, full_name)).untaint
end
##
@ -110,7 +108,7 @@ class Gem::BasicSpecification
# TODO: also, shouldn't it default to full_name if it hasn't been written?
path = File.expand_path File.join(gems_dir, full_name)
path.untaint
path if File.directory? path
path
end
private :find_full_gem_path
@ -148,12 +146,20 @@ class Gem::BasicSpecification
File.join full_gem_path, path.untaint
end
full_paths << extension_dir unless @extensions.nil? || @extensions.empty?
full_paths << extension_dir if have_extensions?
full_paths
end
end
##
# The path to the data directory for this gem.
def datadir
# TODO: drop the extra ", gem_name" which is uselessly redundant
File.expand_path(File.join(gems_dir, full_name, "data", name)).untaint
end
##
# Full path of the target library file.
# If the file is not in this gem, return nil.
@ -189,8 +195,7 @@ class Gem::BasicSpecification
# gem directory. eg: /usr/local/lib/ruby/1.8/gems
def gems_dir
# TODO: this logic seems terribly broken, but tests fail if just base_dir
@gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
raise NotImplementedError
end
def internal_init # :nodoc:
@ -198,8 +203,7 @@ class Gem::BasicSpecification
@extensions_dir = nil
@full_gem_path = nil
@gem_dir = nil
@gems_dir = nil
@base_dir = nil
@ignored = nil
end
##
@ -217,7 +221,7 @@ class Gem::BasicSpecification
end
def raw_require_paths # :nodoc:
Array(@require_paths)
raise NotImplementedError
end
##
@ -238,7 +242,7 @@ class Gem::BasicSpecification
# spec.require_path = '.'
def require_paths
return raw_require_paths if @extensions.nil? || @extensions.empty?
return raw_require_paths unless have_extensions?
[extension_dir].concat raw_require_paths
end
@ -250,8 +254,8 @@ class Gem::BasicSpecification
def source_paths
paths = raw_require_paths.dup
if @extensions then
ext_dirs = @extensions.map do |extension|
if have_extensions? then
ext_dirs = extensions.map do |extension|
extension.split(File::SEPARATOR, 2).first
end.uniq
@ -307,5 +311,23 @@ class Gem::BasicSpecification
raise NotImplementedError
end
private
def have_extensions?; !extensions.empty?; end
def have_file? file, suffixes
return true if raw_require_paths.any? do |path|
base = File.join(gems_dir, full_name, path.untaint, file).untaint
suffixes.any? { |suf| File.file? base + suf }
end
if have_extensions?
base = File.join extension_dir, file
suffixes.any? { |suf| File.file? base + suf }
else
false
end
end
end