rubygems-update 3.2.30 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -4
  3. data/CONTRIBUTING.md +40 -10
  4. data/Manifest.txt +28 -5
  5. data/POLICIES.md +22 -8
  6. data/README.md +9 -7
  7. data/UPGRADING.md +5 -81
  8. data/bin/gem +1 -6
  9. data/bundler/CHANGELOG.md +86 -0
  10. data/bundler/exe/bundle +7 -8
  11. data/bundler/lib/bundler/build_metadata.rb +2 -2
  12. data/bundler/lib/bundler/cli/doctor.rb +3 -2
  13. data/bundler/lib/bundler/cli/gem.rb +70 -8
  14. data/bundler/lib/bundler/cli/info.rb +6 -1
  15. data/bundler/lib/bundler/cli/install.rb +2 -0
  16. data/bundler/lib/bundler/cli/update.rb +2 -2
  17. data/bundler/lib/bundler/cli.rb +9 -1
  18. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -5
  19. data/bundler/lib/bundler/definition.rb +66 -120
  20. data/bundler/lib/bundler/dependency.rb +5 -7
  21. data/bundler/lib/bundler/dsl.rb +18 -30
  22. data/bundler/lib/bundler/endpoint_specification.rb +0 -8
  23. data/bundler/lib/bundler/environment_preserver.rb +4 -1
  24. data/bundler/lib/bundler/fetcher/compact_index.rb +9 -4
  25. data/bundler/lib/bundler/fetcher.rb +2 -5
  26. data/bundler/lib/bundler/gem_helper.rb +2 -2
  27. data/bundler/lib/bundler/injector.rb +10 -1
  28. data/bundler/lib/bundler/installer/gem_installer.rb +1 -6
  29. data/bundler/lib/bundler/installer.rb +1 -4
  30. data/bundler/lib/bundler/lazy_specification.rb +17 -1
  31. data/bundler/lib/bundler/lockfile_parser.rb +10 -12
  32. data/bundler/lib/bundler/man/bundle-add.1 +10 -2
  33. data/bundler/lib/bundler/man/bundle-add.1.ronn +7 -1
  34. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-config.1 +5 -5
  39. data/bundler/lib/bundler/man/bundle-config.1.ronn +5 -5
  40. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-gem.1 +14 -1
  43. data/bundler/lib/bundler/man/bundle-gem.1.ronn +16 -0
  44. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  46. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  47. data/bundler/lib/bundler/man/bundle-install.1 +2 -2
  48. data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
  49. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  55. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  56. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  57. data/bundler/lib/bundler/man/bundle-update.1 +2 -2
  58. data/bundler/lib/bundler/man/bundle-update.1.ronn +2 -1
  59. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  60. data/bundler/lib/bundler/man/bundle.1 +1 -1
  61. data/bundler/lib/bundler/man/gemfile.5 +28 -2
  62. data/bundler/lib/bundler/man/gemfile.5.ronn +9 -1
  63. data/bundler/lib/bundler/plugin/api/source.rb +1 -0
  64. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  65. data/bundler/lib/bundler/process_lock.rb +1 -1
  66. data/bundler/lib/bundler/psyched_yaml.rb +1 -13
  67. data/bundler/lib/bundler/resolver.rb +34 -31
  68. data/bundler/lib/bundler/rubygems_ext.rb +2 -0
  69. data/bundler/lib/bundler/rubygems_integration.rb +11 -48
  70. data/bundler/lib/bundler/runtime.rb +1 -1
  71. data/bundler/lib/bundler/self_manager.rb +73 -0
  72. data/bundler/lib/bundler/shared_helpers.rb +4 -12
  73. data/bundler/lib/bundler/source/git/git_proxy.rb +7 -4
  74. data/bundler/lib/bundler/source/metadata.rb +1 -1
  75. data/bundler/lib/bundler/source/rubygems.rb +17 -13
  76. data/bundler/lib/bundler/source/rubygems_aggregate.rb +1 -1
  77. data/bundler/lib/bundler/source.rb +1 -1
  78. data/bundler/lib/bundler/source_list.rb +7 -29
  79. data/bundler/lib/bundler/spec_set.rb +1 -1
  80. data/bundler/lib/bundler/templates/Executable.bundler +1 -1
  81. data/bundler/lib/bundler/templates/Gemfile +0 -2
  82. data/bundler/lib/bundler/templates/gems.rb +0 -3
  83. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  84. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  85. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -2
  86. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +13 -13
  87. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  88. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  89. data/bundler/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  90. data/bundler/lib/bundler/ui/shell.rb +1 -1
  91. data/bundler/lib/bundler/vendor/.document +1 -0
  92. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  93. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  94. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  95. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  96. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  97. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  98. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  99. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  100. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  101. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  102. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  103. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  104. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  105. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  106. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  107. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  108. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  109. data/bundler/lib/bundler/version.rb +1 -1
  110. data/bundler/lib/bundler.rb +9 -3
  111. data/hide_lib_for_update/note.txt +0 -4
  112. data/lib/rubygems/command.rb +4 -4
  113. data/lib/rubygems/command_manager.rb +4 -2
  114. data/lib/rubygems/commands/cert_command.rb +6 -6
  115. data/lib/rubygems/commands/fetch_command.rb +1 -1
  116. data/lib/rubygems/commands/install_command.rb +5 -2
  117. data/lib/rubygems/commands/pristine_command.rb +8 -2
  118. data/lib/rubygems/commands/server_command.rb +14 -77
  119. data/lib/rubygems/commands/setup_command.rb +84 -76
  120. data/lib/rubygems/commands/uninstall_command.rb +1 -1
  121. data/lib/rubygems/commands/update_command.rb +10 -5
  122. data/lib/rubygems/defaults.rb +2 -20
  123. data/lib/rubygems/dependency_list.rb +2 -2
  124. data/lib/rubygems/deprecate.rb +53 -6
  125. data/lib/rubygems/exceptions.rb +27 -1
  126. data/lib/rubygems/ext/builder.rb +11 -8
  127. data/lib/rubygems/ext/cmake_builder.rb +1 -1
  128. data/lib/rubygems/install_update_options.rb +13 -4
  129. data/lib/rubygems/installer.rb +46 -27
  130. data/lib/rubygems/local_remote_options.rb +3 -3
  131. data/lib/rubygems/name_tuple.rb +2 -3
  132. data/lib/rubygems/optparse/.document +1 -0
  133. data/lib/rubygems/optparse/COPYING +56 -0
  134. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  135. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  136. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  137. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  138. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  139. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  140. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  141. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  142. data/lib/rubygems/optparse/lib/optparse.rb +2230 -0
  143. data/lib/rubygems/optparse.rb +3 -0
  144. data/lib/rubygems/path_support.rb +1 -6
  145. data/lib/rubygems/platform.rb +4 -0
  146. data/lib/rubygems/remote_fetcher.rb +1 -1
  147. data/lib/rubygems/request_set.rb +2 -2
  148. data/lib/rubygems/requirement.rb +1 -1
  149. data/lib/rubygems/resolver/installer_set.rb +1 -1
  150. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  151. data/lib/rubygems/security.rb +4 -3
  152. data/lib/rubygems/security_option.rb +3 -3
  153. data/lib/rubygems/source.rb +3 -1
  154. data/lib/rubygems/spec_fetcher.rb +1 -1
  155. data/lib/rubygems/specification.rb +46 -46
  156. data/lib/rubygems/text.rb +21 -20
  157. data/lib/rubygems/tsort/.document +1 -0
  158. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  159. data/lib/rubygems/tsort/lib/tsort.rb +454 -0
  160. data/lib/rubygems/tsort.rb +3 -0
  161. data/lib/rubygems/uninstaller.rb +4 -1
  162. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  163. data/lib/rubygems/util/licenses.rb +2 -0
  164. data/lib/rubygems/version.rb +2 -0
  165. data/lib/rubygems/version_option.rb +2 -2
  166. data/lib/rubygems.rb +13 -10
  167. data/rubygems-update.gemspec +1 -1
  168. data/setup.rb +1 -6
  169. data/test/rubygems/encrypted_private_key.pem +26 -26
  170. data/test/rubygems/helper.rb +48 -38
  171. data/test/rubygems/test_config.rb +2 -2
  172. data/test/rubygems/test_exit.rb +11 -0
  173. data/test/rubygems/test_gem.rb +46 -41
  174. data/test/rubygems/test_gem_command.rb +1 -1
  175. data/test/rubygems/test_gem_command_manager.rb +28 -2
  176. data/test/rubygems/test_gem_commands_cert_command.rb +8 -8
  177. data/test/rubygems/test_gem_commands_fetch_command.rb +36 -0
  178. data/test/rubygems/test_gem_commands_open_command.rb +1 -1
  179. data/test/rubygems/test_gem_commands_server_command.rb +4 -46
  180. data/test/rubygems/test_gem_commands_setup_command.rb +67 -19
  181. data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
  182. data/test/rubygems/test_gem_commands_uninstall_command.rb +1 -1
  183. data/test/rubygems/test_gem_commands_update_command.rb +2 -2
  184. data/test/rubygems/test_gem_commands_yank_command.rb +1 -1
  185. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +7 -3
  186. data/test/rubygems/test_gem_install_update_options.rb +2 -2
  187. data/test/rubygems/test_gem_installer.rb +37 -5
  188. data/test/rubygems/test_gem_path_support.rb +2 -6
  189. data/test/rubygems/test_gem_remote_fetcher.rb +15 -0
  190. data/test/rubygems/test_gem_request.rb +10 -4
  191. data/test/rubygems/test_gem_requirement.rb +0 -1
  192. data/test/rubygems/test_gem_resolver.rb +7 -7
  193. data/test/rubygems/test_gem_security.rb +1 -1
  194. data/test/rubygems/test_gem_specification.rb +27 -25
  195. data/test/rubygems/test_gem_text.rb +6 -0
  196. data/test/rubygems/test_project_sanity.rb +1 -1
  197. data/test/rubygems/test_require.rb +8 -35
  198. data/test/rubygems/test_rubygems.rb +23 -0
  199. metadata +31 -8
  200. data/bundler/lib/bundler/gemdeps.rb +0 -29
  201. data/lib/rubygems/server.rb +0 -882
  202. data/test/rubygems/bogussources.rb +0 -9
  203. data/test/rubygems/test_gem_server.rb +0 -608
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'optparse/lib/optparse'
@@ -72,12 +72,7 @@ class Gem::PathSupport
72
72
 
73
73
  # Return the default Gem path
74
74
  def default_path
75
- gem_path = Gem.default_path + [@home]
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)
@@ -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?
@@ -284,7 +284,7 @@ class Gem::RemoteFetcher
284
284
 
285
285
  data = fetch_path(uri, mtime)
286
286
 
287
- if data == nil # indicates the server returned 304 Not Modified
287
+ if data.nil? # indicates the server returned 304 Not Modified
288
288
  return Gem.read_binary(path)
289
289
  end
290
290
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'tsort'
2
+ require_relative 'tsort'
3
3
 
4
4
  ##
5
5
  # A RequestSet groups a request to activate a set of dependencies.
@@ -15,7 +15,7 @@ require 'tsort'
15
15
  # #=> ["nokogiri-1.6.0", "mini_portile-0.5.1", "pg-0.17.0"]
16
16
 
17
17
  class Gem::RequestSet
18
- include TSort
18
+ include Gem::TSort
19
19
 
20
20
  ##
21
21
  # Array of gems to install even if already installed
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require_relative "deprecate"
2
+ require_relative "version"
3
3
 
4
4
  ##
5
5
  # A Requirement is a set of one or more version restrictions. It supports a
@@ -71,7 +71,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
71
71
  end
72
72
 
73
73
  found = found.sort_by do |s|
74
- [s.version, s.platform == Gem::Platform::RUBY ? -1 : 1]
74
+ [s.version, Gem::Platform.sort_priority(s.platform)]
75
75
  end
76
76
 
77
77
  newest = found.last
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tsort'
3
+ require_relative '../../../../tsort'
4
4
 
5
5
  require_relative 'dependency_graph/log'
6
6
  require_relative 'dependency_graph/vertex'
@@ -17,7 +17,7 @@ module Gem::Resolver::Molinillo
17
17
  vertices.values.each { |v| yield v }
18
18
  end
19
19
 
20
- include TSort
20
+ include Gem::TSort
21
21
 
22
22
  # @!visibility private
23
23
  alias tsort_each_node each
@@ -510,9 +510,10 @@ module Gem::Security
510
510
 
511
511
  dcs = dcs.split '.'
512
512
 
513
- name = "CN=#{cn}/#{dcs.map {|dc| "DC=#{dc}" }.join '/'}"
514
-
515
- OpenSSL::X509::Name.parse name
513
+ OpenSSL::X509::Name.new([
514
+ ["CN", cn],
515
+ *dcs.map {|dc| ["DC", dc] },
516
+ ])
516
517
  end
517
518
 
518
519
  ##
@@ -19,16 +19,16 @@ end
19
19
 
20
20
  module Gem::SecurityOption
21
21
  def add_security_option
22
- OptionParser.accept Gem::Security::Policy do |value|
22
+ Gem::OptionParser.accept Gem::Security::Policy do |value|
23
23
  require_relative 'security'
24
24
 
25
- raise OptionParser::InvalidArgument, 'OpenSSL not installed' unless
25
+ raise Gem::OptionParser::InvalidArgument, 'OpenSSL not installed' unless
26
26
  defined?(Gem::Security::HighSecurity)
27
27
 
28
28
  policy = Gem::Security::Policies[value]
29
29
  unless policy
30
30
  valid = Gem::Security::Policies.keys.sort
31
- raise OptionParser::InvalidArgument, "#{value} (#{valid.join ', '} are valid)"
31
+ raise Gem::OptionParser::InvalidArgument, "#{value} (#{valid.join ', '} are valid)"
32
32
  end
33
33
  policy
34
34
  end
@@ -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
@@ -121,7 +121,7 @@ class Gem::SpecFetcher
121
121
  end
122
122
  end
123
123
 
124
- tuples = tuples.sort_by {|x| x[0] }
124
+ tuples = tuples.sort_by {|x| x[0].version }
125
125
 
126
126
  return [tuples, errors]
127
127
  end
@@ -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
 
@@ -102,12 +104,8 @@ class Gem::Specification < Gem::BasicSpecification
102
104
  today = Time.now.utc
103
105
  TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
104
106
 
105
- # rubocop:disable Style/MutableConstant
106
- LOAD_CACHE = {} # :nodoc:
107
- # rubocop:enable Style/MutableConstant
108
- LOAD_CACHE_MUTEX = Thread::Mutex.new
109
-
110
- private_constant :LOAD_CACHE if defined? private_constant
107
+ @load_cache = {} # :nodoc:
108
+ @load_cache_mutex = Thread::Mutex.new
111
109
 
112
110
  VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
113
111
 
@@ -182,13 +180,19 @@ class Gem::Specification < Gem::BasicSpecification
182
180
  @@default_value[k].nil?
183
181
  end
184
182
 
185
- @@stubs = nil
186
- @@stubs_by_name = {}
183
+ def self.clear_specs # :nodoc:
184
+ @@all = nil
185
+ @@stubs = nil
186
+ @@stubs_by_name = {}
187
+ @@spec_with_requirable_file = {}
188
+ @@active_stub_with_requirable_file = {}
189
+ end
190
+ private_class_method :clear_specs
191
+
192
+ clear_specs
187
193
 
188
194
  # Sentinel object to represent "not found" stubs
189
195
  NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc:
190
- @@spec_with_requirable_file = {}
191
- @@active_stub_with_requirable_file = {}
192
196
 
193
197
  # Tracking removed method calls to warn users during build time.
194
198
  REMOVED_METHODS = [:rubyforge_project=].freeze # :nodoc:
@@ -281,6 +285,15 @@ class Gem::Specification < Gem::BasicSpecification
281
285
  ######################################################################
282
286
  # :section: Recommended gemspec attributes
283
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
+
284
297
  ##
285
298
  # A long description of this gem
286
299
  #
@@ -324,17 +337,21 @@ class Gem::Specification < Gem::BasicSpecification
324
337
  # This should just be the name of your license. The full text of the license
325
338
  # should be inside of the gem (at the top level) when you build it.
326
339
  #
327
- # The simplest way, is to specify the standard SPDX ID
340
+ # The simplest way is to specify the standard SPDX ID
328
341
  # https://spdx.org/licenses/ for the license.
329
- # Ideally you should pick one that is OSI (Open Source Initiative)
342
+ # Ideally, you should pick one that is OSI (Open Source Initiative)
330
343
  # http://opensource.org/licenses/alphabetical approved.
331
344
  #
332
- # The most commonly used OSI approved licenses are MIT and Apache-2.0.
345
+ # The most commonly used OSI-approved licenses are MIT and Apache-2.0.
333
346
  # GitHub also provides a license picker at http://choosealicense.com/.
334
347
  #
348
+ # You can also use a custom license file along with your gemspec and specify
349
+ # a LicenseRef-<idstring>, where idstring is the name of the file containing
350
+ # the license text.
351
+ #
335
352
  # You should specify a license for your gem so that people know how they are
336
- # permitted to use it, and any restrictions you're placing on it. Not
337
- # specifying a license means all rights are reserved; others have no rights
353
+ # permitted to use it and any restrictions you're placing on it. Not
354
+ # specifying a license means all rights are reserved; others have no right
338
355
  # to use the code for any purpose.
339
356
  #
340
357
  # You can set multiple licenses with #licenses=
@@ -512,11 +529,6 @@ class Gem::Specification < Gem::BasicSpecification
512
529
  @require_paths = Array(val)
513
530
  end
514
531
 
515
- ##
516
- # The version of Ruby required by this gem
517
-
518
- attr_reader :required_ruby_version
519
-
520
532
  ##
521
533
  # The RubyGems version required by this gem
522
534
 
@@ -744,23 +756,15 @@ class Gem::Specification < Gem::BasicSpecification
744
756
  attr_accessor :specification_version
745
757
 
746
758
  def self._all # :nodoc:
747
- unless defined?(@@all) && @@all
748
- @@all = stubs.map(&:to_spec)
749
-
750
- # After a reset, make sure already loaded specs
751
- # are still marked as activated.
752
- specs = {}
753
- Gem.loaded_specs.each_value{|s| specs[s] = true }
754
- @@all.each{|s| s.activated = true if specs[s] }
755
- end
756
- @@all
759
+ @@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec)
757
760
  end
758
761
 
759
- def self._clear_load_cache # :nodoc:
760
- LOAD_CACHE_MUTEX.synchronize do
761
- LOAD_CACHE.clear
762
+ def self.clear_load_cache # :nodoc:
763
+ @load_cache_mutex.synchronize do
764
+ @load_cache.clear
762
765
  end
763
766
  end
767
+ private_class_method :clear_load_cache
764
768
 
765
769
  def self.each_gemspec(dirs) # :nodoc:
766
770
  dirs.each do |dir|
@@ -855,7 +859,7 @@ class Gem::Specification < Gem::BasicSpecification
855
859
  next names if names.nonzero?
856
860
  versions = b.version <=> a.version
857
861
  next versions if versions.nonzero?
858
- b.platform == Gem::Platform::RUBY ? -1 : 1
862
+ Gem::Platform.sort_priority(b.platform)
859
863
  end
860
864
  end
861
865
 
@@ -1080,7 +1084,7 @@ class Gem::Specification < Gem::BasicSpecification
1080
1084
  # +prerelease+ is true.
1081
1085
 
1082
1086
  def self.latest_specs(prerelease = false)
1083
- _latest_specs Gem::Specification._all, prerelease
1087
+ _latest_specs Gem::Specification.stubs, prerelease
1084
1088
  end
1085
1089
 
1086
1090
  ##
@@ -1108,7 +1112,7 @@ class Gem::Specification < Gem::BasicSpecification
1108
1112
  def self.load(file)
1109
1113
  return unless file
1110
1114
 
1111
- _spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] }
1115
+ _spec = @load_cache_mutex.synchronize { @load_cache[file] }
1112
1116
  return _spec if _spec
1113
1117
 
1114
1118
  file = file.dup.tap(&Gem::UNTAINT)
@@ -1123,12 +1127,12 @@ class Gem::Specification < Gem::BasicSpecification
1123
1127
 
1124
1128
  if Gem::Specification === _spec
1125
1129
  _spec.loaded_from = File.expand_path file.to_s
1126
- LOAD_CACHE_MUTEX.synchronize do
1127
- prev = LOAD_CACHE[file]
1130
+ @load_cache_mutex.synchronize do
1131
+ prev = @load_cache[file]
1128
1132
  if prev
1129
1133
  _spec = prev
1130
1134
  else
1131
- LOAD_CACHE[file] = _spec
1135
+ @load_cache[file] = _spec
1132
1136
  end
1133
1137
  end
1134
1138
  return _spec
@@ -1226,12 +1230,8 @@ class Gem::Specification < Gem::BasicSpecification
1226
1230
  def self.reset
1227
1231
  @@dirs = nil
1228
1232
  Gem.pre_reset_hooks.each {|hook| hook.call }
1229
- @@all = nil
1230
- @@stubs = nil
1231
- @@stubs_by_name = {}
1232
- @@spec_with_requirable_file = {}
1233
- @@active_stub_with_requirable_file = {}
1234
- _clear_load_cache
1233
+ clear_specs
1234
+ clear_load_cache
1235
1235
  unresolved = unresolved_deps
1236
1236
  unless unresolved.empty?
1237
1237
  w = "W" + "ARN"
@@ -2333,7 +2333,7 @@ class Gem::Specification < Gem::BasicSpecification
2333
2333
  # Returns an object you can use to sort specifications in #sort_by.
2334
2334
 
2335
2335
  def sort_obj
2336
- [@name, @version, @new_platform == Gem::Platform::RUBY ? -1 : 1]
2336
+ [@name, @version, Gem::Platform.sort_priority(@new_platform)]
2337
2337
  end
2338
2338
 
2339
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
- s = str1
56
- t = str2
57
- n = s.length
58
- m = t.length
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
- str1.each_char.each_with_index do |char1,i|
67
- e = i + 1
64
+ # to avoid duplicating an enumerable object, create it outside of the loop
65
+ str2_codepoints = str2.codepoints
68
66
 
69
- str2.each_char.each_with_index do |char2,j|
70
- cost = (char1 == char2) ? 0 : 1
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
- d[j + 1] + 1, # insertion
73
- e + 1, # deletion
74
- d[j] + cost # substitution
75
- )
76
- d[j] = e
77
- e = x
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
- return x
84
+ x
84
85
  end
85
86
  end
@@ -0,0 +1 @@
1
+ # Vendored files do not need to be documented
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.