rubygems-update 3.2.33 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -4
- data/CONTRIBUTING.md +40 -10
- data/Manifest.txt +6 -5
- data/POLICIES.md +22 -8
- data/README.md +9 -7
- data/UPGRADING.md +5 -81
- data/bin/gem +1 -6
- data/bundler/CHANGELOG.md +27 -0
- data/bundler/exe/bundle +7 -8
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/gem.rb +1 -1
- data/bundler/lib/bundler/cli/install.rb +2 -0
- data/bundler/lib/bundler/cli.rb +5 -0
- data/bundler/lib/bundler/definition.rb +14 -2
- data/bundler/lib/bundler/dependency.rb +5 -7
- data/bundler/lib/bundler/dsl.rb +0 -27
- data/bundler/lib/bundler/endpoint_specification.rb +0 -8
- data/bundler/lib/bundler/fetcher/compact_index.rb +9 -4
- data/bundler/lib/bundler/fetcher.rb +2 -5
- data/bundler/lib/bundler/injector.rb +10 -1
- data/bundler/lib/bundler/installer/gem_installer.rb +1 -6
- data/bundler/lib/bundler/installer.rb +1 -4
- data/bundler/lib/bundler/lockfile_parser.rb +10 -13
- data/bundler/lib/bundler/man/bundle-add.1 +9 -1
- data/bundler/lib/bundler/man/bundle-add.1.ronn +7 -1
- data/bundler/lib/bundler/man/bundle-config.1 +2 -2
- data/bundler/lib/bundler/man/bundle-config.1.ronn +3 -3
- data/bundler/lib/bundler/man/bundle-install.1 +1 -1
- data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
- data/bundler/lib/bundler/man/bundle-update.1 +1 -1
- data/bundler/lib/bundler/man/bundle-update.1.ronn +2 -1
- data/bundler/lib/bundler/man/gemfile.5 +1 -1
- data/bundler/lib/bundler/man/gemfile.5.ronn +1 -1
- data/bundler/lib/bundler/plugin/installer.rb +1 -1
- data/bundler/lib/bundler/process_lock.rb +1 -1
- data/bundler/lib/bundler/psyched_yaml.rb +1 -13
- data/bundler/lib/bundler/resolver.rb +34 -29
- data/bundler/lib/bundler/rubygems_ext.rb +2 -0
- data/bundler/lib/bundler/rubygems_integration.rb +11 -48
- data/bundler/lib/bundler/self_manager.rb +73 -0
- data/bundler/lib/bundler/shared_helpers.rb +2 -9
- data/bundler/lib/bundler/source/metadata.rb +1 -1
- data/bundler/lib/bundler/templates/Executable.bundler +1 -1
- data/bundler/lib/bundler/templates/Gemfile +0 -2
- data/bundler/lib/bundler/templates/gems.rb +0 -3
- data/bundler/lib/bundler/templates/newgem/Rakefile.tt +10 -1
- data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
- data/bundler/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
- data/bundler/lib/bundler/ui/shell.rb +1 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
- data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
- data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
- data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
- data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/lib/bundler.rb +9 -3
- data/hide_lib_for_update/note.txt +0 -4
- data/lib/rubygems/command_manager.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +5 -2
- data/lib/rubygems/commands/server_command.rb +14 -77
- data/lib/rubygems/commands/setup_command.rb +4 -16
- data/lib/rubygems/commands/update_command.rb +9 -4
- data/lib/rubygems/defaults.rb +2 -20
- data/lib/rubygems/deprecate.rb +53 -6
- data/lib/rubygems/exceptions.rb +26 -1
- data/lib/rubygems/ext/builder.rb +5 -3
- data/lib/rubygems/install_update_options.rb +11 -2
- data/lib/rubygems/installer.rb +11 -1
- data/lib/rubygems/name_tuple.rb +2 -3
- data/lib/rubygems/path_support.rb +1 -6
- data/lib/rubygems/platform.rb +4 -0
- data/lib/rubygems/remote_fetcher.rb +1 -1
- data/lib/rubygems/requirement.rb +1 -1
- data/lib/rubygems/resolver/installer_set.rb +1 -1
- data/lib/rubygems/security.rb +4 -3
- data/lib/rubygems/source.rb +3 -1
- data/lib/rubygems/spec_fetcher.rb +1 -1
- data/lib/rubygems/specification.rb +11 -13
- data/lib/rubygems/text.rb +21 -20
- data/lib/rubygems/uninstaller.rb +4 -1
- data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
- data/lib/rubygems/version.rb +2 -0
- data/lib/rubygems.rb +26 -23
- data/rubygems-update.gemspec +1 -1
- data/setup.rb +1 -6
- data/test/rubygems/helper.rb +20 -6
- data/test/rubygems/test_config.rb +2 -2
- data/test/rubygems/test_exit.rb +11 -0
- data/test/rubygems/test_gem.rb +46 -41
- data/test/rubygems/test_gem_command_manager.rb +16 -2
- data/test/rubygems/test_gem_commands_open_command.rb +1 -1
- data/test/rubygems/test_gem_commands_server_command.rb +4 -46
- data/test/rubygems/test_gem_commands_update_command.rb +2 -2
- data/test/rubygems/test_gem_path_support.rb +2 -6
- data/test/rubygems/test_gem_remote_fetcher.rb +15 -0
- data/test/rubygems/test_gem_requirement.rb +0 -1
- data/test/rubygems/test_gem_security.rb +1 -1
- data/test/rubygems/test_gem_specification.rb +16 -25
- data/test/rubygems/test_gem_text.rb +6 -0
- data/test/rubygems/test_project_sanity.rb +1 -1
- data/test/rubygems/test_require.rb +0 -7
- data/test/rubygems/test_rubygems.rb +23 -0
- metadata +9 -8
- data/bundler/lib/bundler/gemdeps.rb +0 -29
- data/lib/rubygems/server.rb +0 -882
- data/test/rubygems/bogussources.rb +0 -9
- data/test/rubygems/test_gem_server.rb +0 -608
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gem::UnknownCommandSpellChecker
|
4
|
+
attr_reader :error
|
5
|
+
|
6
|
+
def initialize(error)
|
7
|
+
@error = error
|
8
|
+
end
|
9
|
+
|
10
|
+
def corrections
|
11
|
+
@corrections ||=
|
12
|
+
spell_checker.correct(error.unknown_command).map(&:inspect)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def spell_checker
|
18
|
+
dictionary = Gem::CommandManager.instance.command_names
|
19
|
+
DidYouMean::SpellChecker.new(dictionary: dictionary)
|
20
|
+
end
|
21
|
+
end
|
data/lib/rubygems/version.rb
CHANGED
@@ -149,6 +149,8 @@
|
|
149
149
|
# For the last example, single-digit versions are automatically extended with
|
150
150
|
# a zero to give a sensible result.
|
151
151
|
|
152
|
+
require_relative "deprecate"
|
153
|
+
|
152
154
|
class Gem::Version
|
153
155
|
autoload :Requirement, File.expand_path('requirement', __dir__)
|
154
156
|
|
data/lib/rubygems.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
require 'rbconfig'
|
9
9
|
|
10
10
|
module Gem
|
11
|
-
VERSION = "3.
|
11
|
+
VERSION = "3.3.0".freeze
|
12
12
|
end
|
13
13
|
|
14
14
|
# Must be first since it unloads the prelude from 1.9.2
|
@@ -800,7 +800,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|
800
800
|
##
|
801
801
|
# Safely write a file in binary mode on all platforms.
|
802
802
|
def self.write_binary(path, data)
|
803
|
-
File.open(path, File::RDWR | File::CREAT | File::
|
803
|
+
File.open(path, File::RDWR | File::CREAT | File::LOCK_EX, binmode: true) do |io|
|
804
804
|
io.write data
|
805
805
|
end
|
806
806
|
rescue *WRITE_BINARY_ERRORS
|
@@ -854,7 +854,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|
854
854
|
fetcher = Gem::SpecFetcher.fetcher
|
855
855
|
spec_tuples, = fetcher.spec_for_dependency dependency
|
856
856
|
|
857
|
-
spec, = spec_tuples.
|
857
|
+
spec, = spec_tuples.last
|
858
858
|
|
859
859
|
spec
|
860
860
|
end
|
@@ -1293,7 +1293,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|
1293
1293
|
end
|
1294
1294
|
|
1295
1295
|
def default_gem_load_paths
|
1296
|
-
@default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1]
|
1296
|
+
@default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1].map do |lp|
|
1297
|
+
expanded = File.expand_path(lp)
|
1298
|
+
next expanded unless File.exist?(expanded)
|
1299
|
+
|
1300
|
+
File.realpath(expanded)
|
1301
|
+
end
|
1297
1302
|
end
|
1298
1303
|
end
|
1299
1304
|
|
@@ -1310,37 +1315,19 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|
1310
1315
|
autoload :Licenses, File.expand_path('rubygems/util/licenses', __dir__)
|
1311
1316
|
autoload :NameTuple, File.expand_path('rubygems/name_tuple', __dir__)
|
1312
1317
|
autoload :PathSupport, File.expand_path('rubygems/path_support', __dir__)
|
1313
|
-
autoload :Platform, File.expand_path('rubygems/platform', __dir__)
|
1314
1318
|
autoload :RequestSet, File.expand_path('rubygems/request_set', __dir__)
|
1315
|
-
autoload :Requirement, File.expand_path('rubygems/requirement', __dir__)
|
1316
1319
|
autoload :Resolver, File.expand_path('rubygems/resolver', __dir__)
|
1317
1320
|
autoload :Source, File.expand_path('rubygems/source', __dir__)
|
1318
1321
|
autoload :SourceList, File.expand_path('rubygems/source_list', __dir__)
|
1319
1322
|
autoload :SpecFetcher, File.expand_path('rubygems/spec_fetcher', __dir__)
|
1320
|
-
autoload :Specification, File.expand_path('rubygems/specification', __dir__)
|
1321
1323
|
autoload :Util, File.expand_path('rubygems/util', __dir__)
|
1322
1324
|
autoload :Version, File.expand_path('rubygems/version', __dir__)
|
1323
1325
|
end
|
1324
1326
|
|
1325
1327
|
require_relative 'rubygems/exceptions'
|
1328
|
+
require_relative 'rubygems/specification'
|
1326
1329
|
|
1327
1330
|
# REFACTOR: This should be pulled out into some kind of hacks file.
|
1328
|
-
begin
|
1329
|
-
##
|
1330
|
-
# Defaults the Ruby implementation wants to provide for RubyGems
|
1331
|
-
|
1332
|
-
require "rubygems/defaults/#{RUBY_ENGINE}"
|
1333
|
-
rescue LoadError
|
1334
|
-
end
|
1335
|
-
|
1336
|
-
##
|
1337
|
-
# Loads the default specs.
|
1338
|
-
Gem::Specification.load_defaults
|
1339
|
-
|
1340
|
-
require_relative 'rubygems/core_ext/kernel_gem'
|
1341
|
-
require_relative 'rubygems/core_ext/kernel_require'
|
1342
|
-
require_relative 'rubygems/core_ext/kernel_warn'
|
1343
|
-
|
1344
1331
|
begin
|
1345
1332
|
##
|
1346
1333
|
# Defaults the operating system (or packager) wants to provide for RubyGems.
|
@@ -1356,3 +1343,19 @@ rescue StandardError => e
|
|
1356
1343
|
"the problem and ask for help."
|
1357
1344
|
raise e.class, msg
|
1358
1345
|
end
|
1346
|
+
|
1347
|
+
begin
|
1348
|
+
##
|
1349
|
+
# Defaults the Ruby implementation wants to provide for RubyGems
|
1350
|
+
|
1351
|
+
require "rubygems/defaults/#{RUBY_ENGINE}"
|
1352
|
+
rescue LoadError
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
##
|
1356
|
+
# Loads the default specs.
|
1357
|
+
Gem::Specification.load_defaults
|
1358
|
+
|
1359
|
+
require_relative 'rubygems/core_ext/kernel_gem'
|
1360
|
+
require_relative 'rubygems/core_ext/kernel_require'
|
1361
|
+
require_relative 'rubygems/core_ext/kernel_warn'
|
data/rubygems-update.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rubygems-update"
|
5
|
-
s.version = "3.
|
5
|
+
s.version = "3.3.0"
|
6
6
|
s.authors = ["Jim Weirich", "Chad Fowler", "Eric Hodel", "Luis Lavena", "Aaron Patterson", "Samuel Giddins", "André Arko", "Evan Phoenix", "Hiroshi SHIBATA"]
|
7
7
|
s.email = ["", "", "drbrain@segment7.net", "luislavena@gmail.com", "aaron@tenderlovemaking.com", "segiddins@segiddins.me", "andre@arko.net", "evan@phx.io", "hsbt@ruby-lang.org"]
|
8
8
|
|
data/setup.rb
CHANGED
@@ -21,7 +21,6 @@ Dir.chdir File.dirname(__FILE__)
|
|
21
21
|
$:.unshift File.expand_path('lib')
|
22
22
|
require 'rubygems'
|
23
23
|
require 'rubygems/gem_runner'
|
24
|
-
require 'rubygems/exceptions'
|
25
24
|
|
26
25
|
Gem::CommandManager.instance.register_command :setup
|
27
26
|
|
@@ -31,8 +30,4 @@ if ENV["GEM_PREV_VER"]
|
|
31
30
|
end
|
32
31
|
args.unshift 'setup'
|
33
32
|
|
34
|
-
|
35
|
-
Gem::GemRunner.new.run args
|
36
|
-
rescue Gem::SystemExitException => e
|
37
|
-
exit e.exit_code
|
38
|
-
end
|
33
|
+
Gem::GemRunner.new.run args
|
data/test/rubygems/helper.rb
CHANGED
@@ -143,15 +143,13 @@ class Gem::TestCase < Test::Unit::TestCase
|
|
143
143
|
|
144
144
|
return captured_stdout.read, captured_stderr.read
|
145
145
|
ensure
|
146
|
-
captured_stdout.unlink
|
147
|
-
captured_stderr.unlink
|
148
146
|
$stdout.reopen orig_stdout
|
149
147
|
$stderr.reopen orig_stderr
|
150
148
|
|
151
149
|
orig_stdout.close
|
152
150
|
orig_stderr.close
|
153
|
-
captured_stdout.close
|
154
|
-
captured_stderr.close
|
151
|
+
captured_stdout.close!
|
152
|
+
captured_stderr.close!
|
155
153
|
end
|
156
154
|
end
|
157
155
|
end
|
@@ -591,7 +589,7 @@ class Gem::TestCase < Test::Unit::TestCase
|
|
591
589
|
def have_git?
|
592
590
|
return if in_path? @git
|
593
591
|
|
594
|
-
|
592
|
+
pend 'cannot find git executable, use GIT environment variable to set'
|
595
593
|
end
|
596
594
|
|
597
595
|
def in_path?(executable) # :nodoc:
|
@@ -1302,6 +1300,22 @@ Also, a list:
|
|
1302
1300
|
Gem.instance_variable_set :@ruby, orig_ruby
|
1303
1301
|
end
|
1304
1302
|
|
1303
|
+
def with_internal_encoding(encoding)
|
1304
|
+
int_enc = Encoding.default_internal
|
1305
|
+
silence_warnings { Encoding.default_internal = encoding }
|
1306
|
+
|
1307
|
+
yield
|
1308
|
+
ensure
|
1309
|
+
silence_warnings { Encoding.default_internal = int_enc }
|
1310
|
+
end
|
1311
|
+
|
1312
|
+
def silence_warnings
|
1313
|
+
old_verbose, $VERBOSE = $VERBOSE, false
|
1314
|
+
yield
|
1315
|
+
ensure
|
1316
|
+
$VERBOSE = old_verbose
|
1317
|
+
end
|
1318
|
+
|
1305
1319
|
class << self
|
1306
1320
|
# :nodoc:
|
1307
1321
|
##
|
@@ -1589,7 +1603,7 @@ class Object
|
|
1589
1603
|
metaclass.send :undef_method, name
|
1590
1604
|
metaclass.send :alias_method, name, new_name
|
1591
1605
|
metaclass.send :undef_method, new_name
|
1592
|
-
end
|
1606
|
+
end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition
|
1593
1607
|
end
|
1594
1608
|
|
1595
1609
|
require_relative 'utilities'
|
@@ -12,14 +12,14 @@ class TestConfig < Gem::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_good_rake_path_is_escaped
|
15
|
-
path = Gem::TestCase.
|
15
|
+
path = Gem::TestCase.class_variable_get(:@@good_rake)
|
16
16
|
ruby, rake = path.shellsplit
|
17
17
|
assert_equal(Gem.ruby, ruby)
|
18
18
|
assert_match(/\/good_rake.rb\z/, rake)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_bad_rake_path_is_escaped
|
22
|
-
path = Gem::TestCase.
|
22
|
+
path = Gem::TestCase.class_variable_get(:@@bad_rake)
|
23
23
|
ruby, rake = path.shellsplit
|
24
24
|
assert_equal(Gem.ruby, ruby)
|
25
25
|
assert_match(/\/bad_rake.rb\z/, rake)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
class TestExit < Gem::TestCase
|
7
|
+
def test_exit
|
8
|
+
system(*ruby_with_rubygems_in_load_path, "-e", "raise Gem::SystemExitException.new(2)")
|
9
|
+
assert_equal 2, $?.exitstatus
|
10
|
+
end
|
11
|
+
end
|
data/test/rubygems/test_gem.rb
CHANGED
@@ -888,6 +888,27 @@ class TestGem < Gem::TestCase
|
|
888
888
|
assert_equal gems['a-2'], spec
|
889
889
|
end
|
890
890
|
|
891
|
+
def test_self_latest_spec_for_multiple_sources
|
892
|
+
uri = 'https://example.sample.com/'
|
893
|
+
source = Gem::Source.new(uri)
|
894
|
+
source_list = Gem::SourceList.new
|
895
|
+
source_list << Gem::Source.new(@uri)
|
896
|
+
source_list << source
|
897
|
+
Gem.sources.replace source_list
|
898
|
+
|
899
|
+
spec_fetcher(uri) do |fetcher|
|
900
|
+
fetcher.spec 'a', 1.1
|
901
|
+
end
|
902
|
+
|
903
|
+
gems = spec_fetcher do |fetcher|
|
904
|
+
fetcher.spec 'a', 1
|
905
|
+
fetcher.spec 'a', '3.a'
|
906
|
+
fetcher.spec 'a', 2
|
907
|
+
end
|
908
|
+
spec = Gem.latest_spec_for 'a'
|
909
|
+
assert_equal gems['a-2'], spec
|
910
|
+
end
|
911
|
+
|
891
912
|
def test_self_latest_rubygems_version
|
892
913
|
spec_fetcher do |fetcher|
|
893
914
|
fetcher.spec 'rubygems-update', '1.8.23'
|
@@ -912,6 +933,29 @@ class TestGem < Gem::TestCase
|
|
912
933
|
assert_equal Gem::Version.new(2), version
|
913
934
|
end
|
914
935
|
|
936
|
+
def test_self_latest_version_for_multiple_sources
|
937
|
+
uri = 'https://example.sample.com/'
|
938
|
+
source = Gem::Source.new(uri)
|
939
|
+
source_list = Gem::SourceList.new
|
940
|
+
source_list << Gem::Source.new(@uri)
|
941
|
+
source_list << source
|
942
|
+
Gem.sources.replace source_list
|
943
|
+
|
944
|
+
spec_fetcher(uri) do |fetcher|
|
945
|
+
fetcher.spec 'a', 1.1
|
946
|
+
end
|
947
|
+
|
948
|
+
spec_fetcher do |fetcher|
|
949
|
+
fetcher.spec 'a', 1
|
950
|
+
fetcher.spec 'a', 2
|
951
|
+
fetcher.spec 'a', '3.a'
|
952
|
+
end
|
953
|
+
|
954
|
+
version = Gem.latest_version_for 'a'
|
955
|
+
|
956
|
+
assert_equal Gem::Version.new(2), version
|
957
|
+
end
|
958
|
+
|
915
959
|
def test_self_loaded_specs
|
916
960
|
foo = util_spec 'foo'
|
917
961
|
install_gem foo
|
@@ -921,56 +965,17 @@ class TestGem < Gem::TestCase
|
|
921
965
|
assert_equal true, Gem.loaded_specs.keys.include?('foo')
|
922
966
|
end
|
923
967
|
|
924
|
-
def util_path
|
925
|
-
ENV.delete "GEM_HOME"
|
926
|
-
ENV.delete "GEM_PATH"
|
927
|
-
end
|
928
|
-
|
929
968
|
def test_self_path
|
930
969
|
assert_equal [Gem.dir], Gem.path
|
931
970
|
end
|
932
971
|
|
933
972
|
def test_self_path_default
|
934
|
-
|
935
|
-
|
936
|
-
if defined?(APPLE_GEM_HOME)
|
937
|
-
orig_APPLE_GEM_HOME = APPLE_GEM_HOME
|
938
|
-
Object.send :remove_const, :APPLE_GEM_HOME
|
939
|
-
end
|
973
|
+
ENV.delete "GEM_HOME"
|
974
|
+
ENV.delete "GEM_PATH"
|
940
975
|
|
941
976
|
Gem.instance_variable_set :@paths, nil
|
942
977
|
|
943
978
|
assert_equal [Gem.default_path, Gem.dir].flatten.uniq, Gem.path
|
944
|
-
ensure
|
945
|
-
Object.const_set :APPLE_GEM_HOME, orig_APPLE_GEM_HOME if orig_APPLE_GEM_HOME
|
946
|
-
end
|
947
|
-
|
948
|
-
unless win_platform?
|
949
|
-
def test_self_path_APPLE_GEM_HOME
|
950
|
-
util_path
|
951
|
-
|
952
|
-
Gem.clear_paths
|
953
|
-
apple_gem_home = File.join @tempdir, 'apple_gem_home'
|
954
|
-
|
955
|
-
old, $-w = $-w, nil
|
956
|
-
Object.const_set :APPLE_GEM_HOME, apple_gem_home
|
957
|
-
$-w = old
|
958
|
-
|
959
|
-
assert_includes Gem.path, apple_gem_home
|
960
|
-
ensure
|
961
|
-
Object.send :remove_const, :APPLE_GEM_HOME
|
962
|
-
end
|
963
|
-
|
964
|
-
def test_self_path_APPLE_GEM_HOME_GEM_PATH
|
965
|
-
Gem.clear_paths
|
966
|
-
ENV['GEM_PATH'] = @gemhome
|
967
|
-
apple_gem_home = File.join @tempdir, 'apple_gem_home'
|
968
|
-
Gem.const_set :APPLE_GEM_HOME, apple_gem_home
|
969
|
-
|
970
|
-
refute Gem.path.include?(apple_gem_home)
|
971
|
-
ensure
|
972
|
-
Gem.send :remove_const, :APPLE_GEM_HOME
|
973
|
-
end
|
974
979
|
end
|
975
980
|
|
976
981
|
def test_self_path_ENV_PATH
|
@@ -62,13 +62,27 @@ class TestGemCommandManager < Gem::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_find_command_unknown
|
65
|
-
e = assert_raise Gem::
|
65
|
+
e = assert_raise Gem::UnknownCommandError do
|
66
66
|
@command_manager.find_command 'xyz'
|
67
67
|
end
|
68
68
|
|
69
69
|
assert_equal 'Unknown command xyz', e.message
|
70
70
|
end
|
71
71
|
|
72
|
+
def test_find_command_unknown_suggestions
|
73
|
+
e = assert_raise Gem::UnknownCommandError do
|
74
|
+
@command_manager.find_command 'pish'
|
75
|
+
end
|
76
|
+
|
77
|
+
message = 'Unknown command pish'.dup
|
78
|
+
|
79
|
+
if RUBY_VERSION >= "2.4" && defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
|
80
|
+
message << "\nDid you mean? \"push\""
|
81
|
+
end
|
82
|
+
|
83
|
+
assert_equal message, e.message
|
84
|
+
end
|
85
|
+
|
72
86
|
def test_run_interrupt
|
73
87
|
old_load_path = $:.dup
|
74
88
|
$: << File.expand_path("test/rubygems", PROJECT_DIR)
|
@@ -277,7 +291,7 @@ class TestGemCommandManager < Gem::TestCase
|
|
277
291
|
|
278
292
|
#check defaults
|
279
293
|
@command_manager.process_args %w[update]
|
280
|
-
assert_includes check_options[:document], '
|
294
|
+
assert_includes check_options[:document], 'ri'
|
281
295
|
|
282
296
|
#check settings
|
283
297
|
check_options = nil
|
@@ -21,7 +21,7 @@ class TestGemCommandsOpenCommand < Gem::TestCase
|
|
21
21
|
|
22
22
|
def test_execute
|
23
23
|
@cmd.options[:args] = %w[foo]
|
24
|
-
@cmd.options[:editor] = "#{
|
24
|
+
@cmd.options[:editor] = "#{ruby_with_rubygems_in_load_path} -eexit --"
|
25
25
|
|
26
26
|
gem 'foo', '1.0.0'
|
27
27
|
spec = gem 'foo', '1.0.1'
|
@@ -9,53 +9,11 @@ class TestGemCommandsServerCommand < Gem::TestCase
|
|
9
9
|
@cmd = Gem::Commands::ServerCommand.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
@
|
14
|
-
|
15
|
-
assert_equal false, @cmd.options[:daemon]
|
16
|
-
assert_equal [], @cmd.options[:gemdir]
|
17
|
-
assert_equal 8808, @cmd.options[:port]
|
18
|
-
|
19
|
-
@cmd.send :handle_options, %w[-p 9999 -d /nonexistent --daemon]
|
20
|
-
|
21
|
-
assert_equal true, @cmd.options[:daemon]
|
22
|
-
assert_equal [File.expand_path('/nonexistent')], @cmd.options[:gemdir]
|
23
|
-
assert_equal 9999, @cmd.options[:port]
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_handle_options_gemdir
|
27
|
-
@cmd.send :handle_options, %w[--dir a --dir b]
|
28
|
-
|
29
|
-
assert_equal [File.expand_path('a'), File.expand_path('b')],
|
30
|
-
@cmd.options[:gemdir]
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_handle_options_port
|
34
|
-
@cmd.send :handle_options, %w[-p 0]
|
35
|
-
assert_equal 0, @cmd.options[:port]
|
36
|
-
|
37
|
-
@cmd.send :handle_options, %w[-p 65535]
|
38
|
-
assert_equal 65535, @cmd.options[:port]
|
39
|
-
|
40
|
-
begin
|
41
|
-
@cmd.send :handle_options, %w[-p discard]
|
42
|
-
assert_equal 9, @cmd.options[:port]
|
43
|
-
rescue Gem::OptionParser::InvalidArgument
|
44
|
-
# for container environment on GitHub Actions
|
45
|
-
end
|
46
|
-
|
47
|
-
e = assert_raise Gem::OptionParser::InvalidArgument do
|
48
|
-
@cmd.send :handle_options, %w[-p nonexistent]
|
49
|
-
end
|
50
|
-
|
51
|
-
assert_equal 'invalid argument: -p nonexistent: no such named service',
|
52
|
-
e.message
|
53
|
-
|
54
|
-
e = assert_raise Gem::OptionParser::InvalidArgument do
|
55
|
-
@cmd.send :handle_options, %w[-p 65536]
|
12
|
+
def test_execute
|
13
|
+
use_ui @ui do
|
14
|
+
@cmd.execute
|
56
15
|
end
|
57
16
|
|
58
|
-
|
59
|
-
e.message
|
17
|
+
assert_match %r{Install the rubygems-server}i, @ui.error
|
60
18
|
end
|
61
19
|
end
|
@@ -579,7 +579,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
579
579
|
|
580
580
|
expected = {
|
581
581
|
:args => [],
|
582
|
-
:document => %w[
|
582
|
+
:document => %w[ri],
|
583
583
|
:force => false,
|
584
584
|
:system => true,
|
585
585
|
}
|
@@ -598,7 +598,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|
598
598
|
|
599
599
|
expected = {
|
600
600
|
:args => [],
|
601
|
-
:document => %w[
|
601
|
+
:document => %w[ri],
|
602
602
|
:force => false,
|
603
603
|
:system => "1.3.7",
|
604
604
|
}
|
@@ -16,7 +16,7 @@ class TestGemPathSupport < Gem::TestCase
|
|
16
16
|
|
17
17
|
assert_equal ENV["GEM_HOME"], ps.home
|
18
18
|
|
19
|
-
expected =
|
19
|
+
expected = ENV["GEM_PATH"].split(File::PATH_SEPARATOR)
|
20
20
|
assert_equal expected, ps.path, "defaults to GEM_PATH"
|
21
21
|
end
|
22
22
|
|
@@ -25,7 +25,7 @@ class TestGemPathSupport < Gem::TestCase
|
|
25
25
|
|
26
26
|
assert_equal File.join(@tempdir, "foo"), ps.home
|
27
27
|
|
28
|
-
expected =
|
28
|
+
expected = ENV["GEM_PATH"].split(File::PATH_SEPARATOR) + [File.join(@tempdir, 'foo')]
|
29
29
|
assert_equal expected, ps.path
|
30
30
|
end
|
31
31
|
|
@@ -102,10 +102,6 @@ class TestGemPathSupport < Gem::TestCase
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
def util_path
|
106
|
-
ENV["GEM_PATH"].split(File::PATH_SEPARATOR)
|
107
|
-
end
|
108
|
-
|
109
105
|
def test_initialize_spec
|
110
106
|
ENV["GEM_SPEC_CACHE"] = nil
|
111
107
|
|
@@ -173,6 +173,21 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|
173
173
|
assert_equal 'hello', File.read(path)
|
174
174
|
end
|
175
175
|
|
176
|
+
def test_cache_update_path_with_utf8_internal_encoding
|
177
|
+
with_internal_encoding('UTF-8') do
|
178
|
+
uri = URI 'http://example/file'
|
179
|
+
path = File.join @tempdir, 'file'
|
180
|
+
data = String.new("\xC8").force_encoding(Encoding::BINARY)
|
181
|
+
|
182
|
+
fetcher = util_fuck_with_fetcher data
|
183
|
+
|
184
|
+
written_data = fetcher.cache_update_path uri, path
|
185
|
+
|
186
|
+
assert_equal data, written_data
|
187
|
+
assert_equal data, File.binread(path)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
176
191
|
def test_cache_update_path_no_update
|
177
192
|
uri = URI 'http://example/file'
|
178
193
|
path = File.join @tempdir, 'file'
|
@@ -253,7 +253,6 @@ class TestGemRequirement < Gem::TestCase
|
|
253
253
|
assert_satisfied_by "1.0.0.0", "= 1.0"
|
254
254
|
assert_satisfied_by "10.3.2", "!= 9.3.4"
|
255
255
|
assert_satisfied_by "10.3.2", "> 9.3.2"
|
256
|
-
assert_satisfied_by "10.3.2", "> 9.3.2"
|
257
256
|
assert_satisfied_by " 9.3.2", ">= 9.3.2"
|
258
257
|
assert_satisfied_by "9.3.2 ", ">= 9.3.2"
|
259
258
|
assert_satisfied_by "", "= 0"
|
@@ -196,7 +196,7 @@ class TestGemSecurity < Gem::TestCase
|
|
196
196
|
|
197
197
|
def test_class_sign
|
198
198
|
issuer = PUBLIC_CERT.subject
|
199
|
-
signee = OpenSSL::X509::Name.
|
199
|
+
signee = OpenSSL::X509::Name.new([["CN", "signee"], ["DC", "example"]])
|
200
200
|
|
201
201
|
key = PRIVATE_KEY
|
202
202
|
cert = OpenSSL::X509::Certificate.new
|
@@ -147,6 +147,7 @@ end
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def test_find_in_unresolved_tree_is_not_exponentiental
|
150
|
+
pend "currently slower in CI on TruffleRuby" if RUBY_ENGINE == 'truffleruby'
|
150
151
|
num_of_pkg = 7
|
151
152
|
num_of_version_per_pkg = 3
|
152
153
|
packages = (0..num_of_pkg).map do |pkgi|
|
@@ -873,24 +874,21 @@ dependencies: []
|
|
873
874
|
end
|
874
875
|
|
875
876
|
def test_self_load_utf8_with_ascii_encoding
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
io.write spec2.to_ruby_for_cache.force_encoding('BINARY').sub("\\u{5678}", bin.force_encoding('BINARY'))
|
885
|
-
end
|
877
|
+
with_internal_encoding('US-ASCII') do
|
878
|
+
spec2 = @a2.dup
|
879
|
+
bin = "\u5678".dup
|
880
|
+
spec2.authors = [bin]
|
881
|
+
full_path = spec2.spec_file
|
882
|
+
write_file full_path do |io|
|
883
|
+
io.write spec2.to_ruby_for_cache.force_encoding('BINARY').sub("\\u{5678}", bin.force_encoding('BINARY'))
|
884
|
+
end
|
886
885
|
|
887
|
-
|
886
|
+
spec = Gem::Specification.load full_path
|
888
887
|
|
889
|
-
|
888
|
+
spec2.files.clear
|
890
889
|
|
891
|
-
|
892
|
-
|
893
|
-
silence_warnings { Encoding.default_internal = int_enc }
|
890
|
+
assert_equal spec2, spec
|
891
|
+
end
|
894
892
|
end
|
895
893
|
|
896
894
|
def test_self_load_legacy_ruby
|
@@ -944,7 +942,7 @@ dependencies: []
|
|
944
942
|
end
|
945
943
|
|
946
944
|
def test_self_outdated_and_latest_remotes
|
947
|
-
|
945
|
+
spec_fetcher do |fetcher|
|
948
946
|
fetcher.download 'a', 4
|
949
947
|
fetcher.download 'b', 3
|
950
948
|
|
@@ -953,8 +951,8 @@ dependencies: []
|
|
953
951
|
end
|
954
952
|
|
955
953
|
expected = [
|
956
|
-
[
|
957
|
-
[
|
954
|
+
[Gem::Specification.stubs.find {|s| s.full_name == 'a-3.a' }, v(4)],
|
955
|
+
[Gem::Specification.stubs.find {|s| s.full_name == 'b-2' }, v(3)],
|
958
956
|
]
|
959
957
|
|
960
958
|
assert_equal expected, Gem::Specification.outdated_and_latest_version.to_a
|
@@ -3745,11 +3743,4 @@ end
|
|
3745
3743
|
end
|
3746
3744
|
end
|
3747
3745
|
end
|
3748
|
-
|
3749
|
-
def silence_warnings
|
3750
|
-
old_verbose, $VERBOSE = $VERBOSE, false
|
3751
|
-
yield
|
3752
|
-
ensure
|
3753
|
-
$VERBOSE = old_verbose
|
3754
|
-
end
|
3755
3746
|
end
|
@@ -83,6 +83,12 @@ Without the wrapping, the text might not look good in the RSS feed.
|
|
83
83
|
assert_equal 7, levenshtein_distance("zentest", "xxxxxxx")
|
84
84
|
end
|
85
85
|
|
86
|
+
def test_levenshtein_distance_all
|
87
|
+
assert_equal 6, levenshtein_distance("algorithm", "altruistic")
|
88
|
+
assert_equal 3, levenshtein_distance("saturday", "sunday")
|
89
|
+
assert_equal 3, levenshtein_distance("kitten", "sitting")
|
90
|
+
end
|
91
|
+
|
86
92
|
def test_truncate_text
|
87
93
|
assert_equal "abc", truncate_text("abc", "desc")
|
88
94
|
assert_equal "Truncating desc to 2 characters:\nab", truncate_text("abc", "desc", 2)
|
@@ -13,7 +13,7 @@ class TestProjectSanity < Gem::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_require_rubygems_package
|
16
|
-
err, status = Open3.capture2e(*ruby_with_rubygems_in_load_path, "--disable-gems", "-e", "
|
16
|
+
err, status = Open3.capture2e(*ruby_with_rubygems_in_load_path, "--disable-gems", "-e", "require \"rubygems/package\"")
|
17
17
|
|
18
18
|
assert status.success?, err
|
19
19
|
end
|
@@ -700,13 +700,6 @@ class TestGemRequire < Gem::TestCase
|
|
700
700
|
!ENV["GEM_COMMAND"].nil?
|
701
701
|
end
|
702
702
|
|
703
|
-
def silence_warnings
|
704
|
-
old_verbose, $VERBOSE = $VERBOSE, false
|
705
|
-
yield
|
706
|
-
ensure
|
707
|
-
$VERBOSE = old_verbose
|
708
|
-
end
|
709
|
-
|
710
703
|
def util_install_extension_file(name)
|
711
704
|
spec = quick_gem name
|
712
705
|
util_build_gem spec
|