rubygems-update 3.7.1 → 4.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1434 -1317
  3. data/CODE_OF_CONDUCT.md +7 -129
  4. data/Manifest.txt +5 -11
  5. data/README.md +2 -2
  6. data/bundler/CHANGELOG.md +1001 -902
  7. data/bundler/README.md +4 -4
  8. data/bundler/bundler.gemspec +3 -3
  9. data/bundler/lib/bundler/build_metadata.rb +2 -2
  10. data/bundler/lib/bundler/capistrano.rb +1 -19
  11. data/bundler/lib/bundler/checksum.rb +6 -0
  12. data/bundler/lib/bundler/cli/cache.rb +1 -12
  13. data/bundler/lib/bundler/cli/common.rb +21 -4
  14. data/bundler/lib/bundler/cli/config.rb +1 -2
  15. data/bundler/lib/bundler/cli/console.rb +5 -0
  16. data/bundler/lib/bundler/cli/exec.rb +29 -4
  17. data/bundler/lib/bundler/cli/gem.rb +19 -33
  18. data/bundler/lib/bundler/cli/install.rb +7 -84
  19. data/bundler/lib/bundler/cli/issue.rb +2 -2
  20. data/bundler/lib/bundler/cli/list.rb +33 -2
  21. data/bundler/lib/bundler/cli/lock.rb +5 -5
  22. data/bundler/lib/bundler/cli/plugin.rb +5 -1
  23. data/bundler/lib/bundler/cli/show.rb +3 -7
  24. data/bundler/lib/bundler/cli/update.rb +3 -3
  25. data/bundler/lib/bundler/cli.rb +97 -95
  26. data/bundler/lib/bundler/compact_index_client.rb +0 -1
  27. data/bundler/lib/bundler/current_ruby.rb +3 -15
  28. data/bundler/lib/bundler/definition.rb +122 -95
  29. data/bundler/lib/bundler/deployment.rb +1 -64
  30. data/bundler/lib/bundler/digest.rb +1 -1
  31. data/bundler/lib/bundler/dsl.rb +14 -36
  32. data/bundler/lib/bundler/endpoint_specification.rb +0 -22
  33. data/bundler/lib/bundler/errors.rb +1 -5
  34. data/bundler/lib/bundler/feature_flag.rb +0 -33
  35. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  36. data/bundler/lib/bundler/friendly_errors.rb +2 -2
  37. data/bundler/lib/bundler/index.rb +0 -7
  38. data/bundler/lib/bundler/inline.rb +1 -1
  39. data/bundler/lib/bundler/installer/gem_installer.rb +0 -11
  40. data/bundler/lib/bundler/installer.rb +0 -6
  41. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  42. data/bundler/lib/bundler/lockfile_parser.rb +2 -12
  43. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-binstubs.1 +3 -6
  45. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  46. data/bundler/lib/bundler/man/bundle-cache.1 +2 -14
  47. data/bundler/lib/bundler/man/bundle-cache.1.ronn +1 -14
  48. data/bundler/lib/bundler/man/bundle-check.1 +2 -5
  49. data/bundler/lib/bundler/man/bundle-check.1.ronn +0 -5
  50. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-config.1 +36 -46
  52. data/bundler/lib/bundler/man/bundle-config.1.ronn +69 -75
  53. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-doctor.1 +4 -4
  55. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +4 -4
  56. data/bundler/lib/bundler/man/bundle-env.1 +1 -1
  57. data/bundler/lib/bundler/man/bundle-exec.1 +2 -5
  58. data/bundler/lib/bundler/man/bundle-exec.1.ronn +1 -5
  59. data/bundler/lib/bundler/man/bundle-fund.1 +1 -1
  60. data/bundler/lib/bundler/man/bundle-gem.1 +3 -6
  61. data/bundler/lib/bundler/man/bundle-gem.1.ronn +2 -5
  62. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  64. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  65. data/bundler/lib/bundler/man/bundle-install.1 +8 -59
  66. data/bundler/lib/bundler/man/bundle-install.1.ronn +12 -107
  67. data/bundler/lib/bundler/man/bundle-issue.1 +1 -1
  68. data/bundler/lib/bundler/man/bundle-licenses.1 +1 -1
  69. data/bundler/lib/bundler/man/bundle-list.1 +6 -1
  70. data/bundler/lib/bundler/man/bundle-list.1.ronn +5 -0
  71. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  72. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  73. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  74. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  75. data/bundler/lib/bundler/man/bundle-plugin.1 +33 -15
  76. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +36 -15
  77. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  78. data/bundler/lib/bundler/man/bundle-remove.1 +2 -8
  79. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -8
  80. data/bundler/lib/bundler/man/bundle-show.1 +2 -5
  81. data/bundler/lib/bundler/man/bundle-show.1.ronn +0 -4
  82. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  83. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  84. data/bundler/lib/bundler/man/bundle.1 +1 -10
  85. data/bundler/lib/bundler/man/bundle.1.ronn +0 -9
  86. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  87. data/bundler/lib/bundler/man/index.txt +0 -2
  88. data/bundler/lib/bundler/materialization.rb +1 -1
  89. data/bundler/lib/bundler/plugin/installer.rb +0 -10
  90. data/bundler/lib/bundler/plugin/source_list.rb +1 -1
  91. data/bundler/lib/bundler/plugin.rb +1 -1
  92. data/bundler/lib/bundler/resolver/package.rb +1 -0
  93. data/bundler/lib/bundler/resolver.rb +1 -1
  94. data/bundler/lib/bundler/ruby_dsl.rb +2 -0
  95. data/bundler/lib/bundler/ruby_version.rb +1 -3
  96. data/bundler/lib/bundler/rubygems_ext.rb +1 -1
  97. data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
  98. data/bundler/lib/bundler/rubygems_integration.rb +1 -5
  99. data/bundler/lib/bundler/self_manager.rb +1 -1
  100. data/bundler/lib/bundler/settings.rb +8 -27
  101. data/bundler/lib/bundler/shared_helpers.rb +8 -20
  102. data/bundler/lib/bundler/source/gemspec.rb +4 -0
  103. data/bundler/lib/bundler/source/git/git_proxy.rb +3 -11
  104. data/bundler/lib/bundler/source/git.rb +2 -3
  105. data/bundler/lib/bundler/source/path.rb +5 -7
  106. data/bundler/lib/bundler/source/rubygems.rb +11 -17
  107. data/bundler/lib/bundler/source.rb +1 -1
  108. data/bundler/lib/bundler/source_list.rb +4 -45
  109. data/bundler/lib/bundler/source_map.rb +2 -5
  110. data/bundler/lib/bundler/spec_set.rb +6 -15
  111. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  112. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  113. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  114. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  115. data/bundler/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  116. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  117. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  118. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +6 -0
  119. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  120. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +7 -4
  121. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  122. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  123. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  124. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  125. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +5 -2
  126. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +42 -6
  127. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -1
  128. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +2 -2
  129. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +3 -7
  130. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  131. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  132. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  133. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  134. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  135. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  136. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  137. data/bundler/lib/bundler/version.rb +1 -1
  138. data/bundler/lib/bundler/vlad.rb +1 -14
  139. data/bundler/lib/bundler.rb +6 -28
  140. data/doc/MAINTAINERS.txt +0 -7
  141. data/doc/bundler/UPGRADING.md +11 -27
  142. data/doc/rubygems/CONTRIBUTING.md +1 -1
  143. data/lib/rubygems/basic_specification.rb +3 -9
  144. data/lib/rubygems/bundler_version_finder.rb +1 -0
  145. data/lib/rubygems/command.rb +1 -1
  146. data/lib/rubygems/command_manager.rb +3 -4
  147. data/lib/rubygems/commands/build_command.rb +0 -7
  148. data/lib/rubygems/commands/cert_command.rb +1 -1
  149. data/lib/rubygems/commands/install_command.rb +1 -5
  150. data/lib/rubygems/commands/setup_command.rb +5 -3
  151. data/lib/rubygems/commands/sources_command.rb +122 -18
  152. data/lib/rubygems/config_file.rb +1 -1
  153. data/lib/rubygems/defaults.rb +1 -1
  154. data/lib/rubygems/dependency.rb +1 -1
  155. data/lib/rubygems/dependency_installer.rb +0 -77
  156. data/lib/rubygems/dependency_list.rb +1 -2
  157. data/lib/rubygems/deprecate.rb +74 -72
  158. data/lib/rubygems/doctor.rb +1 -1
  159. data/lib/rubygems/errors.rb +1 -1
  160. data/lib/rubygems/exceptions.rb +5 -15
  161. data/lib/rubygems/ext/builder.rb +6 -2
  162. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  163. data/lib/rubygems/ext/cmake_builder.rb +97 -8
  164. data/lib/rubygems/ext/configure_builder.rb +2 -2
  165. data/lib/rubygems/ext/ext_conf_builder.rb +6 -2
  166. data/lib/rubygems/ext/rake_builder.rb +2 -2
  167. data/lib/rubygems/gem_runner.rb +0 -1
  168. data/lib/rubygems/install_update_options.rb +1 -2
  169. data/lib/rubygems/installer.rb +16 -54
  170. data/lib/rubygems/name_tuple.rb +7 -1
  171. data/lib/rubygems/package/tar_header.rb +4 -4
  172. data/lib/rubygems/package/tar_reader.rb +2 -0
  173. data/lib/rubygems/package/tar_writer.rb +1 -1
  174. data/lib/rubygems/package.rb +21 -12
  175. data/lib/rubygems/platform.rb +31 -11
  176. data/lib/rubygems/remote_fetcher.rb +8 -5
  177. data/lib/rubygems/resolver/conflict.rb +1 -1
  178. data/lib/rubygems/resolver.rb +1 -1
  179. data/lib/rubygems/s3_uri_signer.rb +54 -7
  180. data/lib/rubygems/security/signer.rb +1 -1
  181. data/lib/rubygems/source.rb +2 -2
  182. data/lib/rubygems/source_list.rb +36 -0
  183. data/lib/rubygems/spec_fetcher.rb +4 -4
  184. data/lib/rubygems/specification.rb +5 -96
  185. data/lib/rubygems/specification_policy.rb +0 -36
  186. data/lib/rubygems/specification_record.rb +1 -1
  187. data/lib/rubygems/text.rb +1 -1
  188. data/lib/rubygems/uninstaller.rb +17 -6
  189. data/lib/rubygems/user_interaction.rb +6 -9
  190. data/lib/rubygems/util.rb +0 -22
  191. data/lib/rubygems/validator.rb +1 -1
  192. data/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb +25 -9
  193. data/lib/rubygems/vendor/net-http/lib/net/http/responses.rb +2 -2
  194. data/lib/rubygems/vendor/net-http/lib/net/http.rb +14 -14
  195. data/lib/rubygems/vendor/optparse/lib/optparse.rb +82 -41
  196. data/lib/rubygems/vendor/resolv/lib/resolv.rb +1 -1
  197. data/lib/rubygems/vendor/timeout/lib/timeout.rb +4 -1
  198. data/lib/rubygems/vendor/uri/lib/uri/common.rb +57 -15
  199. data/lib/rubygems/vendor/uri/lib/uri/file.rb +1 -1
  200. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +34 -21
  201. data/lib/rubygems/vendor/uri/lib/uri/http.rb +12 -0
  202. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  203. data/lib/rubygems/vendor/uri/lib/uri/version.rb +2 -2
  204. data/lib/rubygems/version.rb +2 -17
  205. data/lib/rubygems/win_platform.rb +31 -0
  206. data/lib/rubygems.rb +10 -38
  207. data/rubygems-update.gemspec +4 -4
  208. metadata +10 -18
  209. data/bundler/lib/bundler/cli/inject.rb +0 -60
  210. data/bundler/lib/bundler/cli/viz.rb +0 -31
  211. data/bundler/lib/bundler/graph.rb +0 -152
  212. data/bundler/lib/bundler/man/bundle-inject.1 +0 -31
  213. data/bundler/lib/bundler/man/bundle-inject.1.ronn +0 -32
  214. data/bundler/lib/bundler/man/bundle-viz.1 +0 -30
  215. data/bundler/lib/bundler/man/bundle-viz.1.ronn +0 -36
  216. data/bundler/lib/bundler/similarity_detector.rb +0 -63
  217. data/lib/rubygems/commands/query_command.rb +0 -43
  218. data/lib/rubygems/compatibility.rb +0 -41
  219. data/lib/rubygems/install_default_message.rb +0 -13
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "openssl"
4
+ require_relative "user_interaction"
4
5
 
5
6
  ##
6
7
  # S3URISigner implements AWS SigV4 for S3 Source to avoid a dependency on the aws-sdk-* gems
7
8
  # More on AWS SigV4: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
8
9
  class Gem::S3URISigner
10
+ include Gem::UserInteraction
11
+
9
12
  class ConfigurationError < Gem::Exception
10
13
  def initialize(message)
11
14
  super message
@@ -147,17 +150,40 @@ class Gem::S3URISigner
147
150
  require_relative "request/connection_pools"
148
151
  require "json"
149
152
 
150
- iam_info = ec2_metadata_request(EC2_IAM_INFO)
153
+ # First try V2 fallback to V1
154
+ res = nil
155
+ begin
156
+ res = ec2_metadata_credentials_imds_v2
157
+ rescue InstanceProfileError
158
+ alert_warning "Unable to access ec2 credentials via IMDSv2, falling back to IMDSv1"
159
+ res = ec2_metadata_credentials_imds_v1
160
+ end
161
+ res
162
+ end
163
+
164
+ def ec2_metadata_credentials_imds_v2
165
+ token = ec2_metadata_token
166
+ iam_info = ec2_metadata_request(EC2_IAM_INFO, token:)
151
167
  # Expected format: arn:aws:iam::<id>:instance-profile/<role_name>
152
168
  role_name = iam_info["InstanceProfileArn"].split("/").last
153
- ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name)
169
+ ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name, token:)
154
170
  end
155
171
 
156
- def ec2_metadata_request(url)
157
- uri = Gem::URI(url)
158
- @request_pool ||= create_request_pool(uri)
159
- request = Gem::Request.new(uri, Gem::Net::HTTP::Get, nil, @request_pool)
160
- response = request.fetch
172
+ def ec2_metadata_credentials_imds_v1
173
+ iam_info = ec2_metadata_request(EC2_IAM_INFO, token: nil)
174
+ # Expected format: arn:aws:iam::<id>:instance-profile/<role_name>
175
+ role_name = iam_info["InstanceProfileArn"].split("/").last
176
+ ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name, token: nil)
177
+ end
178
+
179
+ def ec2_metadata_request(url, token:)
180
+ request = ec2_iam_request(Gem::URI(url), Gem::Net::HTTP::Get)
181
+
182
+ response = request.fetch do |req|
183
+ if token
184
+ req.add_field "X-aws-ec2-metadata-token", token
185
+ end
186
+ end
161
187
 
162
188
  case response
163
189
  when Gem::Net::HTTPOK then
@@ -167,6 +193,26 @@ class Gem::S3URISigner
167
193
  end
168
194
  end
169
195
 
196
+ def ec2_metadata_token
197
+ request = ec2_iam_request(Gem::URI(EC2_IAM_TOKEN), Gem::Net::HTTP::Put)
198
+
199
+ response = request.fetch do |req|
200
+ req.add_field "X-aws-ec2-metadata-token-ttl-seconds", 60
201
+ end
202
+
203
+ case response
204
+ when Gem::Net::HTTPOK then
205
+ response.body
206
+ else
207
+ raise InstanceProfileError.new("Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}")
208
+ end
209
+ end
210
+
211
+ def ec2_iam_request(uri, verb)
212
+ @request_pool ||= create_request_pool(uri)
213
+ Gem::Request.new(uri, verb, nil, @request_pool)
214
+ end
215
+
170
216
  def create_request_pool(uri)
171
217
  proxy_uri = Gem::Request.proxy_uri(Gem::Request.get_proxy_from_env(uri.scheme))
172
218
  certs = Gem::Request.get_cert_files
@@ -174,6 +220,7 @@ class Gem::S3URISigner
174
220
  end
175
221
 
176
222
  BASE64_URI_TRANSLATE = { "+" => "%2B", "/" => "%2F", "=" => "%3D", "\n" => "" }.freeze
223
+ EC2_IAM_TOKEN = "http://169.254.169.254/latest/api/token"
177
224
  EC2_IAM_INFO = "http://169.254.169.254/latest/meta-data/iam/info"
178
225
  EC2_IAM_SECURITY_CREDENTIALS = "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
179
226
  end
@@ -52,7 +52,7 @@ class Gem::Security::Signer
52
52
  re_signed_cert = Gem::Security.re_sign(
53
53
  expired_cert,
54
54
  private_key,
55
- (Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days)
55
+ Gem::Security::ONE_DAY * Gem.configuration.cert_expiration_length_days
56
56
  )
57
57
 
58
58
  Gem::Security.write(re_signed_cert, expired_cert_path)
@@ -190,7 +190,7 @@ class Gem::Source
190
190
  # Downloads +spec+ and writes it to +dir+. See also
191
191
  # Gem::RemoteFetcher#download.
192
192
 
193
- def download(spec, dir=Dir.pwd)
193
+ def download(spec, dir = Dir.pwd)
194
194
  fetcher = Gem::RemoteFetcher.fetcher
195
195
  fetcher.download spec, uri.to_s, dir
196
196
  end
@@ -210,7 +210,7 @@ class Gem::Source
210
210
  end
211
211
  end
212
212
 
213
- def typo_squatting?(host, distance_threshold=4)
213
+ def typo_squatting?(host, distance_threshold = 4)
214
214
  return if @uri.host.nil?
215
215
  levenshtein_distance(@uri.host, host).between? 1, distance_threshold
216
216
  end
@@ -59,6 +59,42 @@ class Gem::SourceList
59
59
  src
60
60
  end
61
61
 
62
+ ##
63
+ # Prepends +obj+ to the beginning of the source list which may be a Gem::Source, Gem::URI or URI
64
+ # Moves +obj+ to the beginning of the list if already present.
65
+ # String.
66
+
67
+ def prepend(obj)
68
+ src = case obj
69
+ when Gem::Source
70
+ obj
71
+ else
72
+ Gem::Source.new(obj)
73
+ end
74
+
75
+ @sources.delete(src) if @sources.include?(src)
76
+ @sources.unshift(src)
77
+ src
78
+ end
79
+
80
+ ##
81
+ # Appends +obj+ to the end of the source list, moving it if already present.
82
+ # +obj+ may be a Gem::Source, Gem::URI or URI String.
83
+ # Moves +obj+ to the end of the list if already present.
84
+
85
+ def append(obj)
86
+ src = case obj
87
+ when Gem::Source
88
+ obj
89
+ else
90
+ Gem::Source.new(obj)
91
+ end
92
+
93
+ @sources.delete(src) if @sources.include?(src)
94
+ @sources << src
95
+ src
96
+ end
97
+
62
98
  ##
63
99
  # Replaces this SourceList with the sources in +other+ See #<< for
64
100
  # acceptable items in +other+.
@@ -83,7 +83,7 @@ class Gem::SpecFetcher
83
83
  #
84
84
  # If +matching_platform+ is false, gems for all platforms are returned.
85
85
 
86
- def search_for_dependency(dependency, matching_platform=true)
86
+ def search_for_dependency(dependency, matching_platform = true)
87
87
  found = {}
88
88
 
89
89
  rejected_specs = {}
@@ -130,7 +130,7 @@ class Gem::SpecFetcher
130
130
  ##
131
131
  # Return all gem name tuples who's names match +obj+
132
132
 
133
- def detect(type=:complete)
133
+ def detect(type = :complete)
134
134
  tuples = []
135
135
 
136
136
  list, _ = available_specs(type)
@@ -150,7 +150,7 @@ class Gem::SpecFetcher
150
150
  #
151
151
  # If +matching_platform+ is false, gems for all platforms are returned.
152
152
 
153
- def spec_for_dependency(dependency, matching_platform=true)
153
+ def spec_for_dependency(dependency, matching_platform = true)
154
154
  tuples, errors = search_for_dependency(dependency, matching_platform)
155
155
 
156
156
  specs = []
@@ -280,7 +280,7 @@ class Gem::SpecFetcher
280
280
  # Retrieves NameTuples from +source+ of the given +type+ (:prerelease,
281
281
  # etc.). If +gracefully_ignore+ is true, errors are ignored.
282
282
 
283
- def tuples_for(source, type, gracefully_ignore=false) # :nodoc:
283
+ def tuples_for(source, type, gracefully_ignore = false) # :nodoc:
284
284
  @caches[type][source.uri] ||=
285
285
  source.load_specs(type).sort_by(&:name)
286
286
  rescue Gem::RemoteFetcher::FetchError
@@ -7,7 +7,6 @@
7
7
  # See LICENSE.txt for permissions.
8
8
  #++
9
9
 
10
- require_relative "deprecate"
11
10
  require_relative "basic_specification"
12
11
  require_relative "stub_specification"
13
12
  require_relative "platform"
@@ -38,8 +37,6 @@ require "rbconfig"
38
37
  # items you may add to a specification.
39
38
 
40
39
  class Gem::Specification < Gem::BasicSpecification
41
- extend Gem::Deprecate
42
-
43
40
  # REFACTOR: Consider breaking out this version stuff into a separate
44
41
  # module. There's enough special stuff around it that it may justify
45
42
  # a separate class.
@@ -488,8 +485,6 @@ class Gem::Specification < Gem::BasicSpecification
488
485
  end
489
486
 
490
487
  @platform = @new_platform.to_s
491
-
492
- invalidate_memoized_attributes
493
488
  end
494
489
 
495
490
  ##
@@ -737,14 +732,6 @@ class Gem::Specification < Gem::BasicSpecification
737
732
 
738
733
  attr_accessor :autorequire # :nodoc:
739
734
 
740
- ##
741
- # Sets the default executable for this gem.
742
- #
743
- # Deprecated: You must now specify the executable name to Gem.bin_path.
744
-
745
- attr_writer :default_executable
746
- rubygems_deprecate :default_executable=
747
-
748
735
  ##
749
736
  # Allows deinstallation of gems with legacy platforms.
750
737
 
@@ -1321,7 +1308,7 @@ class Gem::Specification < Gem::BasicSpecification
1321
1308
  spec.instance_variable_set :@authors, array[12]
1322
1309
  spec.instance_variable_set :@description, array[13]
1323
1310
  spec.instance_variable_set :@homepage, array[14]
1324
- spec.instance_variable_set :@has_rdoc, array[15]
1311
+ # offset due to has_rdoc removal
1325
1312
  spec.instance_variable_set :@licenses, array[17]
1326
1313
  spec.instance_variable_set :@metadata, array[18]
1327
1314
  spec.instance_variable_set :@loaded, false
@@ -1620,14 +1607,14 @@ class Gem::Specification < Gem::BasicSpecification
1620
1607
  # spec's cached gem.
1621
1608
 
1622
1609
  def cache_dir
1623
- @cache_dir ||= File.join base_dir, "cache"
1610
+ File.join base_dir, "cache"
1624
1611
  end
1625
1612
 
1626
1613
  ##
1627
1614
  # Returns the full path to the cached gem for this spec.
1628
1615
 
1629
1616
  def cache_file
1630
- @cache_file ||= File.join cache_dir, "#{full_name}.gem"
1617
+ File.join cache_dir, "#{full_name}.gem"
1631
1618
  end
1632
1619
 
1633
1620
  ##
@@ -1716,24 +1703,6 @@ class Gem::Specification < Gem::BasicSpecification
1716
1703
  end
1717
1704
  end
1718
1705
 
1719
- ##
1720
- # The default executable for this gem.
1721
- #
1722
- # Deprecated: The name of the gem is assumed to be the name of the
1723
- # executable now. See Gem.bin_path.
1724
-
1725
- def default_executable # :nodoc:
1726
- if defined?(@default_executable) && @default_executable
1727
- result = @default_executable
1728
- elsif @executables && @executables.size == 1
1729
- result = Array(@executables).first
1730
- else
1731
- result = nil
1732
- end
1733
- result
1734
- end
1735
- rubygems_deprecate :default_executable
1736
-
1737
1706
  ##
1738
1707
  # The default value for specification attribute +name+
1739
1708
 
@@ -1757,7 +1726,7 @@ class Gem::Specification < Gem::BasicSpecification
1757
1726
  #
1758
1727
  # [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
1759
1728
 
1760
- def dependent_gems(check_dev=true)
1729
+ def dependent_gems(check_dev = true)
1761
1730
  out = []
1762
1731
  Gem::Specification.each do |spec|
1763
1732
  deps = check_dev ? spec.dependencies : spec.runtime_dependencies
@@ -1903,10 +1872,6 @@ class Gem::Specification < Gem::BasicSpecification
1903
1872
  spec
1904
1873
  end
1905
1874
 
1906
- def full_name
1907
- @full_name ||= super
1908
- end
1909
-
1910
1875
  ##
1911
1876
  # Work around old bundler versions removing my methods
1912
1877
  # Can be removed once RubyGems can no longer install Bundler 2.5
@@ -1919,29 +1884,6 @@ class Gem::Specification < Gem::BasicSpecification
1919
1884
  @gems_dir ||= File.join(base_dir, "gems")
1920
1885
  end
1921
1886
 
1922
- ##
1923
- # Deprecated and ignored, defaults to true.
1924
- #
1925
- # Formerly used to indicate this gem was RDoc-capable.
1926
-
1927
- def has_rdoc # :nodoc:
1928
- true
1929
- end
1930
- rubygems_deprecate :has_rdoc
1931
-
1932
- ##
1933
- # Deprecated and ignored.
1934
- #
1935
- # Formerly used to indicate this gem was RDoc-capable.
1936
-
1937
- def has_rdoc=(ignored) # :nodoc:
1938
- @has_rdoc = true
1939
- end
1940
- rubygems_deprecate :has_rdoc=
1941
-
1942
- alias_method :has_rdoc?, :has_rdoc # :nodoc:
1943
- rubygems_deprecate :has_rdoc?
1944
-
1945
1887
  ##
1946
1888
  # True if this gem has files in test_files
1947
1889
 
@@ -2044,17 +1986,6 @@ class Gem::Specification < Gem::BasicSpecification
2044
1986
  end
2045
1987
  end
2046
1988
 
2047
- ##
2048
- # Expire memoized instance variables that can incorrectly generate, replace
2049
- # or miss files due changes in certain attributes used to compute them.
2050
-
2051
- def invalidate_memoized_attributes
2052
- @full_name = nil
2053
- @cache_file = nil
2054
- end
2055
-
2056
- private :invalidate_memoized_attributes
2057
-
2058
1989
  def inspect # :nodoc:
2059
1990
  if $DEBUG
2060
1991
  super
@@ -2093,8 +2024,6 @@ class Gem::Specification < Gem::BasicSpecification
2093
2024
  def internal_init # :nodoc:
2094
2025
  super
2095
2026
  @bin_dir = nil
2096
- @cache_dir = nil
2097
- @cache_file = nil
2098
2027
  @doc_dir = nil
2099
2028
  @ri_dir = nil
2100
2029
  @spec_dir = nil
@@ -2447,8 +2376,6 @@ class Gem::Specification < Gem::BasicSpecification
2447
2376
  :required_rubygems_version,
2448
2377
  :specification_version,
2449
2378
  :version,
2450
- :has_rdoc,
2451
- :default_executable,
2452
2379
  :metadata,
2453
2380
  :signing_key,
2454
2381
  ]
@@ -2586,29 +2513,11 @@ class Gem::Specification < Gem::BasicSpecification
2586
2513
  Gem::SpecificationPolicy.new(self).validate_for_resolution
2587
2514
  end
2588
2515
 
2589
- def validate_metadata
2590
- Gem::SpecificationPolicy.new(self).validate_metadata
2591
- end
2592
- rubygems_deprecate :validate_metadata
2593
-
2594
- def validate_dependencies
2595
- Gem::SpecificationPolicy.new(self).validate_dependencies
2596
- end
2597
- rubygems_deprecate :validate_dependencies
2598
-
2599
- def validate_permissions
2600
- Gem::SpecificationPolicy.new(self).validate_permissions
2601
- end
2602
- rubygems_deprecate :validate_permissions
2603
-
2604
2516
  ##
2605
2517
  # Set the version to +version+.
2606
2518
 
2607
2519
  def version=(version)
2608
- @version = Gem::Version.create(version)
2609
- return if @version.nil?
2610
-
2611
- invalidate_memoized_attributes
2520
+ @version = version.nil? ? version : Gem::Version.create(version)
2612
2521
  end
2613
2522
 
2614
2523
  def stubbed?
@@ -190,9 +190,6 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
190
190
 
191
191
  ##
192
192
  # Checks that the gem does not depend on itself.
193
- # Checks that dependencies use requirements as we recommend. Warnings are
194
- # issued when dependencies are open-ended or overly strict for semantic
195
- # versioning.
196
193
 
197
194
  def validate_dependencies # :nodoc:
198
195
  warning_messages = []
@@ -200,39 +197,6 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
200
197
  if dep.name == @specification.name # warn on self reference
201
198
  warning_messages << "Self referencing dependency is unnecessary and strongly discouraged."
202
199
  end
203
-
204
- prerelease_dep = dep.requirements_list.any? do |req|
205
- Gem::Requirement.new(req).prerelease?
206
- end
207
-
208
- warning_messages << "prerelease dependency on #{dep} is not recommended" if
209
- prerelease_dep && !@specification.version.prerelease?
210
-
211
- open_ended = dep.requirement.requirements.all? do |op, version|
212
- !version.prerelease? && [">", ">="].include?(op)
213
- end
214
-
215
- next unless open_ended
216
- op, dep_version = dep.requirement.requirements.first
217
-
218
- segments = dep_version.segments
219
-
220
- base = segments.first 2
221
-
222
- recommendation = if [">", ">="].include?(op) && segments == [0]
223
- " use a bounded requirement, such as \"~> x.y\""
224
- else
225
- bugfix = if op == ">"
226
- ", \"> #{dep_version}\""
227
- elsif op == ">=" && base != segments
228
- ", \">= #{dep_version}\""
229
- end
230
-
231
- " if #{dep.name} is semantically versioned, use:\n" \
232
- " add_#{dep.type}_dependency \"#{dep.name}\", \"~> #{base.join "."}\"#{bugfix}"
233
- end
234
-
235
- warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
236
200
  end
237
201
  if warning_messages.any?
238
202
  warning_messages.each {|warning_message| warning warning_message }
@@ -73,7 +73,7 @@ module Gem
73
73
  end
74
74
 
75
75
  ##
76
- # Adds +spec+ to the the record, keeping the collection properly sorted.
76
+ # Adds +spec+ to the record, keeping the collection properly sorted.
77
77
 
78
78
  def add_spec(spec)
79
79
  return if all.include? spec
data/lib/rubygems/text.rb CHANGED
@@ -21,7 +21,7 @@ module Gem::Text
21
21
  # Wraps +text+ to +wrap+ characters and optionally indents by +indent+
22
22
  # characters
23
23
 
24
- def format_text(text, wrap, indent=0)
24
+ def format_text(text, wrap, indent = 0)
25
25
  result = []
26
26
  work = clean_text(text)
27
27
 
@@ -42,10 +42,25 @@ class Gem::Uninstaller
42
42
  attr_reader :spec
43
43
 
44
44
  ##
45
- # Constructs an uninstaller that will uninstall +gem+
45
+ # Constructs an uninstaller that will uninstall gem named +gem+.
46
+ # +options+ is a Hash with the following keys:
47
+ #
48
+ # :version:: Version requirement for the gem to uninstall. If not specified,
49
+ # uses Gem::Requirement.default.
50
+ # :install_dir:: The directory where the gem is installed. If not specified,
51
+ # uses Gem.dir.
52
+ # :executables:: Whether executables should be removed without confirmation or not. If nil, asks the user explicitly.
53
+ # :all:: If more than one version matches the requirement, whether to forcefully remove all matching versions or ask the user to select specific matching versions that should be removed.
54
+ # :ignore:: Ignore broken dependency checks when uninstalling.
55
+ # :bin_dir:: Directory containing executables to remove. If not specified,
56
+ # uses Gem.bindir.
57
+ # :format_executable:: In order to find executables to be removed, format executable names using Gem::Installer.exec_format.
58
+ # :abort_on_dependent:: Directly abort uninstallation if dependencies would be broken, rather than asking the user for confirmation.
59
+ # :check_dev:: When checking if uninstalling gem would leave broken dependencies around, also consider development dependencies.
60
+ # :force:: Set both :all and :ignore to true for forced uninstallation.
61
+ # :user_install:: Uninstall from user gem directory instead of system directory.
46
62
 
47
63
  def initialize(gem, options = {})
48
- # TODO: document the valid options
49
64
  @gem = gem
50
65
  @version = options[:version] || Gem::Requirement.default
51
66
  @install_dir = options[:install_dir]
@@ -57,10 +72,6 @@ class Gem::Uninstaller
57
72
  @bin_dir = options[:bin_dir]
58
73
  @format_executable = options[:format_executable]
59
74
  @abort_on_dependent = options[:abort_on_dependent]
60
-
61
- # Indicate if development dependencies should be checked when
62
- # uninstalling. (default: false)
63
- #
64
75
  @check_dev = options[:check_dev]
65
76
 
66
77
  if options[:force]
@@ -6,7 +6,6 @@
6
6
  # See LICENSE.txt for permissions.
7
7
  #++
8
8
 
9
- require_relative "deprecate"
10
9
  require_relative "text"
11
10
 
12
11
  ##
@@ -170,8 +169,6 @@ end
170
169
  # Gem::StreamUI implements a simple stream based user interface.
171
170
 
172
171
  class Gem::StreamUI
173
- extend Gem::Deprecate
174
-
175
172
  ##
176
173
  # The input stream
177
174
 
@@ -193,7 +190,7 @@ class Gem::StreamUI
193
190
  # then special operations (like asking for passwords) will use the TTY
194
191
  # commands to disable character echo.
195
192
 
196
- def initialize(in_stream, out_stream, err_stream=$stderr, usetty=true)
193
+ def initialize(in_stream, out_stream, err_stream = $stderr, usetty = true)
197
194
  @ins = in_stream
198
195
  @outs = out_stream
199
196
  @errs = err_stream
@@ -246,7 +243,7 @@ class Gem::StreamUI
246
243
  # to a tty, raises an exception if default is nil, otherwise returns
247
244
  # default.
248
245
 
249
- def ask_yes_no(question, default=nil)
246
+ def ask_yes_no(question, default = nil)
250
247
  unless tty?
251
248
  if default.nil?
252
249
  raise Gem::OperationNotSupportedError,
@@ -325,14 +322,14 @@ class Gem::StreamUI
325
322
  ##
326
323
  # Display a statement.
327
324
 
328
- def say(statement="")
325
+ def say(statement = "")
329
326
  @outs.puts statement
330
327
  end
331
328
 
332
329
  ##
333
330
  # Display an informational alert. Will ask +question+ if it is not nil.
334
331
 
335
- def alert(statement, question=nil)
332
+ def alert(statement, question = nil)
336
333
  @outs.puts "INFO: #{statement}"
337
334
  ask(question) if question
338
335
  end
@@ -340,7 +337,7 @@ class Gem::StreamUI
340
337
  ##
341
338
  # Display a warning on stderr. Will ask +question+ if it is not nil.
342
339
 
343
- def alert_warning(statement, question=nil)
340
+ def alert_warning(statement, question = nil)
344
341
  @errs.puts "WARNING: #{statement}"
345
342
  ask(question) if question
346
343
  end
@@ -349,7 +346,7 @@ class Gem::StreamUI
349
346
  # Display an error message in a location expected to get error messages.
350
347
  # Will ask +question+ if it is not nil.
351
348
 
352
- def alert_error(statement, question=nil)
349
+ def alert_error(statement, question = nil)
353
350
  @errs.puts "ERROR: #{statement}"
354
351
  ask(question) if question
355
352
  end
data/lib/rubygems/util.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "deprecate"
4
-
5
3
  ##
6
4
  # This module contains various utility methods as module methods.
7
5
 
@@ -56,26 +54,6 @@ module Gem::Util
56
54
  IO.popen command, &:read
57
55
  end
58
56
 
59
- ##
60
- # Invokes system, but silences all output.
61
-
62
- def self.silent_system(*command)
63
- opt = { out: IO::NULL, err: [:child, :out] }
64
- if Hash === command.last
65
- opt.update(command.last)
66
- cmds = command[0...-1]
67
- else
68
- cmds = command.dup
69
- end
70
- system(*(cmds << opt))
71
- end
72
-
73
- class << self
74
- extend Gem::Deprecate
75
-
76
- rubygems_deprecate :silent_system
77
- end
78
-
79
57
  ##
80
58
  # Enumerates the parents of +directory+.
81
59
 
@@ -59,7 +59,7 @@ class Gem::Validator
59
59
  #--
60
60
  # TODO needs further cleanup
61
61
 
62
- def alien(gems=[])
62
+ def alien(gems = [])
63
63
  errors = Hash.new {|h,k| h[k] = {} }
64
64
 
65
65
  Gem::Specification.each do |spec|