rubygems-update 3.2.32 → 3.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +154 -4
- data/CONTRIBUTING.md +40 -10
- data/Manifest.txt +11 -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 +70 -0
- data/bundler/exe/bundle +7 -8
- data/bundler/lib/bundler/.document +1 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/doctor.rb +3 -2
- data/bundler/lib/bundler/cli/gem.rb +2 -1
- data/bundler/lib/bundler/cli/info.rb +6 -1
- data/bundler/lib/bundler/cli/install.rb +2 -0
- data/bundler/lib/bundler/cli/update.rb +2 -2
- data/bundler/lib/bundler/cli.rb +6 -0
- data/bundler/lib/bundler/compact_index_client/updater.rb +0 -5
- data/bundler/lib/bundler/definition.rb +29 -53
- data/bundler/lib/bundler/dependency.rb +5 -7
- data/bundler/lib/bundler/dsl.rb +18 -30
- data/bundler/lib/bundler/endpoint_specification.rb +0 -8
- data/bundler/lib/bundler/environment_preserver.rb +4 -1
- 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/lazy_specification.rb +17 -1
- data/bundler/lib/bundler/lockfile_parser.rb +10 -13
- data/bundler/lib/bundler/man/bundle-add.1 +10 -2
- data/bundler/lib/bundler/man/bundle-add.1.ronn +7 -1
- data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
- data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
- data/bundler/lib/bundler/man/bundle-check.1 +1 -1
- data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
- data/bundler/lib/bundler/man/bundle-config.1 +3 -3
- data/bundler/lib/bundler/man/bundle-config.1.ronn +3 -3
- data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
- data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
- data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
- data/bundler/lib/bundler/man/bundle-info.1 +1 -1
- data/bundler/lib/bundler/man/bundle-init.1 +1 -1
- data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
- data/bundler/lib/bundler/man/bundle-install.1 +2 -2
- data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
- data/bundler/lib/bundler/man/bundle-list.1 +1 -1
- data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
- data/bundler/lib/bundler/man/bundle-open.1 +1 -1
- data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
- data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
- data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
- data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
- data/bundler/lib/bundler/man/bundle-show.1 +1 -1
- data/bundler/lib/bundler/man/bundle-update.1 +2 -2
- data/bundler/lib/bundler/man/bundle-update.1.ronn +2 -1
- data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
- data/bundler/lib/bundler/man/bundle.1 +1 -1
- data/bundler/lib/bundler/man/gemfile.5 +28 -2
- data/bundler/lib/bundler/man/gemfile.5.ronn +9 -1
- data/bundler/lib/bundler/plugin/api/source.rb +1 -0
- 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 -31
- data/bundler/lib/bundler/rubygems_ext.rb +2 -0
- data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
- data/bundler/lib/bundler/rubygems_integration.rb +11 -48
- data/bundler/lib/bundler/self_manager.rb +76 -0
- data/bundler/lib/bundler/shared_helpers.rb +4 -12
- data/bundler/lib/bundler/source/git/git_proxy.rb +2 -2
- data/bundler/lib/bundler/source/metadata.rb +1 -1
- data/bundler/lib/bundler/source/rubygems.rb +16 -12
- data/bundler/lib/bundler/source/rubygems_aggregate.rb +1 -1
- data/bundler/lib/bundler/source.rb +1 -1
- data/bundler/lib/bundler/source_list.rb +7 -29
- 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/github/workflows/main.yml.tt +2 -2
- data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
- data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- 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/.document +1 -0
- 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 +5 -3
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
- 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/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/bundler_version_finder.rb +10 -42
- data/lib/rubygems/command_manager.rb +4 -2
- data/lib/rubygems/commands/install_command.rb +5 -2
- data/lib/rubygems/commands/pristine_command.rb +8 -2
- data/lib/rubygems/commands/server_command.rb +14 -77
- data/lib/rubygems/commands/setup_command.rb +21 -22
- data/lib/rubygems/commands/update_command.rb +9 -4
- data/lib/rubygems/defaults.rb +2 -20
- data/lib/rubygems/dependency.rb +7 -7
- data/lib/rubygems/deprecate.rb +53 -6
- data/lib/rubygems/errors.rb +0 -3
- data/lib/rubygems/exceptions.rb +31 -1
- data/lib/rubygems/ext/builder.rb +5 -3
- data/lib/rubygems/install_update_options.rb +11 -2
- data/lib/rubygems/installer.rb +14 -12
- data/lib/rubygems/name_tuple.rb +2 -3
- data/lib/rubygems/optparse/.document +1 -0
- 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/policy.rb +1 -3
- data/lib/rubygems/security.rb +14 -7
- data/lib/rubygems/source.rb +3 -1
- data/lib/rubygems/spec_fetcher.rb +1 -1
- data/lib/rubygems/specification.rb +21 -21
- data/lib/rubygems/stub_specification.rb +1 -1
- data/lib/rubygems/text.rb +21 -20
- data/lib/rubygems/tsort/.document +1 -0
- 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 +48 -56
- 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 -76
- data/test/rubygems/test_gem_bundler_version_finder.rb +22 -43
- data/test/rubygems/test_gem_command_manager.rb +28 -2
- data/test/rubygems/test_gem_commands_install_command.rb +33 -0
- 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_setup_command.rb +17 -0
- data/test/rubygems/test_gem_commands_update_command.rb +2 -2
- data/test/rubygems/test_gem_dependency.rb +4 -8
- data/test/rubygems/test_gem_installer.rb +10 -5
- 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_stream_ui.rb +1 -1
- data/test/rubygems/test_gem_text.rb +6 -0
- data/test/rubygems/test_kernel.rb +1 -13
- data/test/rubygems/test_project_sanity.rb +1 -1
- data/test/rubygems/test_require.rb +4 -58
- data/test/rubygems/test_rubygems.rb +23 -0
- metadata +14 -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/deprecate.rb
CHANGED
@@ -1,23 +1,70 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
##
|
3
|
-
# Provides
|
4
|
-
#
|
3
|
+
# Provides 3 methods for declaring when something is going away.
|
4
|
+
#
|
5
|
+
# +deprecate(name, repl, year, month)+:
|
6
|
+
# Indicate something may be removed on/after a certain date.
|
7
|
+
#
|
8
|
+
# +rubygems_deprecate(name, replacement=:none)+:
|
9
|
+
# Indicate something will be removed in the next major RubyGems version,
|
10
|
+
# and (optionally) a replacement for it.
|
11
|
+
#
|
12
|
+
# +rubygems_deprecate_command+:
|
13
|
+
# Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
|
14
|
+
# removed in the next RubyGems version.
|
15
|
+
#
|
16
|
+
# Also provides +skip_during+ for temporarily turning off deprecation warnings.
|
17
|
+
# This is intended to be used in the test suite, so deprecation warnings
|
18
|
+
# don't cause test failures if you need to make sure stderr is otherwise empty.
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# Example usage of +deprecate+ and +rubygems_deprecate+:
|
5
22
|
#
|
6
23
|
# class Legacy
|
7
|
-
# def self.
|
24
|
+
# def self.some_class_method
|
8
25
|
# # ...
|
9
26
|
# end
|
10
27
|
#
|
11
|
-
# def
|
28
|
+
# def some_instance_method
|
29
|
+
# # ...
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# def some_old_method
|
12
33
|
# # ...
|
13
34
|
# end
|
14
35
|
#
|
15
36
|
# extend Gem::Deprecate
|
16
|
-
# deprecate :
|
37
|
+
# deprecate :some_instance_method, "X.z", 2011, 4
|
38
|
+
# rubygems_deprecate :some_old_method, "Modern#some_new_method"
|
17
39
|
#
|
18
40
|
# class << self
|
19
41
|
# extend Gem::Deprecate
|
20
|
-
# deprecate :
|
42
|
+
# deprecate :some_class_method, :none, 2011, 4
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
#
|
47
|
+
# Example usage of +rubygems_deprecate_command+:
|
48
|
+
#
|
49
|
+
# class Gem::Commands::QueryCommand < Gem::Command
|
50
|
+
# extend Gem::Deprecate
|
51
|
+
# rubygems_deprecate_command
|
52
|
+
#
|
53
|
+
# # ...
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
#
|
57
|
+
# Example usage of +skip_during+:
|
58
|
+
#
|
59
|
+
# class TestSomething < Gem::Testcase
|
60
|
+
# def test_some_thing_with_deprecations
|
61
|
+
# Gem::Deprecate.skip_during do
|
62
|
+
# actual_stdout, actual_stderr = capture_output do
|
63
|
+
# Gem.something_deprecated
|
64
|
+
# end
|
65
|
+
# assert_empty actual_stdout
|
66
|
+
# assert_equal(expected, actual_stderr)
|
67
|
+
# end
|
21
68
|
# end
|
22
69
|
# end
|
23
70
|
|
data/lib/rubygems/errors.rb
CHANGED
@@ -59,9 +59,6 @@ module Gem
|
|
59
59
|
private
|
60
60
|
|
61
61
|
def build_message
|
62
|
-
if name == "bundler" && message = Gem::BundlerVersionFinder.missing_version_message
|
63
|
-
return message
|
64
|
-
end
|
65
62
|
names = specs.map(&:full_name)
|
66
63
|
"Could not find '#{name}' (#{requirement}) - did find: [#{names.join ','}]\n"
|
67
64
|
end
|
data/lib/rubygems/exceptions.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'deprecate'
|
4
|
+
require_relative 'unknown_command_spell_checker'
|
4
5
|
|
5
6
|
##
|
6
7
|
# Base exception class for RubyGems. All exception raised by RubyGems are a
|
@@ -9,6 +10,34 @@ class Gem::Exception < RuntimeError; end
|
|
9
10
|
|
10
11
|
class Gem::CommandLineError < Gem::Exception; end
|
11
12
|
|
13
|
+
class Gem::UnknownCommandError < Gem::Exception
|
14
|
+
attr_reader :unknown_command
|
15
|
+
|
16
|
+
def initialize(unknown_command)
|
17
|
+
self.class.attach_correctable
|
18
|
+
|
19
|
+
@unknown_command = unknown_command
|
20
|
+
super("Unknown command #{unknown_command}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.attach_correctable
|
24
|
+
return if defined?(@attached)
|
25
|
+
|
26
|
+
if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
|
27
|
+
if DidYouMean.respond_to?(:correct_error)
|
28
|
+
DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
|
29
|
+
else
|
30
|
+
DidYouMean::SPELL_CHECKERS['Gem::UnknownCommandError'] =
|
31
|
+
Gem::UnknownCommandSpellChecker
|
32
|
+
|
33
|
+
prepend DidYouMean::Correctable
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
@attached = true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
12
41
|
class Gem::DependencyError < Gem::Exception; end
|
13
42
|
|
14
43
|
class Gem::DependencyRemovalException < Gem::Exception; end
|
@@ -200,7 +229,7 @@ class Gem::SystemExitException < SystemExit
|
|
200
229
|
def initialize(exit_code)
|
201
230
|
@exit_code = exit_code
|
202
231
|
|
203
|
-
super "Exiting RubyGems with exit_code #{exit_code}"
|
232
|
+
super exit_code, "Exiting RubyGems with exit_code #{exit_code}"
|
204
233
|
end
|
205
234
|
end
|
206
235
|
|
@@ -259,3 +288,4 @@ end
|
|
259
288
|
# Backwards compatible typo'd exception class for early RubyGems 2.0.x
|
260
289
|
|
261
290
|
Gem::UnsatisfiableDepedencyError = Gem::UnsatisfiableDependencyError # :nodoc:
|
291
|
+
Gem.deprecate_constant :UnsatisfiableDepedencyError
|
data/lib/rubygems/ext/builder.rb
CHANGED
@@ -64,14 +64,16 @@ class Gem::Ext::Builder
|
|
64
64
|
require "open3"
|
65
65
|
# Set $SOURCE_DATE_EPOCH for the subprocess.
|
66
66
|
env = {'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string}
|
67
|
-
output, status =
|
67
|
+
output, status = begin
|
68
|
+
Open3.capture2e(env, *command, :chdir => dir)
|
69
|
+
rescue => error
|
70
|
+
raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
|
71
|
+
end
|
68
72
|
if verbose
|
69
73
|
puts output
|
70
74
|
else
|
71
75
|
results << output
|
72
76
|
end
|
73
|
-
rescue => error
|
74
|
-
raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"
|
75
77
|
ensure
|
76
78
|
ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
|
77
79
|
end
|
@@ -181,10 +181,19 @@ module Gem::InstallUpdateOptions
|
|
181
181
|
end
|
182
182
|
|
183
183
|
##
|
184
|
-
# Default options for the gem install
|
184
|
+
# Default options for the gem install and update commands.
|
185
|
+
|
186
|
+
def install_update_options
|
187
|
+
{
|
188
|
+
:document => %w[ri],
|
189
|
+
}
|
190
|
+
end
|
191
|
+
|
192
|
+
##
|
193
|
+
# Default description for the gem install and update commands.
|
185
194
|
|
186
195
|
def install_update_defaults_str
|
187
|
-
'--document=
|
196
|
+
'--document=ri'
|
188
197
|
end
|
189
198
|
|
190
199
|
end
|
data/lib/rubygems/installer.rb
CHANGED
@@ -293,8 +293,6 @@ class Gem::Installer
|
|
293
293
|
def install
|
294
294
|
pre_install_checks
|
295
295
|
|
296
|
-
FileUtils.rm_f File.join gem_home, 'specifications', spec.spec_name
|
297
|
-
|
298
296
|
run_pre_install_hooks
|
299
297
|
|
300
298
|
# Set loaded_from to ensure extension_dir is correct
|
@@ -448,13 +446,9 @@ class Gem::Installer
|
|
448
446
|
# specifications directory.
|
449
447
|
|
450
448
|
def write_spec
|
451
|
-
|
452
|
-
spec.installed_by_version = Gem.rubygems_version
|
453
|
-
|
454
|
-
file.puts spec.to_ruby_for_cache
|
449
|
+
spec.installed_by_version = Gem.rubygems_version
|
455
450
|
|
456
|
-
|
457
|
-
end
|
451
|
+
Gem.write_binary(spec_file, spec.to_ruby_for_cache)
|
458
452
|
end
|
459
453
|
|
460
454
|
##
|
@@ -462,9 +456,7 @@ class Gem::Installer
|
|
462
456
|
# specifications/default directory.
|
463
457
|
|
464
458
|
def write_default_spec
|
465
|
-
|
466
|
-
file.puts spec.to_ruby
|
467
|
-
end
|
459
|
+
Gem.write_binary(default_spec_file, spec.to_ruby)
|
468
460
|
end
|
469
461
|
|
470
462
|
##
|
@@ -776,7 +768,7 @@ str = ARGV.first
|
|
776
768
|
if str
|
777
769
|
str = str.b[/\\A_(.*)_\\z/, 1]
|
778
770
|
if str and Gem::Version.correct?(str)
|
779
|
-
|
771
|
+
#{explicit_version_requirement(spec.name)}
|
780
772
|
ARGV.shift
|
781
773
|
end
|
782
774
|
end
|
@@ -799,6 +791,16 @@ Gem.use_gemdeps
|
|
799
791
|
TEXT
|
800
792
|
end
|
801
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
|
+
|
802
804
|
##
|
803
805
|
# return the stub script text used to launch the true Ruby script
|
804
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
|
@@ -0,0 +1 @@
|
|
1
|
+
# Vendored files do not need to be documented
|
@@ -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/requirement.rb
CHANGED
@@ -115,11 +115,9 @@ class Gem::Security::Policy
|
|
115
115
|
raise Gem::Security::Exception, 'missing key or signature'
|
116
116
|
end
|
117
117
|
|
118
|
-
public_key = Gem::Security.get_public_key(key)
|
119
|
-
|
120
118
|
raise Gem::Security::Exception,
|
121
119
|
"certificate #{signer.subject} does not match the signing key" unless
|
122
|
-
signer.
|
120
|
+
signer.check_private_key(key)
|
123
121
|
|
124
122
|
true
|
125
123
|
end
|
data/lib/rubygems/security.rb
CHANGED
@@ -424,6 +424,8 @@ module Gem::Security
|
|
424
424
|
# Gets the right public key from a PKey instance
|
425
425
|
|
426
426
|
def self.get_public_key(key)
|
427
|
+
# Ruby 3.0 (Ruby/OpenSSL 2.2) or later
|
428
|
+
return OpenSSL::PKey.read(key.public_to_der) if key.respond_to?(:public_to_der)
|
427
429
|
return key.public_key unless key.is_a?(OpenSSL::PKey::EC)
|
428
430
|
|
429
431
|
ec_key = OpenSSL::PKey::EC.new(key.group.curve_name)
|
@@ -490,9 +492,13 @@ module Gem::Security
|
|
490
492
|
when 'rsa'
|
491
493
|
OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH)
|
492
494
|
when 'ec'
|
493
|
-
|
494
|
-
|
495
|
-
|
495
|
+
if RUBY_VERSION >= "2.4.0"
|
496
|
+
OpenSSL::PKey::EC.generate(EC_NAME)
|
497
|
+
else
|
498
|
+
domain_key = OpenSSL::PKey::EC.new(EC_NAME)
|
499
|
+
domain_key.generate_key
|
500
|
+
domain_key
|
501
|
+
end
|
496
502
|
else
|
497
503
|
raise Gem::Security::Exception,
|
498
504
|
"#{algorithm} algorithm not found. RSA, DSA, and EC algorithms are supported."
|
@@ -510,9 +516,10 @@ module Gem::Security
|
|
510
516
|
|
511
517
|
dcs = dcs.split '.'
|
512
518
|
|
513
|
-
|
514
|
-
|
515
|
-
|
519
|
+
OpenSSL::X509::Name.new([
|
520
|
+
["CN", cn],
|
521
|
+
*dcs.map {|dc| ["DC", dc] },
|
522
|
+
])
|
516
523
|
end
|
517
524
|
|
518
525
|
##
|
@@ -526,7 +533,7 @@ module Gem::Security
|
|
526
533
|
raise Gem::Security::Exception,
|
527
534
|
"incorrect signing key for re-signing " +
|
528
535
|
"#{expired_certificate.subject}" unless
|
529
|
-
expired_certificate.
|
536
|
+
expired_certificate.check_private_key(private_key)
|
530
537
|
|
531
538
|
unless expired_certificate.subject.to_s ==
|
532
539
|
expired_certificate.issuer.to_s
|
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
|
@@ -9,6 +9,8 @@
|
|
9
9
|
require_relative 'deprecate'
|
10
10
|
require_relative 'basic_specification'
|
11
11
|
require_relative 'stub_specification'
|
12
|
+
require_relative 'platform'
|
13
|
+
require_relative 'requirement'
|
12
14
|
require_relative 'specification_policy'
|
13
15
|
require_relative 'util/list'
|
14
16
|
|
@@ -179,18 +181,14 @@ class Gem::Specification < Gem::BasicSpecification
|
|
179
181
|
end
|
180
182
|
|
181
183
|
def self.clear_specs # :nodoc:
|
182
|
-
@@
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
@@active_stub_with_requirable_file = {}
|
188
|
-
end
|
184
|
+
@@all = nil
|
185
|
+
@@stubs = nil
|
186
|
+
@@stubs_by_name = {}
|
187
|
+
@@spec_with_requirable_file = {}
|
188
|
+
@@active_stub_with_requirable_file = {}
|
189
189
|
end
|
190
190
|
private_class_method :clear_specs
|
191
191
|
|
192
|
-
@@all_specs_mutex = Thread::Mutex.new
|
193
|
-
|
194
192
|
clear_specs
|
195
193
|
|
196
194
|
# Sentinel object to represent "not found" stubs
|
@@ -287,6 +285,15 @@ class Gem::Specification < Gem::BasicSpecification
|
|
287
285
|
######################################################################
|
288
286
|
# :section: Recommended gemspec attributes
|
289
287
|
|
288
|
+
##
|
289
|
+
# The version of Ruby required by this gem
|
290
|
+
#
|
291
|
+
# Usage:
|
292
|
+
#
|
293
|
+
# spec.required_ruby_version = '>= 2.7.0'
|
294
|
+
|
295
|
+
attr_reader :required_ruby_version
|
296
|
+
|
290
297
|
##
|
291
298
|
# A long description of this gem
|
292
299
|
#
|
@@ -522,11 +529,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
522
529
|
@require_paths = Array(val)
|
523
530
|
end
|
524
531
|
|
525
|
-
##
|
526
|
-
# The version of Ruby required by this gem
|
527
|
-
|
528
|
-
attr_reader :required_ruby_version
|
529
|
-
|
530
532
|
##
|
531
533
|
# The RubyGems version required by this gem
|
532
534
|
|
@@ -754,7 +756,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
754
756
|
attr_accessor :specification_version
|
755
757
|
|
756
758
|
def self._all # :nodoc:
|
757
|
-
@@
|
759
|
+
@@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec)
|
758
760
|
end
|
759
761
|
|
760
762
|
def self.clear_load_cache # :nodoc:
|
@@ -857,7 +859,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
857
859
|
next names if names.nonzero?
|
858
860
|
versions = b.version <=> a.version
|
859
861
|
next versions if versions.nonzero?
|
860
|
-
b.platform
|
862
|
+
Gem::Platform.sort_priority(b.platform)
|
861
863
|
end
|
862
864
|
end
|
863
865
|
|
@@ -993,7 +995,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
993
995
|
def self.find_by_path(path)
|
994
996
|
path = path.dup.freeze
|
995
997
|
spec = @@spec_with_requirable_file[path] ||= (stubs.find do |s|
|
996
|
-
next unless Gem::BundlerVersionFinder.compatible?(s)
|
997
998
|
s.contains_requirable_file? path
|
998
999
|
end || NOT_FOUND)
|
999
1000
|
spec.to_spec
|
@@ -1006,7 +1007,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1006
1007
|
def self.find_inactive_by_path(path)
|
1007
1008
|
stub = stubs.find do |s|
|
1008
1009
|
next if s.activated?
|
1009
|
-
next unless Gem::BundlerVersionFinder.compatible?(s)
|
1010
1010
|
s.contains_requirable_file? path
|
1011
1011
|
end
|
1012
1012
|
stub && stub.to_spec
|
@@ -1082,7 +1082,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1082
1082
|
# +prerelease+ is true.
|
1083
1083
|
|
1084
1084
|
def self.latest_specs(prerelease = false)
|
1085
|
-
_latest_specs Gem::Specification.
|
1085
|
+
_latest_specs Gem::Specification.stubs, prerelease
|
1086
1086
|
end
|
1087
1087
|
|
1088
1088
|
##
|
@@ -1116,7 +1116,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1116
1116
|
file = file.dup.tap(&Gem::UNTAINT)
|
1117
1117
|
return unless File.file?(file)
|
1118
1118
|
|
1119
|
-
code =
|
1119
|
+
code = Gem.open_with_flock(file, 'r:UTF-8:-', &:read)
|
1120
1120
|
|
1121
1121
|
code.tap(&Gem::UNTAINT)
|
1122
1122
|
|
@@ -2331,7 +2331,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2331
2331
|
# Returns an object you can use to sort specifications in #sort_by.
|
2332
2332
|
|
2333
2333
|
def sort_obj
|
2334
|
-
[@name, @version,
|
2334
|
+
[@name, @version, Gem::Platform.sort_priority(@new_platform)]
|
2335
2335
|
end
|
2336
2336
|
|
2337
2337
|
##
|
@@ -110,7 +110,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
|
110
110
|
begin
|
111
111
|
saved_lineno = $.
|
112
112
|
|
113
|
-
|
113
|
+
Gem.open_with_flock loaded_from, OPEN_MODE do |file|
|
114
114
|
begin
|
115
115
|
file.readline # discard encoding line
|
116
116
|
stubline = file.readline.chomp
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
# Vendored files do not need to be documented
|
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
|
|