rubygems-update 3.2.34 → 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/thor/lib/thor/actions/file_manipulation.rb +6 -6
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +2 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +2 -6
- data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -6
- data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +4 -9
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -19
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +4 -22
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/version.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 +55 -8
- 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/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 +9 -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 +3 -3
- 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 -27
- 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_source_git.rb +0 -5
- 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
- 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
data/lib/rubygems/installer.rb
CHANGED
@@ -768,7 +768,7 @@ str = ARGV.first
|
|
768
768
|
if str
|
769
769
|
str = str.b[/\\A_(.*)_\\z/, 1]
|
770
770
|
if str and Gem::Version.correct?(str)
|
771
|
-
|
771
|
+
#{explicit_version_requirement(spec.name)}
|
772
772
|
ARGV.shift
|
773
773
|
end
|
774
774
|
end
|
@@ -791,6 +791,16 @@ Gem.use_gemdeps
|
|
791
791
|
TEXT
|
792
792
|
end
|
793
793
|
|
794
|
+
def explicit_version_requirement(name)
|
795
|
+
code = "version = str"
|
796
|
+
return code unless name == "bundler"
|
797
|
+
|
798
|
+
code += <<-TEXT
|
799
|
+
|
800
|
+
ENV['BUNDLER_VERSION'] = str
|
801
|
+
TEXT
|
802
|
+
end
|
803
|
+
|
794
804
|
##
|
795
805
|
# return the stub script text used to launch the true Ruby script
|
796
806
|
|
data/lib/rubygems/name_tuple.rb
CHANGED
@@ -89,9 +89,8 @@ class Gem::NameTuple
|
|
89
89
|
alias to_s inspect # :nodoc:
|
90
90
|
|
91
91
|
def <=>(other)
|
92
|
-
[@name, @version,
|
93
|
-
[other.name, other.version,
|
94
|
-
other.platform == Gem::Platform::RUBY ? -1 : 1]
|
92
|
+
[@name, @version, Gem::Platform.sort_priority(@platform)] <=>
|
93
|
+
[other.name, other.version, Gem::Platform.sort_priority(other.platform)]
|
95
94
|
end
|
96
95
|
|
97
96
|
include Comparable
|
@@ -72,12 +72,7 @@ class Gem::PathSupport
|
|
72
72
|
|
73
73
|
# Return the default Gem path
|
74
74
|
def default_path
|
75
|
-
|
76
|
-
|
77
|
-
if defined?(APPLE_GEM_HOME)
|
78
|
-
gem_path << APPLE_GEM_HOME
|
79
|
-
end
|
80
|
-
gem_path
|
75
|
+
Gem.default_path + [@home]
|
81
76
|
end
|
82
77
|
|
83
78
|
def expand(path)
|
data/lib/rubygems/platform.rb
CHANGED
@@ -40,6 +40,10 @@ class Gem::Platform
|
|
40
40
|
match_platforms?(platform, Gem.platforms)
|
41
41
|
end
|
42
42
|
|
43
|
+
def self.sort_priority(platform)
|
44
|
+
platform == Gem::Platform::RUBY ? -1 : 1
|
45
|
+
end
|
46
|
+
|
43
47
|
def self.installable?(spec)
|
44
48
|
if spec.respond_to? :installable_platform?
|
45
49
|
spec.installable_platform?
|
data/lib/rubygems/security.rb
CHANGED
@@ -510,9 +510,10 @@ module Gem::Security
|
|
510
510
|
|
511
511
|
dcs = dcs.split '.'
|
512
512
|
|
513
|
-
|
514
|
-
|
515
|
-
|
513
|
+
OpenSSL::X509::Name.new([
|
514
|
+
["CN", cn],
|
515
|
+
*dcs.map {|dc| ["DC", dc] },
|
516
|
+
])
|
516
517
|
end
|
517
518
|
|
518
519
|
##
|
data/lib/rubygems/source.rb
CHANGED
@@ -35,6 +35,7 @@ class Gem::Source
|
|
35
35
|
end
|
36
36
|
|
37
37
|
@uri = uri
|
38
|
+
@update_cache = nil
|
38
39
|
end
|
39
40
|
|
40
41
|
##
|
@@ -118,7 +119,8 @@ class Gem::Source
|
|
118
119
|
# Returns true when it is possible and safe to update the cache directory.
|
119
120
|
|
120
121
|
def update_cache?
|
121
|
-
@update_cache
|
122
|
+
return @update_cache unless @update_cache.nil?
|
123
|
+
@update_cache =
|
122
124
|
begin
|
123
125
|
File.stat(Gem.user_home).uid == Process.uid
|
124
126
|
rescue Errno::ENOENT
|
@@ -181,18 +181,14 @@ class Gem::Specification < Gem::BasicSpecification
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def self.clear_specs # :nodoc:
|
184
|
-
@@
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
@@active_stub_with_requirable_file = {}
|
190
|
-
end
|
184
|
+
@@all = nil
|
185
|
+
@@stubs = nil
|
186
|
+
@@stubs_by_name = {}
|
187
|
+
@@spec_with_requirable_file = {}
|
188
|
+
@@active_stub_with_requirable_file = {}
|
191
189
|
end
|
192
190
|
private_class_method :clear_specs
|
193
191
|
|
194
|
-
@@all_specs_mutex = Thread::Mutex.new
|
195
|
-
|
196
192
|
clear_specs
|
197
193
|
|
198
194
|
# Sentinel object to represent "not found" stubs
|
@@ -760,7 +756,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
760
756
|
attr_accessor :specification_version
|
761
757
|
|
762
758
|
def self._all # :nodoc:
|
763
|
-
@@
|
759
|
+
@@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec)
|
764
760
|
end
|
765
761
|
|
766
762
|
def self.clear_load_cache # :nodoc:
|
@@ -863,7 +859,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
863
859
|
next names if names.nonzero?
|
864
860
|
versions = b.version <=> a.version
|
865
861
|
next versions if versions.nonzero?
|
866
|
-
b.platform
|
862
|
+
Gem::Platform.sort_priority(b.platform)
|
867
863
|
end
|
868
864
|
end
|
869
865
|
|
@@ -1088,7 +1084,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1088
1084
|
# +prerelease+ is true.
|
1089
1085
|
|
1090
1086
|
def self.latest_specs(prerelease = false)
|
1091
|
-
_latest_specs Gem::Specification.
|
1087
|
+
_latest_specs Gem::Specification.stubs, prerelease
|
1092
1088
|
end
|
1093
1089
|
|
1094
1090
|
##
|
@@ -2337,7 +2333,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2337
2333
|
# Returns an object you can use to sort specifications in #sort_by.
|
2338
2334
|
|
2339
2335
|
def sort_obj
|
2340
|
-
[@name, @version,
|
2336
|
+
[@name, @version, Gem::Platform.sort_priority(@new_platform)]
|
2341
2337
|
end
|
2342
2338
|
|
2343
2339
|
##
|
data/lib/rubygems/text.rb
CHANGED
@@ -49,37 +49,38 @@ module Gem::Text
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# This code is based directly on the Text gem implementation
|
53
52
|
# Returns a value representing the "cost" of transforming str1 into str2
|
53
|
+
# Vendored version of DidYouMean::Levenshtein.distance from the ruby/did_you_mean gem @ 1.4.0
|
54
|
+
# https://git.io/JJgZI
|
54
55
|
def levenshtein_distance(str1, str2)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
return m if (0 == n)
|
61
|
-
return n if (0 == m)
|
56
|
+
n = str1.length
|
57
|
+
m = str2.length
|
58
|
+
return m if n.zero?
|
59
|
+
return n if m.zero?
|
62
60
|
|
63
61
|
d = (0..m).to_a
|
64
62
|
x = nil
|
65
63
|
|
66
|
-
|
67
|
-
|
64
|
+
# to avoid duplicating an enumerable object, create it outside of the loop
|
65
|
+
str2_codepoints = str2.codepoints
|
68
66
|
|
69
|
-
|
70
|
-
|
67
|
+
str1.each_codepoint.with_index(1) do |char1, i|
|
68
|
+
j = 0
|
69
|
+
while j < m
|
70
|
+
cost = (char1 == str2_codepoints[j]) ? 0 : 1
|
71
71
|
x = min3(
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
d[j] =
|
77
|
-
|
72
|
+
d[j + 1] + 1, # insertion
|
73
|
+
i + 1, # deletion
|
74
|
+
d[j] + cost # substitution
|
75
|
+
)
|
76
|
+
d[j] = i
|
77
|
+
i = x
|
78
|
+
|
79
|
+
j += 1
|
78
80
|
end
|
79
|
-
|
80
81
|
d[m] = x
|
81
82
|
end
|
82
83
|
|
83
|
-
|
84
|
+
x
|
84
85
|
end
|
85
86
|
end
|
data/lib/rubygems/uninstaller.rb
CHANGED
@@ -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
|
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
|
@@ -311,29 +325,4 @@ class TestGemCommandManager < Gem::TestCase
|
|
311
325
|
ensure
|
312
326
|
Gem::Commands.send(:remove_const, :FooCommand)
|
313
327
|
end
|
314
|
-
|
315
|
-
def test_deprecated_command_with_version
|
316
|
-
require "rubygems/command"
|
317
|
-
foo_command = Class.new(Gem::Command) do
|
318
|
-
extend Gem::Deprecate
|
319
|
-
|
320
|
-
rubygems_deprecate_command("9.9.9")
|
321
|
-
|
322
|
-
def execute
|
323
|
-
say "pew pew!"
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
Gem::Commands.send(:const_set, :FooCommand, foo_command)
|
328
|
-
@command_manager.register_command(:foo, foo_command.new("foo"))
|
329
|
-
|
330
|
-
use_ui @ui do
|
331
|
-
@command_manager.process_args(%w[foo])
|
332
|
-
end
|
333
|
-
|
334
|
-
assert_equal "pew pew!\n", @ui.output
|
335
|
-
assert_match(/WARNING: foo command is deprecated. It will be removed in Rubygems 9.9.9/, @ui.error)
|
336
|
-
ensure
|
337
|
-
Gem::Commands.send(:remove_const, :FooCommand)
|
338
|
-
end
|
339
328
|
end
|
@@ -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'
|