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

Merge RubyGems 2.7.7

see release details here: https://blog.rubygems.org/2018/05/18/2.7.7-released.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2018-05-18 01:39:13 +00:00
parent ecedebab2c
commit c6da9cadb3
29 changed files with 161 additions and 60 deletions

View file

@ -10,7 +10,7 @@ require 'rbconfig'
require 'thread' require 'thread'
module Gem module Gem
VERSION = "2.7.6" VERSION = "2.7.7"
end end
# Must be first since it unloads the prelude from 1.9.2 # Must be first since it unloads the prelude from 1.9.2
@ -604,7 +604,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
private_class_method :find_home private_class_method :find_home
# FIXME deprecate these in 3.0 # TODO: remove in RubyGems 4.0
## ##
# Zlib::GzipReader wrapper that unzips +data+. # Zlib::GzipReader wrapper that unzips +data+.
@ -613,6 +613,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
Gem::Util.gunzip data Gem::Util.gunzip data
end end
class << self
extend Gem::Deprecate
deprecate :gunzip, "Gem::Util.gunzip", 2018, 12
end
## ##
# Zlib::GzipWriter wrapper that zips +data+. # Zlib::GzipWriter wrapper that zips +data+.
@ -620,6 +625,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
Gem::Util.gzip data Gem::Util.gzip data
end end
class << self
extend Gem::Deprecate
deprecate :gzip, "Gem::Util.gzip", 2018, 12
end
## ##
# A Zlib::Inflate#inflate wrapper # A Zlib::Inflate#inflate wrapper
@ -627,6 +637,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
Gem::Util.inflate data Gem::Util.inflate data
end end
class << self
extend Gem::Deprecate
deprecate :inflate, "Gem::Util.inflate", 2018, 12
end
## ##
# Top level install helper method. Allows you to install gems interactively: # Top level install helper method. Allows you to install gems interactively:
# #
@ -1225,9 +1240,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
class << self class << self
## ##
# TODO remove with RubyGems 3.0 # TODO remove with RubyGems 4.0
alias detect_gemdeps use_gemdeps # :nodoc: alias detect_gemdeps use_gemdeps # :nodoc:
extend Gem::Deprecate
deprecate :detect_gemdeps, "Gem.use_gemdeps", 2018, 12
end end
# FIX: Almost everywhere else we use the `def self.` way of defining class # FIX: Almost everywhere else we use the `def self.` way of defining class

View file

@ -1,3 +1,7 @@
# frozen_string_literal: true
require "rubygems/util"
module Gem::BundlerVersionFinder module Gem::BundlerVersionFinder
@without_filtering = false @without_filtering = false
@ -102,7 +106,7 @@ To install the missing version, run `gem install bundler:#{vr.first}`
lockfile = case gemfile lockfile = case gemfile
when "gems.rb" then "gems.locked" when "gems.rb" then "gems.locked"
else "#{gemfile}.lock" else "#{gemfile}.lock"
end.untaint end.dup.untaint
return unless File.file?(lockfile) return unless File.file?(lockfile)

View file

@ -13,7 +13,7 @@ class Gem::Commands::PushCommand < Gem::Command
The push command uploads a gem to the push server (the default is The push command uploads a gem to the push server (the default is
https://rubygems.org) and adds it to the index. https://rubygems.org) and adds it to the index.
The gem can be removed from the index (but only the index) using the yank The gem can be removed from the index and deleted from the server using the yank
command. For further discussion see the help for the yank command. command. For further discussion see the help for the yank command.
EOF EOF
end end

View file

@ -385,7 +385,7 @@ By default, this RubyGems will install gem as:
each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) }
end end
bundler_bin_dir = File.join(Gem.default_dir, 'gems', bundler_spec.full_name, bundler_spec.bindir) bundler_bin_dir = bundler_spec.bin_dir
bundler_bin_dir = File.join(options[:destdir], bundler_bin_dir) unless Gem.win_platform? bundler_bin_dir = File.join(options[:destdir], bundler_bin_dir) unless Gem.win_platform?
mkdir_p bundler_bin_dir mkdir_p bundler_bin_dir
bundler_spec.executables.each do |e| bundler_spec.executables.each do |e|

View file

@ -183,7 +183,7 @@ command help for an example.
when 'metadata' then when 'metadata' then
metadata = entry.read metadata = entry.read
when 'metadata.gz' then when 'metadata.gz' then
metadata = Gem.gunzip entry.read metadata = Gem::Util.gunzip entry.read
end end
end end
end end

View file

@ -2,6 +2,7 @@
## ##
# The Dependency class holds a Gem name and a Gem::Requirement. # The Dependency class holds a Gem name and a Gem::Requirement.
require "rubygems/bundler_version_finder"
require "rubygems/requirement" require "rubygems/requirement"
class Gem::Dependency class Gem::Dependency

View file

@ -113,7 +113,7 @@ class Gem::DependencyInstaller
## ##
#-- #--
# TODO remove, no longer used # TODO remove at RubyGems 4, no longer used
def add_found_dependencies to_do, dependency_list # :nodoc: def add_found_dependencies to_do, dependency_list # :nodoc:
seen = {} seen = {}
@ -163,6 +163,7 @@ class Gem::DependencyInstaller
dependency_list.remove_specs_unsatisfied_by dependencies dependency_list.remove_specs_unsatisfied_by dependencies
end end
deprecate :add_found_dependencies, :none, 2018, 12
## ##
# Creates an AvailableSet to install from based on +dep_or_name+ and # Creates an AvailableSet to install from based on +dep_or_name+ and
@ -321,7 +322,7 @@ class Gem::DependencyInstaller
# Gathers all dependencies necessary for the installation from local and # Gathers all dependencies necessary for the installation from local and
# remote sources unless the ignore_dependencies was given. # remote sources unless the ignore_dependencies was given.
#-- #--
# TODO remove at RubyGems 3 # TODO remove at RubyGems 4
def gather_dependencies # :nodoc: def gather_dependencies # :nodoc:
specs = @available.all_specs specs = @available.all_specs
@ -354,6 +355,7 @@ class Gem::DependencyInstaller
@gems_to_install = dependency_list.dependency_order.reverse @gems_to_install = dependency_list.dependency_order.reverse
end end
deprecate :gather_dependencies, :none, 2018, 12
def in_background what # :nodoc: def in_background what # :nodoc:
fork_happened = false fork_happened = false

View file

@ -4,6 +4,8 @@
# Each exception needs a brief description and the scenarios where it is # Each exception needs a brief description and the scenarios where it is
# likely to be raised # likely to be raised
require 'rubygems/deprecate'
## ##
# Base exception class for RubyGems. All exception raised by RubyGems are a # Base exception class for RubyGems. All exception raised by RubyGems are a
# subclass of this one. # subclass of this one.
@ -11,10 +13,12 @@ class Gem::Exception < RuntimeError
## ##
#-- #--
# TODO: remove in RubyGems 3, nobody sets this # TODO: remove in RubyGems 4, nobody sets this
attr_accessor :source_exception # :nodoc: attr_accessor :source_exception # :nodoc:
extend Gem::Deprecate
deprecate :source_exception, :none, 2018, 12
end end
class Gem::CommandLineError < Gem::Exception; end class Gem::CommandLineError < Gem::Exception; end

View file

@ -347,7 +347,7 @@ class Gem::Indexer
data = Gem.read_binary path data = Gem.read_binary path
compressed_data = Gem.read_binary "#{path}.#{extension}" compressed_data = Gem.read_binary "#{path}.#{extension}"
unless data == Gem.inflate(compressed_data) then unless data == Gem::Util.inflate(compressed_data) then
raise "Compressed file #{compressed_path} does not match uncompressed file #{path}" raise "Compressed file #{compressed_path} does not match uncompressed file #{path}"
end end
end end

View file

@ -7,6 +7,7 @@
require 'rubygems/command' require 'rubygems/command'
require 'rubygems/exceptions' require 'rubygems/exceptions'
require 'rubygems/deprecate'
require 'rubygems/package' require 'rubygems/package'
require 'rubygems/ext' require 'rubygems/ext'
require 'rubygems/user_interaction' require 'rubygems/user_interaction'
@ -27,6 +28,8 @@ require 'fileutils'
class Gem::Installer class Gem::Installer
extend Gem::Deprecate
## ##
# Paths where env(1) might live. Some systems are broken and have it in # Paths where env(1) might live. Some systems are broken and have it in
# /bin # /bin
@ -777,13 +780,14 @@ TEXT
## ##
# Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError. # Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError.
# #
# TODO: Delete this for RubyGems 3. It remains for API compatibility # TODO: Delete this for RubyGems 4. It remains for API compatibility
def extension_build_error(build_dir, output, backtrace = nil) # :nodoc: def extension_build_error(build_dir, output, backtrace = nil) # :nodoc:
builder = Gem::Ext::Builder.new spec, @build_args builder = Gem::Ext::Builder.new spec, @build_args
builder.build_error build_dir, output, backtrace builder.build_error build_dir, output, backtrace
end end
deprecate :extension_build_error, :none, 2018, 12
## ##
# Reads the file index and extracts each file into the gem directory. # Reads the file index and extracts each file into the gem directory.

View file

@ -429,6 +429,14 @@ EOM
destination destination
end end
def normalize_path(pathname)
if Gem.win_platform?
pathname.downcase
else
pathname
end
end
def mkdir_p_safe mkdir, mkdir_options, destination_dir, file_name def mkdir_p_safe mkdir, mkdir_options, destination_dir, file_name
destination_dir = realpath File.expand_path(destination_dir) destination_dir = realpath File.expand_path(destination_dir)
parts = mkdir.split(File::SEPARATOR) parts = mkdir.split(File::SEPARATOR)
@ -437,7 +445,7 @@ EOM
path = File.expand_path(path + File::SEPARATOR + basename) path = File.expand_path(path + File::SEPARATOR + basename)
lstat = File.lstat path rescue nil lstat = File.lstat path rescue nil
if !lstat || !lstat.directory? if !lstat || !lstat.directory?
unless path.start_with? destination_dir and (FileUtils.mkdir path, mkdir_options rescue false) unless normalize_path(path).start_with? normalize_path(destination_dir) and (FileUtils.mkdir path, mkdir_options rescue false)
raise Gem::Package::PathError.new(file_name, destination_dir) raise Gem::Package::PathError.new(file_name, destination_dir)
end end
end end
@ -591,7 +599,7 @@ EOM
end end
case file_name case file_name
when /^metadata(.gz)?$/ then when "metadata", "metadata.gz" then
load_spec entry load_spec entry
when 'data.tar.gz' then when 'data.tar.gz' then
verify_gz entry verify_gz entry

View file

@ -293,7 +293,7 @@ class Gem::RemoteFetcher
if data and !head and uri.to_s =~ /\.gz$/ if data and !head and uri.to_s =~ /\.gz$/
begin begin
data = Gem.gunzip data data = Gem::Util.gunzip data
rescue Zlib::GzipFile::Error rescue Zlib::GzipFile::Error
raise FetchError.new("server did not return a valid file", uri.to_s) raise FetchError.new("server did not return a valid file", uri.to_s)
end end

View file

@ -171,7 +171,9 @@ class Gem::RequestSet
rescue Gem::RuntimeRequirementNotMetError => e rescue Gem::RuntimeRequirementNotMetError => e
recent_match = req.spec.set.find_all(req.request).sort_by(&:version).reverse_each.find do |s| recent_match = req.spec.set.find_all(req.request).sort_by(&:version).reverse_each.find do |s|
s = s.spec s = s.spec
s.required_ruby_version.satisfied_by?(Gem.ruby_version) && s.required_rubygems_version.satisfied_by?(Gem.rubygems_version) s.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
s.required_rubygems_version.satisfied_by?(Gem.rubygems_version) &&
Gem::Platform.installable?(s)
end end
if recent_match if recent_match
suggestion = "The last version of #{req.request} to support your Ruby & RubyGems was #{recent_match.version}. Try installing it with `gem install #{recent_match.name} -v #{recent_match.version}`" suggestion = "The last version of #{req.request} to support your Ruby & RubyGems was #{recent_match.version}. Try installing it with `gem install #{recent_match.name} -v #{recent_match.version}`"

View file

@ -492,7 +492,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs = Marshal.dump specs specs = Marshal.dump specs
if req.path =~ /\.gz$/ then if req.path =~ /\.gz$/ then
specs = Gem.gzip specs specs = Gem::Util.gzip specs
res['content-type'] = 'application/x-gzip' res['content-type'] = 'application/x-gzip'
else else
res['content-type'] = 'application/octet-stream' res['content-type'] = 'application/octet-stream'
@ -553,7 +553,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs = Marshal.dump specs specs = Marshal.dump specs
if req.path =~ /\.gz$/ then if req.path =~ /\.gz$/ then
specs = Gem.gzip specs specs = Gem::Util.gzip specs
res['content-type'] = 'application/x-gzip' res['content-type'] = 'application/x-gzip'
else else
res['content-type'] = 'application/octet-stream' res['content-type'] = 'application/octet-stream'
@ -852,7 +852,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs = Marshal.dump specs specs = Marshal.dump specs
if req.path =~ /\.gz$/ then if req.path =~ /\.gz$/ then
specs = Gem.gzip specs specs = Gem::Util.gzip specs
res['content-type'] = 'application/x-gzip' res['content-type'] = 'application/x-gzip'
else else
res['content-type'] = 'application/octet-stream' res['content-type'] = 'application/octet-stream'

View file

@ -155,7 +155,7 @@ class Gem::Source
uri.path << '.rz' uri.path << '.rz'
spec = fetcher.fetch_path uri spec = fetcher.fetch_path uri
spec = Gem.inflate spec spec = Gem::Util.inflate spec
if update_cache? then if update_cache? then
FileUtils.mkdir_p cache_dir FileUtils.mkdir_p cache_dir

View file

@ -40,6 +40,8 @@ require 'uri'
class Gem::Specification < Gem::BasicSpecification class Gem::Specification < Gem::BasicSpecification
extend Gem::Deprecate
# REFACTOR: Consider breaking out this version stuff into a separate # REFACTOR: Consider breaking out this version stuff into a separate
# module. There's enough special stuff around it that it may justify # module. There's enough special stuff around it that it may justify
# a separate class. # a separate class.
@ -715,6 +717,7 @@ class Gem::Specification < Gem::BasicSpecification
# Deprecated: You must now specify the executable name to Gem.bin_path. # Deprecated: You must now specify the executable name to Gem.bin_path.
attr_writer :default_executable attr_writer :default_executable
deprecate :default_executable=, :none, 2018, 12
## ##
# Allows deinstallation of gems with legacy platforms. # Allows deinstallation of gems with legacy platforms.
@ -1810,6 +1813,7 @@ class Gem::Specification < Gem::BasicSpecification
end end
result result
end end
deprecate :default_executable, :none, 2018, 12
## ##
# The default value for specification attribute +name+ # The default value for specification attribute +name+
@ -2018,6 +2022,7 @@ class Gem::Specification < Gem::BasicSpecification
def has_rdoc # :nodoc: def has_rdoc # :nodoc:
true true
end end
deprecate :has_rdoc, :none, 2018, 12
## ##
# Deprecated and ignored. # Deprecated and ignored.
@ -2027,8 +2032,10 @@ class Gem::Specification < Gem::BasicSpecification
def has_rdoc= ignored # :nodoc: def has_rdoc= ignored # :nodoc:
@has_rdoc = true @has_rdoc = true
end end
deprecate :has_rdoc=, :none, 2018, 12
alias :has_rdoc? :has_rdoc # :nodoc: alias :has_rdoc? :has_rdoc # :nodoc:
deprecate :has_rdoc?, :none, 2018, 12
## ##
# True if this gem has files in test_files # True if this gem has files in test_files
@ -3074,16 +3081,6 @@ open-ended dependency on #{dep} is not recommended
@require_paths @require_paths
end end
extend Gem::Deprecate
# TODO:
# deprecate :has_rdoc, :none, 2011, 10
# deprecate :has_rdoc?, :none, 2011, 10
# deprecate :has_rdoc=, :none, 2011, 10
# deprecate :default_executable, :none, 2011, 10
# deprecate :default_executable=, :none, 2011, 10
# deprecate :file_name, :cache_file, 2011, 10
# deprecate :full_gem_path, :cache_file, 2011, 10
end end
# DOC: What is this and why is it here, randomly, at the end of this file? # DOC: What is this and why is it here, randomly, at the end of this file?

View file

@ -88,6 +88,8 @@ end
class Gem::TestCase < MiniTest::Unit::TestCase class Gem::TestCase < MiniTest::Unit::TestCase
extend Gem::Deprecate
attr_accessor :fetcher # :nodoc: attr_accessor :fetcher # :nodoc:
attr_accessor :gem_repo # :nodoc: attr_accessor :gem_repo # :nodoc:
@ -672,11 +674,13 @@ class Gem::TestCase < MiniTest::Unit::TestCase
end end
## ##
# TODO: remove in RubyGems 3.0 # TODO: remove in RubyGems 4.0
def quick_spec name, version = '2' # :nodoc: def quick_spec name, version = '2' # :nodoc:
util_spec name, version util_spec name, version
end end
deprecate :quick_spec, :util_spec, 2018, 12
## ##
# Builds a gem from +spec+ and places it in <tt>File.join @gemhome, # Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
@ -774,7 +778,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
## ##
# new_spec is deprecated as it is never used. # new_spec is deprecated as it is never used.
# #
# TODO: remove in RubyGems 3.0 # TODO: remove in RubyGems 4.0
def new_spec name, version, deps = nil, *files # :nodoc: def new_spec name, version, deps = nil, *files # :nodoc:
require 'rubygems/specification' require 'rubygems/specification'
@ -815,6 +819,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
spec spec
end end
# TODO: mark deprecate after replacing util_spec from new_spec
# deprecate :new_spec, :none, 2018, 12
def new_default_spec(name, version, deps = nil, *files) def new_default_spec(name, version, deps = nil, *files)
spec = util_spec name, version, deps spec = util_spec name, version, deps

View file

@ -64,7 +64,7 @@ class Gem::FakeFetcher
data.call data.call
else else
if path.to_s =~ /gz$/ and not data.nil? and not data.empty? then if path.to_s =~ /gz$/ and not data.nil? and not data.empty? then
data = Gem.gunzip data data = Gem::Util.gunzip data
end end
data data

View file

@ -6,6 +6,7 @@
#++ #++
require 'rubygems/util' require 'rubygems/util'
require 'rubygems/deprecate'
## ##
# Module that defines the default UserInteraction. Any class including this # Module that defines the default UserInteraction. Any class including this
@ -170,6 +171,8 @@ end
class Gem::StreamUI class Gem::StreamUI
extend Gem::Deprecate
## ##
# The input stream # The input stream
@ -384,6 +387,7 @@ class Gem::StreamUI
def debug(statement) def debug(statement)
@errs.puts statement @errs.puts statement
end end
deprecate :debug, :none, 2018, 12
## ##
# Terminate the application with exit code +status+, running any exit # Terminate the application with exit code +status+, running any exit

View file

@ -170,6 +170,7 @@ class Gem::Version
# True if the +version+ string matches RubyGems' requirements. # True if the +version+ string matches RubyGems' requirements.
def self.correct? version def self.correct? version
return false if version.nil?
!!(version.to_s =~ ANCHORED_VERSION_PATTERN) !!(version.to_s =~ ANCHORED_VERSION_PATTERN)
end end

View file

@ -387,7 +387,7 @@ class TestGem < Gem::TestCase
assert_equal %w[https://rubygems.org/], Gem.default_sources assert_equal %w[https://rubygems.org/], Gem.default_sources
end end
def test_self_detect_gemdeps def test_self_use_gemdeps
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-' rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
@ -399,7 +399,7 @@ class TestGem < Gem::TestCase
begin begin
Dir.chdir 'detect/a/b' Dir.chdir 'detect/a/b'
assert_equal add_bundler_full_name([]), Gem.detect_gemdeps.map(&:full_name) assert_equal add_bundler_full_name([]), Gem.use_gemdeps.map(&:full_name)
ensure ensure
Dir.chdir @tempdir Dir.chdir @tempdir
end end
@ -1214,7 +1214,7 @@ class TestGem < Gem::TestCase
input = "\x1F\x8B\b\0\xED\xA3\x1AQ\0\x03\xCBH" + input = "\x1F\x8B\b\0\xED\xA3\x1AQ\0\x03\xCBH" +
"\xCD\xC9\xC9\a\0\x86\xA6\x106\x05\0\0\0" "\xCD\xC9\xC9\a\0\x86\xA6\x106\x05\0\0\0"
output = Gem.gunzip input output = Gem::Util.gunzip input
assert_equal 'hello', output assert_equal 'hello', output
@ -1226,7 +1226,7 @@ class TestGem < Gem::TestCase
def test_self_gzip def test_self_gzip
input = 'hello' input = 'hello'
output = Gem.gzip input output = Gem::Util.gzip input
zipped = StringIO.new output zipped = StringIO.new output
@ -1450,12 +1450,12 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = path ENV['RUBYGEMS_GEMDEPS'] = path
Gem.detect_gemdeps Gem.use_gemdeps
assert_equal add_bundler_full_name(%W(a-1 b-1 c-1)), loaded_spec_names assert_equal add_bundler_full_name(%W(a-1 b-1 c-1)), loaded_spec_names
end end
def test_auto_activation_of_detected_gemdeps_file def test_auto_activation_of_used_gemdeps_file
skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7" skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
util_clear_gems util_clear_gems
@ -1476,7 +1476,7 @@ class TestGem < Gem::TestCase
ENV['RUBYGEMS_GEMDEPS'] = "-" ENV['RUBYGEMS_GEMDEPS'] = "-"
expected_specs = [a, b, (Gem::USE_BUNDLER_FOR_GEMDEPS || nil) && util_spec("bundler", Bundler::VERSION), c].compact expected_specs = [a, b, (Gem::USE_BUNDLER_FOR_GEMDEPS || nil) && util_spec("bundler", Bundler::VERSION), c].compact
assert_equal expected_specs, Gem.detect_gemdeps.sort_by { |s| s.name } assert_equal expected_specs, Gem.use_gemdeps.sort_by { |s| s.name }
end end
LIB_PATH = File.expand_path "../../../lib".dup.untaint, __FILE__.dup.untaint LIB_PATH = File.expand_path "../../../lib".dup.untaint, __FILE__.dup.untaint

View file

@ -10,7 +10,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
if File.exist?(bundler_gemspec) if File.exist?(bundler_gemspec)
BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1] BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1]
else else
BUNDLER_VERS = "1.16.1" BUNDLER_VERS = "1.16.2"
end end
def setup def setup

View file

@ -524,6 +524,21 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_path_exists extracted assert_path_exists extracted
end end
if Gem.win_platform?
def test_extract_tar_gz_case_insensitive
package = Gem::Package.new @gem
tgz_io = util_tar_gz do |tar|
tar.add_file 'foo/file.rb', 0644 do |io| io.write 'hi' end
end
package.extract_tar_gz tgz_io, @destination.upcase
extracted = File.join @destination, 'foo/file.rb'
assert_path_exists extracted
end
end
def test_install_location def test_install_location
package = Gem::Package.new @gem package = Gem::Package.new @gem
@ -607,7 +622,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end end
def test_load_spec def test_load_spec
entry = StringIO.new Gem.gzip @spec.to_yaml entry = StringIO.new Gem::Util.gzip @spec.to_yaml
def entry.full_name() 'metadata.gz' end def entry.full_name() 'metadata.gz' end
package = Gem::Package.new 'nonexistent.gem' package = Gem::Package.new 'nonexistent.gem'
@ -637,7 +652,7 @@ class TestGemPackage < Gem::Package::TarTestCase
data_tgz = data_tgz.string data_tgz = data_tgz.string
gem = util_tar do |tar| gem = util_tar do |tar|
metadata_gz = Gem.gzip @spec.to_yaml metadata_gz = Gem::Util.gzip @spec.to_yaml
tar.add_file 'metadata.gz', 0444 do |io| tar.add_file 'metadata.gz', 0444 do |io|
io.write metadata_gz io.write metadata_gz
@ -684,7 +699,7 @@ class TestGemPackage < Gem::Package::TarTestCase
data_tgz = data_tgz.string data_tgz = data_tgz.string
gem = util_tar do |tar| gem = util_tar do |tar|
metadata_gz = Gem.gzip @spec.to_yaml metadata_gz = Gem::Util.gzip @spec.to_yaml
tar.add_file 'metadata.gz', 0444 do |io| tar.add_file 'metadata.gz', 0444 do |io|
io.write metadata_gz io.write metadata_gz
@ -721,7 +736,7 @@ class TestGemPackage < Gem::Package::TarTestCase
def test_verify_corrupt def test_verify_corrupt
tf = Tempfile.open 'corrupt' do |io| tf = Tempfile.open 'corrupt' do |io|
data = Gem.gzip 'a' * 10 data = Gem::Util.gzip 'a' * 10
io.write \ io.write \
tar_file_header('metadata.gz', "\000x", 0644, data.length, Time.now) tar_file_header('metadata.gz', "\000x", 0644, data.length, Time.now)
io.write data io.write data
@ -845,7 +860,7 @@ class TestGemPackage < Gem::Package::TarTestCase
build.add_contents gem build.add_contents gem
# write bogus data.tar.gz to foil signature # write bogus data.tar.gz to foil signature
bogus_data = Gem.gzip 'hello' bogus_data = Gem::Util.gzip 'hello'
fake_signer = Class.new do fake_signer = Class.new do
def digest_name; 'SHA512'; end def digest_name; 'SHA512'; end
def digest_algorithm; Digest(:SHA512); end def digest_algorithm; Digest(:SHA512); end
@ -903,6 +918,40 @@ class TestGemPackage < Gem::Package::TarTestCase
end end
assert_equal "package is corrupt, exception while verifying: whatever (ArgumentError) in #{@gem}", e.message assert_equal "package is corrupt, exception while verifying: whatever (ArgumentError) in #{@gem}", e.message
valid_metadata = ["metadata", "metadata.gz"]
valid_metadata.each do |vm|
$spec_loaded = false
$good_name = vm
entry = Object.new
def entry.full_name() $good_name end
package = Gem::Package.new(@gem)
package.instance_variable_set(:@files, [])
def package.load_spec(entry) $spec_loaded = true end
package.verify_entry(entry)
assert $spec_loaded
end
invalid_metadata = ["metadataxgz", "foobar\nmetadata", "metadata\nfoobar"]
invalid_metadata.each do |vm|
$spec_loaded = false
$bad_name = vm
entry = Object.new
def entry.full_name() $bad_name end
package = Gem::Package.new(@gem)
package.instance_variable_set(:@files, [])
def package.load_spec(entry) $spec_loaded = true end
package.verify_entry(entry)
refute $spec_loaded
end
end end
def test_spec def test_spec

View file

@ -158,7 +158,7 @@ group\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
header_s[124, 12] = val header_s[124, 12] = val
io = TempIO.new header_s io = TempIO.new header_s
assert_raises ArgumentError do assert_raises ArgumentError do
new_header = Gem::Package::TarHeader.from io Gem::Package::TarHeader.from io
end end
io.close! if io.respond_to? :close! io.close! if io.respond_to? :close!
end end

View file

@ -541,7 +541,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
@fetcher = fetcher @fetcher = fetcher
def fetcher.fetch_http(uri, mtime, head = nil) def fetcher.fetch_http(uri, mtime, head = nil)
Gem.gzip 'foo' Gem::Util.gzip 'foo'
end end
assert_equal 'foo', fetcher.fetch_path(@uri + 'foo.gz') assert_equal 'foo', fetcher.fetch_path(@uri + 'foo.gz')

View file

@ -450,7 +450,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@spec.cert_chain = [PUBLIC_CERT.to_s] @spec.cert_chain = [PUBLIC_CERT.to_s]
metadata_gz = Gem.gzip @spec.to_yaml metadata_gz = Gem::Util.gzip @spec.to_yaml
package = Gem::Package.new 'nonexistent.gem' package = Gem::Package.new 'nonexistent.gem'
package.checksums[Gem::Security::DIGEST_NAME] = {} package.checksums[Gem::Security::DIGEST_NAME] = {}
@ -473,7 +473,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@spec.cert_chain = [PUBLIC_CERT.to_s] @spec.cert_chain = [PUBLIC_CERT.to_s]
metadata_gz = Gem.gzip @spec.to_yaml metadata_gz = Gem::Util.gzip @spec.to_yaml
package = Gem::Package.new 'nonexistent.gem' package = Gem::Package.new 'nonexistent.gem'
package.checksums[Gem::Security::DIGEST_NAME] = {} package.checksums[Gem::Security::DIGEST_NAME] = {}
@ -502,7 +502,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@spec.cert_chain = [PUBLIC_CERT.to_s] @spec.cert_chain = [PUBLIC_CERT.to_s]
metadata_gz = Gem.gzip @spec.to_yaml metadata_gz = Gem::Util.gzip @spec.to_yaml
package = Gem::Package.new 'nonexistent.gem' package = Gem::Package.new 'nonexistent.gem'
package.checksums[Gem::Security::DIGEST_NAME] = {} package.checksums[Gem::Security::DIGEST_NAME] = {}

View file

@ -127,7 +127,7 @@ class TestGemServer < Gem::TestCase
assert_match %r| \d\d:\d\d:\d\d |, @res['date'] assert_match %r| \d\d:\d\d:\d\d |, @res['date']
assert_equal 'application/x-gzip', @res['content-type'] assert_equal 'application/x-gzip', @res['content-type']
assert_equal [['a', Gem::Version.new(2), Gem::Platform::RUBY]], assert_equal [['a', Gem::Version.new(2), Gem::Platform::RUBY]],
Marshal.load(Gem.gunzip(@res.body)) Marshal.load(Gem::Util.gunzip(@res.body))
end end
def test_listen def test_listen
@ -177,7 +177,7 @@ class TestGemServer < Gem::TestCase
assert_match %r| \d\d:\d\d:\d\d |, @res['date'] assert_match %r| \d\d:\d\d:\d\d |, @res['date']
assert_equal 'application/x-gzip', @res['content-type'] assert_equal 'application/x-gzip', @res['content-type']
assert_equal [['a', v('3.a'), Gem::Platform::RUBY]], assert_equal [['a', v('3.a'), Gem::Platform::RUBY]],
Marshal.load(Gem.gunzip(@res.body)) Marshal.load(Gem::Util.gunzip(@res.body))
end end
def test_quick_gemdirs def test_quick_gemdirs
@ -236,7 +236,7 @@ class TestGemServer < Gem::TestCase
assert @res['date'] assert @res['date']
assert_equal 'application/x-deflate', @res['content-type'] assert_equal 'application/x-deflate', @res['content-type']
spec = Marshal.load Gem.inflate(@res.body) spec = Marshal.load Gem::Util.inflate(@res.body)
assert_equal 'a', spec.name assert_equal 'a', spec.name
assert_equal Gem::Version.new(1), spec.version assert_equal Gem::Version.new(1), spec.version
end end
@ -253,7 +253,7 @@ class TestGemServer < Gem::TestCase
assert @res['date'] assert @res['date']
assert_equal 'application/x-deflate', @res['content-type'] assert_equal 'application/x-deflate', @res['content-type']
spec = Marshal.load Gem.inflate(@res.body) spec = Marshal.load Gem::Util.inflate(@res.body)
assert_equal 'a', spec.name assert_equal 'a', spec.name
assert_equal Gem::Version.new(1), spec.version assert_equal Gem::Version.new(1), spec.version
assert_equal Gem::Platform.local, spec.platform assert_equal Gem::Platform.local, spec.platform
@ -269,7 +269,7 @@ class TestGemServer < Gem::TestCase
assert @res['date'] assert @res['date']
assert_equal 'application/x-deflate', @res['content-type'] assert_equal 'application/x-deflate', @res['content-type']
spec = Marshal.load Gem.inflate(@res.body) spec = Marshal.load Gem::Util.inflate(@res.body)
assert_equal 'a', spec.name assert_equal 'a', spec.name
assert_equal v('3.a'), spec.version assert_equal v('3.a'), spec.version
end end
@ -286,7 +286,7 @@ class TestGemServer < Gem::TestCase
assert @res['date'] assert @res['date']
assert_equal 'application/x-deflate', @res['content-type'] assert_equal 'application/x-deflate', @res['content-type']
spec = Marshal.load Gem.inflate(@res.body) spec = Marshal.load Gem::Util.inflate(@res.body)
assert_equal 'a-b', spec.name assert_equal 'a-b', spec.name
assert_equal v('3.a'), spec.version assert_equal v('3.a'), spec.version
end end
@ -303,7 +303,7 @@ class TestGemServer < Gem::TestCase
assert @res['date'] assert @res['date']
assert_equal 'application/x-deflate', @res['content-type'] assert_equal 'application/x-deflate', @res['content-type']
spec = Marshal.load Gem.inflate(@res.body) spec = Marshal.load Gem::Util.inflate(@res.body)
assert_equal 'a-b-1', spec.name assert_equal 'a-b-1', spec.name
assert_equal v('3.a'), spec.version assert_equal v('3.a'), spec.version
end end
@ -571,7 +571,7 @@ class TestGemServer < Gem::TestCase
assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY], assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY],
['a', Gem::Version.new(2), Gem::Platform::RUBY], ['a', Gem::Version.new(2), Gem::Platform::RUBY],
['a', v('3.a'), Gem::Platform::RUBY]], ['a', v('3.a'), Gem::Platform::RUBY]],
Marshal.load(Gem.gunzip(@res.body)) Marshal.load(Gem::Util.gunzip(@res.body))
end end
def test_uri_encode def test_uri_encode

View file

@ -1133,7 +1133,7 @@ dependencies: []
def test_handles_private_null_type def test_handles_private_null_type
path = File.join DATA_PATH, "null-type.gemspec.rz" path = File.join DATA_PATH, "null-type.gemspec.rz"
data = Marshal.load Gem.inflate(Gem.read_binary(path)) data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
assert_equal nil, data.rubyforge_project assert_equal nil, data.rubyforge_project
end end

View file

@ -46,6 +46,7 @@ class TestGemVersion < Gem::TestCase
def test_class_correct def test_class_correct
assert_equal true, Gem::Version.correct?("5.1") assert_equal true, Gem::Version.correct?("5.1")
assert_equal false, Gem::Version.correct?("an incorrect version") assert_equal false, Gem::Version.correct?("an incorrect version")
assert_equal false, Gem::Version.correct?(nil)
end end
def test_class_new_subclass def test_class_new_subclass