rubygems-update 3.4.20 → 3.4.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -0
  3. data/Manifest.txt +6 -0
  4. data/bundler/CHANGELOG.md +55 -3
  5. data/bundler/README.md +1 -2
  6. data/bundler/lib/bundler/build_metadata.rb +3 -3
  7. data/bundler/lib/bundler/cli/check.rb +1 -1
  8. data/bundler/lib/bundler/cli/gem.rb +4 -3
  9. data/bundler/lib/bundler/cli/install.rb +2 -2
  10. data/bundler/lib/bundler/cli/lock.rb +26 -23
  11. data/bundler/lib/bundler/cli/open.rb +5 -7
  12. data/bundler/lib/bundler/definition.rb +43 -26
  13. data/bundler/lib/bundler/endpoint_specification.rb +1 -1
  14. data/bundler/lib/bundler/env.rb +2 -2
  15. data/bundler/lib/bundler/errors.rb +15 -0
  16. data/bundler/lib/bundler/gem_helpers.rb +7 -0
  17. data/bundler/lib/bundler/gem_version_promoter.rb +2 -2
  18. data/bundler/lib/bundler/injector.rb +1 -1
  19. data/bundler/lib/bundler/installer/gem_installer.rb +5 -5
  20. data/bundler/lib/bundler/installer/parallel_installer.rb +0 -26
  21. data/bundler/lib/bundler/installer/standalone.rb +13 -6
  22. data/bundler/lib/bundler/lazy_specification.rb +4 -0
  23. data/bundler/lib/bundler/lockfile_parser.rb +29 -24
  24. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  25. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  26. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  27. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  28. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  29. data/bundler/lib/bundler/man/bundle-config.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-exec.1 +2 -2
  33. data/bundler/lib/bundler/man/bundle-exec.1.ronn +2 -3
  34. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  40. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-plugin.1 +17 -17
  46. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +5 -5
  47. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  48. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  49. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle.1 +1 -1
  54. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  55. data/bundler/lib/bundler/plugin/index.rb +8 -0
  56. data/bundler/lib/bundler/plugin.rb +9 -2
  57. data/bundler/lib/bundler/resolver/package.rb +5 -0
  58. data/bundler/lib/bundler/resolver.rb +27 -7
  59. data/bundler/lib/bundler/ruby_version.rb +8 -1
  60. data/bundler/lib/bundler/rubygems_ext.rb +3 -4
  61. data/bundler/lib/bundler/rubygems_gem_installer.rb +23 -8
  62. data/bundler/lib/bundler/settings.rb +53 -16
  63. data/bundler/lib/bundler/shared_helpers.rb +16 -1
  64. data/bundler/lib/bundler/source/git/git_proxy.rb +21 -4
  65. data/bundler/lib/bundler/source/metadata.rb +1 -1
  66. data/bundler/lib/bundler/spec_set.rb +7 -4
  67. data/bundler/lib/bundler/stub_specification.rb +4 -2
  68. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +6 -2
  69. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  70. data/bundler/lib/bundler/ui/shell.rb +1 -1
  71. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +1 -0
  72. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +21 -9
  73. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  74. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  75. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  76. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  77. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +8 -10
  78. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +15 -4
  79. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +15 -15
  80. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  81. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  82. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +4 -0
  83. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +16 -25
  84. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  85. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  86. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  87. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
  88. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  89. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
  90. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +44 -6
  91. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  92. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  93. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +26 -150
  94. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +4 -46
  95. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  96. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -45
  97. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/lcs_diff.rb +49 -0
  98. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  99. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  100. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  101. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  102. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  103. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  104. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +155 -8
  105. data/bundler/lib/bundler/version.rb +1 -1
  106. data/bundler/lib/bundler/yaml_serializer.rb +12 -8
  107. data/bundler/lib/bundler.rb +0 -8
  108. data/lib/rubygems/basic_specification.rb +1 -1
  109. data/lib/rubygems/command.rb +5 -5
  110. data/lib/rubygems/command_manager.rb +1 -1
  111. data/lib/rubygems/commands/cert_command.rb +3 -3
  112. data/lib/rubygems/commands/check_command.rb +5 -1
  113. data/lib/rubygems/commands/cleanup_command.rb +1 -1
  114. data/lib/rubygems/commands/contents_command.rb +2 -2
  115. data/lib/rubygems/commands/environment_command.rb +2 -2
  116. data/lib/rubygems/commands/help_command.rb +3 -3
  117. data/lib/rubygems/commands/open_command.rb +1 -3
  118. data/lib/rubygems/commands/owner_command.rb +1 -1
  119. data/lib/rubygems/commands/setup_command.rb +10 -10
  120. data/lib/rubygems/commands/specification_command.rb +5 -1
  121. data/lib/rubygems/commands/stale_command.rb +1 -1
  122. data/lib/rubygems/commands/uninstall_command.rb +4 -4
  123. data/lib/rubygems/commands/unpack_command.rb +3 -3
  124. data/lib/rubygems/commands/update_command.rb +4 -4
  125. data/lib/rubygems/commands/yank_command.rb +1 -1
  126. data/lib/rubygems/config_file.rb +63 -16
  127. data/lib/rubygems/core_ext/kernel_gem.rb +1 -1
  128. data/lib/rubygems/core_ext/kernel_require.rb +2 -2
  129. data/lib/rubygems/defaults.rb +6 -2
  130. data/lib/rubygems/dependency_installer.rb +4 -4
  131. data/lib/rubygems/deprecate.rb +2 -1
  132. data/lib/rubygems/doctor.rb +2 -2
  133. data/lib/rubygems/errors.rb +1 -1
  134. data/lib/rubygems/exceptions.rb +1 -1
  135. data/lib/rubygems/ext/builder.rb +5 -4
  136. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  137. data/lib/rubygems/ext/ext_conf_builder.rb +1 -1
  138. data/lib/rubygems/ext/rake_builder.rb +1 -1
  139. data/lib/rubygems/gem_runner.rb +5 -1
  140. data/lib/rubygems/gemcutter_utilities.rb +2 -2
  141. data/lib/rubygems/indexer.rb +1 -1
  142. data/lib/rubygems/install_update_options.rb +1 -1
  143. data/lib/rubygems/installer.rb +15 -20
  144. data/lib/rubygems/local_remote_options.rb +1 -1
  145. data/lib/rubygems/package/digest_io.rb +1 -1
  146. data/lib/rubygems/package/old.rb +1 -1
  147. data/lib/rubygems/package/tar_header.rb +2 -2
  148. data/lib/rubygems/package/tar_reader.rb +9 -2
  149. data/lib/rubygems/package/tar_writer.rb +2 -2
  150. data/lib/rubygems/package.rb +9 -9
  151. data/lib/rubygems/path_support.rb +1 -1
  152. data/lib/rubygems/platform.rb +12 -6
  153. data/lib/rubygems/query_utils.rb +4 -4
  154. data/lib/rubygems/remote_fetcher.rb +12 -4
  155. data/lib/rubygems/request.rb +1 -1
  156. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  157. data/lib/rubygems/request_set.rb +2 -1
  158. data/lib/rubygems/requirement.rb +1 -1
  159. data/lib/rubygems/resolver/api_set.rb +2 -1
  160. data/lib/rubygems/resolver/api_specification.rb +1 -1
  161. data/lib/rubygems/resolver.rb +3 -3
  162. data/lib/rubygems/security/signer.rb +10 -2
  163. data/lib/rubygems/security/trust_dir.rb +5 -5
  164. data/lib/rubygems/security.rb +1 -1
  165. data/lib/rubygems/security_option.rb +1 -1
  166. data/lib/rubygems/source/local.rb +2 -1
  167. data/lib/rubygems/source.rb +5 -1
  168. data/lib/rubygems/source_list.rb +1 -1
  169. data/lib/rubygems/spec_fetcher.rb +2 -2
  170. data/lib/rubygems/specification.rb +30 -23
  171. data/lib/rubygems/specification_policy.rb +11 -11
  172. data/lib/rubygems/uninstaller.rb +3 -3
  173. data/lib/rubygems/update_suggestion.rb +1 -1
  174. data/lib/rubygems/user_interaction.rb +2 -2
  175. data/lib/rubygems/util/licenses.rb +48 -0
  176. data/lib/rubygems/util.rb +5 -1
  177. data/lib/rubygems/validator.rb +1 -1
  178. data/lib/rubygems/version.rb +6 -5
  179. data/lib/rubygems/yaml_serializer.rb +93 -0
  180. data/lib/rubygems.rb +9 -9
  181. data/rubygems-update.gemspec +1 -1
  182. data/setup.rb +2 -0
  183. data/test/rubygems/bundler_test_gem.rb +6 -3
  184. data/test/rubygems/helper.rb +29 -21
  185. data/test/rubygems/package/tar_test_case.rb +2 -2
  186. data/test/rubygems/test_gem.rb +51 -26
  187. data/test/rubygems/test_gem_command.rb +3 -1
  188. data/test/rubygems/test_gem_command_manager.rb +6 -6
  189. data/test/rubygems/test_gem_commands_cert_command.rb +23 -23
  190. data/test/rubygems/test_gem_commands_cleanup_command.rb +2 -2
  191. data/test/rubygems/test_gem_commands_environment_command.rb +2 -1
  192. data/test/rubygems/test_gem_commands_exec_command.rb +5 -1
  193. data/test/rubygems/test_gem_commands_install_command.rb +5 -5
  194. data/test/rubygems/test_gem_commands_open_command.rb +5 -2
  195. data/test/rubygems/test_gem_commands_pristine_command.rb +2 -2
  196. data/test/rubygems/test_gem_commands_push_command.rb +7 -6
  197. data/test/rubygems/test_gem_commands_signin_command.rb +8 -8
  198. data/test/rubygems/test_gem_commands_uninstall_command.rb +21 -1
  199. data/test/rubygems/test_gem_commands_unpack_command.rb +2 -2
  200. data/test/rubygems/test_gem_config_file.rb +46 -12
  201. data/test/rubygems/test_gem_ext_builder.rb +1 -1
  202. data/test/rubygems/test_gem_ext_cargo_builder.rb +2 -2
  203. data/test/rubygems/test_gem_gemcutter_utilities.rb +8 -5
  204. data/test/rubygems/test_gem_install_update_options.rb +3 -3
  205. data/test/rubygems/test_gem_installer.rb +16 -16
  206. data/test/rubygems/test_gem_package.rb +35 -34
  207. data/test/rubygems/test_gem_package_old.rb +1 -1
  208. data/test/rubygems/test_gem_package_tar_header.rb +3 -3
  209. data/test/rubygems/test_gem_package_tar_reader.rb +19 -4
  210. data/test/rubygems/test_gem_package_tar_writer.rb +28 -28
  211. data/test/rubygems/test_gem_rdoc.rb +2 -2
  212. data/test/rubygems/test_gem_remote_fetcher.rb +13 -9
  213. data/test/rubygems/test_gem_request.rb +5 -5
  214. data/test/rubygems/test_gem_request_connection_pools.rb +2 -1
  215. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +14 -7
  216. data/test/rubygems/test_gem_security.rb +2 -2
  217. data/test/rubygems/test_gem_security_policy.rb +2 -2
  218. data/test/rubygems/test_gem_security_signer.rb +2 -2
  219. data/test/rubygems/test_gem_security_trust_dir.rb +6 -6
  220. data/test/rubygems/test_gem_spec_fetcher.rb +2 -2
  221. data/test/rubygems/test_gem_specification.rb +29 -29
  222. data/test/rubygems/test_gem_stream_ui.rb +1 -1
  223. data/test/rubygems/test_gem_update_suggestion.rb +12 -6
  224. data/test/rubygems/test_gem_util.rb +2 -2
  225. data/test/rubygems/test_gem_version.rb +4 -2
  226. data/test/rubygems/utilities.rb +4 -3
  227. metadata +9 -3
@@ -65,8 +65,15 @@ class Bundler::Thor
65
65
 
66
66
  # Defines the long description of the next command.
67
67
  #
68
+ # Long description is by default indented, line-wrapped and repeated whitespace merged.
69
+ # In order to print long description verbatim, with indentation and spacing exactly
70
+ # as found in the code, use the +wrap+ option
71
+ #
72
+ # long_desc 'your very long description', wrap: false
73
+ #
68
74
  # ==== Parameters
69
75
  # long description<String>
76
+ # options<Hash>
70
77
  #
71
78
  def long_desc(long_description, options = {})
72
79
  if options[:for]
@@ -74,6 +81,7 @@ class Bundler::Thor
74
81
  command.long_description = long_description if long_description
75
82
  else
76
83
  @long_desc = long_description
84
+ @long_desc_wrap = options[:wrap] != false
77
85
  end
78
86
  end
79
87
 
@@ -133,7 +141,7 @@ class Bundler::Thor
133
141
  # # magic
134
142
  # end
135
143
  #
136
- # method_option :foo => :bar, :for => :previous_command
144
+ # method_option :foo, :for => :previous_command
137
145
  #
138
146
  # def next_command
139
147
  # # magic
@@ -153,6 +161,9 @@ class Bundler::Thor
153
161
  # :hide - If you want to hide this option from the help.
154
162
  #
155
163
  def method_option(name, options = {})
164
+ unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }
165
+ raise ArgumentError, "Expected a Symbol or String, got #{name.inspect}"
166
+ end
156
167
  scope = if options[:for]
157
168
  find_and_refresh_command(options[:for]).options
158
169
  else
@@ -163,6 +174,81 @@ class Bundler::Thor
163
174
  end
164
175
  alias_method :option, :method_option
165
176
 
177
+ # Adds and declares option group for exclusive options in the
178
+ # block and arguments. You can declare options as the outside of the block.
179
+ #
180
+ # If :for is given as option, it allows you to change the options from
181
+ # a previous defined command.
182
+ #
183
+ # ==== Parameters
184
+ # Array[Bundler::Thor::Option.name]
185
+ # options<Hash>:: :for is applied for previous defined command.
186
+ #
187
+ # ==== Examples
188
+ #
189
+ # exclusive do
190
+ # option :one
191
+ # option :two
192
+ # end
193
+ #
194
+ # Or
195
+ #
196
+ # option :one
197
+ # option :two
198
+ # exclusive :one, :two
199
+ #
200
+ # If you give "--one" and "--two" at the same time ExclusiveArgumentsError
201
+ # will be raised.
202
+ #
203
+ def method_exclusive(*args, &block)
204
+ register_options_relation_for(:method_options,
205
+ :method_exclusive_option_names, *args, &block)
206
+ end
207
+ alias_method :exclusive, :method_exclusive
208
+
209
+ # Adds and declares option group for required at least one of options in the
210
+ # block of arguments. You can declare options as the outside of the block.
211
+ #
212
+ # If :for is given as option, it allows you to change the options from
213
+ # a previous defined command.
214
+ #
215
+ # ==== Parameters
216
+ # Array[Bundler::Thor::Option.name]
217
+ # options<Hash>:: :for is applied for previous defined command.
218
+ #
219
+ # ==== Examples
220
+ #
221
+ # at_least_one do
222
+ # option :one
223
+ # option :two
224
+ # end
225
+ #
226
+ # Or
227
+ #
228
+ # option :one
229
+ # option :two
230
+ # at_least_one :one, :two
231
+ #
232
+ # If you do not give "--one" and "--two" AtLeastOneRequiredArgumentError
233
+ # will be raised.
234
+ #
235
+ # You can use at_least_one and exclusive at the same time.
236
+ #
237
+ # exclusive do
238
+ # at_least_one do
239
+ # option :one
240
+ # option :two
241
+ # end
242
+ # end
243
+ #
244
+ # Then it is required either only one of "--one" or "--two".
245
+ #
246
+ def method_at_least_one(*args, &block)
247
+ register_options_relation_for(:method_options,
248
+ :method_at_least_one_option_names, *args, &block)
249
+ end
250
+ alias_method :at_least_one, :method_at_least_one
251
+
166
252
  # Prints help information for the given command.
167
253
  #
168
254
  # ==== Parameters
@@ -178,9 +264,16 @@ class Bundler::Thor
178
264
  shell.say " #{banner(command).split("\n").join("\n ")}"
179
265
  shell.say
180
266
  class_options_help(shell, nil => command.options.values)
267
+ print_exclusive_options(shell, command)
268
+ print_at_least_one_required_options(shell, command)
269
+
181
270
  if command.long_description
182
271
  shell.say "Description:"
183
- shell.print_wrapped(command.long_description, :indent => 2)
272
+ if command.wrap_long_description
273
+ shell.print_wrapped(command.long_description, indent: 2)
274
+ else
275
+ shell.say command.long_description
276
+ end
184
277
  else
185
278
  shell.say command.description
186
279
  end
@@ -197,7 +290,7 @@ class Bundler::Thor
197
290
  Bundler::Thor::Util.thor_classes_in(self).each do |klass|
198
291
  list += klass.printable_commands(false)
199
292
  end
200
- list.sort! { |a, b| a[0] <=> b[0] }
293
+ sort_commands!(list)
201
294
 
202
295
  if defined?(@package_name) && @package_name
203
296
  shell.say "#{@package_name} commands:"
@@ -205,9 +298,11 @@ class Bundler::Thor
205
298
  shell.say "Commands:"
206
299
  end
207
300
 
208
- shell.print_table(list, :indent => 2, :truncate => true)
301
+ shell.print_table(list, indent: 2, truncate: true)
209
302
  shell.say
210
303
  class_options_help(shell)
304
+ print_exclusive_options(shell)
305
+ print_at_least_one_required_options(shell)
211
306
  end
212
307
 
213
308
  # Returns commands ready to be printed.
@@ -238,7 +333,7 @@ class Bundler::Thor
238
333
 
239
334
  define_method(subcommand) do |*args|
240
335
  args, opts = Bundler::Thor::Arguments.split(args)
241
- invoke_args = [args, opts, {:invoked_via_subcommand => true, :class_options => options}]
336
+ invoke_args = [args, opts, {invoked_via_subcommand: true, class_options: options}]
242
337
  invoke_args.unshift "help" if opts.delete("--help") || opts.delete("-h")
243
338
  invoke subcommand_class, *invoke_args
244
339
  end
@@ -346,6 +441,24 @@ class Bundler::Thor
346
441
 
347
442
  protected
348
443
 
444
+ # Returns this class exclusive options array set.
445
+ #
446
+ # ==== Returns
447
+ # Array[Array[Bundler::Thor::Option.name]]
448
+ #
449
+ def method_exclusive_option_names #:nodoc:
450
+ @method_exclusive_option_names ||= []
451
+ end
452
+
453
+ # Returns this class at least one of required options array set.
454
+ #
455
+ # ==== Returns
456
+ # Array[Array[Bundler::Thor::Option.name]]
457
+ #
458
+ def method_at_least_one_option_names #:nodoc:
459
+ @method_at_least_one_option_names ||= []
460
+ end
461
+
349
462
  def stop_on_unknown_option #:nodoc:
350
463
  @stop_on_unknown_option ||= []
351
464
  end
@@ -355,8 +468,30 @@ class Bundler::Thor
355
468
  @disable_required_check ||= [:help]
356
469
  end
357
470
 
471
+ def print_exclusive_options(shell, command = nil) # :nodoc:
472
+ opts = []
473
+ opts = command.method_exclusive_option_names unless command.nil?
474
+ opts += class_exclusive_option_names
475
+ unless opts.empty?
476
+ shell.say "Exclusive Options:"
477
+ shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
478
+ shell.say
479
+ end
480
+ end
481
+
482
+ def print_at_least_one_required_options(shell, command = nil) # :nodoc:
483
+ opts = []
484
+ opts = command.method_at_least_one_option_names unless command.nil?
485
+ opts += class_at_least_one_option_names
486
+ unless opts.empty?
487
+ shell.say "Required At Least One:"
488
+ shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
489
+ shell.say
490
+ end
491
+ end
492
+
358
493
  # The method responsible for dispatching given the args.
359
- def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
494
+ def dispatch(meth, given_args, given_opts, config) #:nodoc:
360
495
  meth ||= retrieve_command_name(given_args)
361
496
  command = all_commands[normalize_command_name(meth)]
362
497
 
@@ -415,12 +550,16 @@ class Bundler::Thor
415
550
  @usage ||= nil
416
551
  @desc ||= nil
417
552
  @long_desc ||= nil
553
+ @long_desc_wrap ||= nil
418
554
  @hide ||= nil
419
555
 
420
556
  if @usage && @desc
421
557
  base_class = @hide ? Bundler::Thor::HiddenCommand : Bundler::Thor::Command
422
- commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options)
423
- @usage, @desc, @long_desc, @method_options, @hide = nil
558
+ relations = {exclusive_option_names: method_exclusive_option_names,
559
+ at_least_one_option_names: method_at_least_one_option_names}
560
+ commands[meth] = base_class.new(meth, @desc, @long_desc, @long_desc_wrap, @usage, method_options, relations)
561
+ @usage, @desc, @long_desc, @long_desc_wrap, @method_options, @hide = nil
562
+ @method_exclusive_option_names, @method_at_least_one_option_names = nil
424
563
  true
425
564
  elsif all_commands[meth] || meth == "method_missing"
426
565
  true
@@ -495,6 +634,14 @@ class Bundler::Thor
495
634
  "
496
635
  end
497
636
  alias_method :subtask_help, :subcommand_help
637
+
638
+ # Sort the commands, lexicographically by default.
639
+ #
640
+ # Can be overridden in the subclass to change the display order of the
641
+ # commands.
642
+ def sort_commands!(list)
643
+ list.sort! { |a, b| a[0] <=> b[0] }
644
+ end
498
645
  end
499
646
 
500
647
  include Bundler::Thor::Base
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.4.20".freeze
4
+ VERSION = "2.4.22".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
@@ -17,7 +17,11 @@ module Bundler
17
17
  if v.is_a?(Hash)
18
18
  yaml << dump_hash(v).gsub(/^(?!$)/, " ") # indent all non-empty lines
19
19
  elsif v.is_a?(Array) # Expected to be array of strings
20
- yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
20
+ if v.empty?
21
+ yaml << " []\n"
22
+ else
23
+ yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
24
+ end
21
25
  else
22
26
  yaml << " " << v.to_s.gsub(/\s+/, " ").inspect << "\n"
23
27
  end
@@ -54,8 +58,8 @@ module Bundler
54
58
  str.split(/\r?\n/).each do |line|
55
59
  if match = HASH_REGEX.match(line)
56
60
  indent, key, quote, val = match.captures
57
- key = convert_to_backward_compatible_key(key)
58
- depth = indent.scan(/ /).length
61
+ convert_to_backward_compatible_key!(key)
62
+ depth = indent.size / 2
59
63
  if quote.empty? && val.empty?
60
64
  new_hash = {}
61
65
  stack[depth][key] = new_hash
@@ -63,6 +67,7 @@ module Bundler
63
67
  last_empty_key = key
64
68
  last_hash = stack[depth]
65
69
  else
70
+ val = [] if val == "[]" # empty array
66
71
  stack[depth][key] = val
67
72
  end
68
73
  elsif match = ARRAY_REGEX.match(line)
@@ -76,14 +81,13 @@ module Bundler
76
81
  end
77
82
 
78
83
  # for settings' keys
79
- def convert_to_backward_compatible_key(key)
80
- key = "#{key}/" if key =~ /https?:/i && key !~ %r{/\Z}
81
- key = key.gsub(".", "__") if key.include?(".")
82
- key
84
+ def convert_to_backward_compatible_key!(key)
85
+ key << "/" if /https?:/i.match?(key) && !%r{/\Z}.match?(key)
86
+ key.gsub!(".", "__")
83
87
  end
84
88
 
85
89
  class << self
86
- private :dump_hash, :convert_to_backward_compatible_key
90
+ private :dump_hash, :convert_to_backward_compatible_key!
87
91
  end
88
92
  end
89
93
  end
@@ -330,14 +330,6 @@ module Bundler
330
330
 
331
331
  def rm_rf(path)
332
332
  FileUtils.remove_entry_secure(path) if path && File.exist?(path)
333
- rescue ArgumentError
334
- message = <<EOF
335
- It is a security vulnerability to allow your home directory to be world-writable, and bundler cannot continue.
336
- You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
337
- Please refer to https://ruby-doc.org/stdlib-3.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
338
- EOF
339
- File.world_writable?(path) ? Bundler.ui.warn(message) : raise
340
- raise PathError, "Please fix the world-writable issue with your #{path} directory"
341
333
  end
342
334
 
343
335
  def settings
@@ -291,7 +291,7 @@ class Gem::BasicSpecification
291
291
  def lib_dirs_glob
292
292
  dirs = if self.raw_require_paths
293
293
  if self.raw_require_paths.size > 1
294
- "{#{self.raw_require_paths.join(',')}}"
294
+ "{#{self.raw_require_paths.join(",")}}"
295
295
  else
296
296
  self.raw_require_paths.first
297
297
  end
@@ -228,7 +228,7 @@ class Gem::Command
228
228
 
229
229
  if args.size > 1
230
230
  raise Gem::CommandLineError,
231
- "Too many gem names (#{args.join(', ')}); please specify only one"
231
+ "Too many gem names (#{args.join(", ")}); please specify only one"
232
232
  end
233
233
 
234
234
  args.first
@@ -430,9 +430,9 @@ class Gem::Command
430
430
 
431
431
  def handles?(args)
432
432
  parser.parse!(args.dup)
433
- return true
434
- rescue
435
- return false
433
+ true
434
+ rescue StandardError
435
+ false
436
436
  end
437
437
 
438
438
  ##
@@ -459,7 +459,7 @@ class Gem::Command
459
459
  until extra.empty? do
460
460
  ex = []
461
461
  ex << extra.shift
462
- ex << extra.shift if extra.first.to_s =~ /^[^-]/ # rubocop:disable Performance/StartWith
462
+ ex << extra.shift if /^[^-]/.match?(extra.first.to_s) # rubocop:disable Performance/StartWith
463
463
  result << ex if handles?(ex)
464
464
  end
465
465
 
@@ -201,7 +201,7 @@ class Gem::CommandManager
201
201
 
202
202
  if possibilities.size > 1
203
203
  raise Gem::CommandLineError,
204
- "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
204
+ "Ambiguous command #{cmd_name} matches [#{possibilities.join(", ")}]"
205
205
  elsif possibilities.empty?
206
206
  raise Gem::UnknownCommandError.new(cmd_name)
207
207
  end
@@ -178,9 +178,9 @@ class Gem::Commands::CertCommand < Gem::Command
178
178
 
179
179
  algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM
180
180
  key = Gem::Security.create_key(algorithm)
181
- key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase
181
+ key_path = Gem::Security.write key, "gem-private_key.pem", 0o600, passphrase
182
182
 
183
- return key, key_path
183
+ [key, key_path]
184
184
  end
185
185
 
186
186
  def certificates_matching(filter)
@@ -292,7 +292,7 @@ For further reading on signing gems see `ri Gem::Security`.
292
292
  cert = File.read cert_file
293
293
  cert = OpenSSL::X509::Certificate.new cert
294
294
 
295
- permissions = File.stat(cert_file).mode & 0777
295
+ permissions = File.stat(cert_file).mode & 0o777
296
296
 
297
297
  issuer_cert = options[:issuer_cert]
298
298
  issuer_key = options[:key]
@@ -41,7 +41,11 @@ class Gem::Commands::CheckCommand < Gem::Command
41
41
  def check_gems
42
42
  say "Checking gems..."
43
43
  say
44
- gems = get_all_gem_names rescue []
44
+ gems = begin
45
+ get_all_gem_names
46
+ rescue StandardError
47
+ []
48
+ end
45
49
 
46
50
  Gem::Validator.new.alien(gems).sort.each do |key, val|
47
51
  unless val.empty?
@@ -90,7 +90,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
90
90
  verbose do
91
91
  skipped = @default_gems.map {|spec| spec.full_name }
92
92
 
93
- "Skipped default gems: #{skipped.join ', '}"
93
+ "Skipped default gems: #{skipped.join ", "}"
94
94
  end
95
95
  end
96
96
 
@@ -92,7 +92,7 @@ prefix or only the files that are requireable.
92
92
 
93
93
  def files_in_gem(spec)
94
94
  gem_path = spec.full_gem_path
95
- extra = "/{#{spec.require_paths.join ','}}" if options[:lib_only]
95
+ extra = "/{#{spec.require_paths.join ","}}" if options[:lib_only]
96
96
  glob = "#{gem_path}#{extra}/**/*"
97
97
  prefix_re = /#{Regexp.escape(gem_path)}\//
98
98
 
@@ -178,7 +178,7 @@ prefix or only the files that are requireable.
178
178
  @spec_dirs.sort.each {|dir| say dir }
179
179
  end
180
180
 
181
- return nil
181
+ nil
182
182
  end
183
183
 
184
184
  def specification_directories # :nodoc:
@@ -17,7 +17,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
17
17
  platform display the supported gem platforms
18
18
  <omitted> display everything
19
19
  EOF
20
- return args.gsub(/^\s+/, "")
20
+ args.gsub(/^\s+/, "")
21
21
  end
22
22
 
23
23
  def description # :nodoc:
@@ -173,6 +173,6 @@ lib/rubygems/defaults/operating_system.rb
173
173
  end
174
174
  end
175
175
 
176
- return nil
176
+ nil
177
177
  end
178
178
  end
@@ -269,7 +269,7 @@ Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's
269
269
  platform.
270
270
  EOF
271
271
 
272
- # NOTE when updating also update Gem::Command::HELP
272
+ # NOTE: when updating also update Gem::Command::HELP
273
273
 
274
274
  SUBCOMMANDS = [
275
275
  ["commands", :show_commands],
@@ -328,7 +328,7 @@ platform.
328
328
 
329
329
  summary_width = 80 - margin_width - desc_width
330
330
  wrap_indent = " " * (margin_width + desc_width)
331
- format = "#{' ' * margin_width}%-#{desc_width}s%s"
331
+ format = "#{" " * margin_width}%-#{desc_width}s%s"
332
332
 
333
333
  @command_manager.command_names.each do |cmd_name|
334
334
  command = @command_manager[cmd_name]
@@ -367,7 +367,7 @@ platform.
367
367
  command = @command_manager[possibilities.first]
368
368
  command.invoke("--help")
369
369
  elsif possibilities.size > 1
370
- alert_warning "Ambiguous command #{command_name} (#{possibilities.join(', ')})"
370
+ alert_warning "Ambiguous command #{command_name} (#{possibilities.join(", ")})"
371
371
  else
372
372
  alert_warning "Unknown command #{command_name}. Try: gem help commands"
373
373
  end
@@ -70,9 +70,7 @@ class Gem::Commands::OpenCommand < Gem::Command
70
70
  end
71
71
 
72
72
  def open_editor(path)
73
- Dir.chdir(path) do
74
- system(*@editor.split(/\s+/) + [path])
75
- end
73
+ system(*@editor.split(/\s+/) + [path], { :chdir => path })
76
74
  end
77
75
 
78
76
  def spec_for(name)
@@ -79,7 +79,7 @@ permission to.
79
79
 
80
80
  say "Owners for gem: #{name}"
81
81
  owners.each do |owner|
82
- say "- #{owner['email'] || owner['handle'] || owner['id']}"
82
+ say "- #{owner["email"] || owner["handle"] || owner["id"]}"
83
83
  end
84
84
  end
85
85
  end
@@ -134,7 +134,7 @@ prefix and suffix. If ruby was installed as `ruby18`, gem will be
134
134
  installed as `gem18`.
135
135
 
136
136
  By default, this RubyGems will install gem as:
137
- #{Gem.default_exec_format % 'gem'}
137
+ #{Gem.default_exec_format % "gem"}
138
138
  EOF
139
139
  end
140
140
 
@@ -243,7 +243,7 @@ By default, this RubyGems will install gem as:
243
243
  end
244
244
 
245
245
  def install_executables(bin_dir)
246
- prog_mode = options[:prog_mode] || 0755
246
+ prog_mode = options[:prog_mode] || 0o755
247
247
 
248
248
  executables = { "gem" => "exe" }
249
249
  executables.each do |tool, path|
@@ -357,7 +357,7 @@ By default, this RubyGems will install gem as:
357
357
  say "Set the GEM_HOME environment variable if you want RDoc generated"
358
358
  end
359
359
 
360
- return false
360
+ false
361
361
  end
362
362
 
363
363
  def install_default_bundler_gem(bin_dir)
@@ -369,7 +369,7 @@ By default, this RubyGems will install gem as:
369
369
  File.dirname(loaded_from)
370
370
  else
371
371
  target_specs_dir = File.join(default_dir, "specifications", "default")
372
- mkdir_p target_specs_dir, :mode => 0755
372
+ mkdir_p target_specs_dir, :mode => 0o755
373
373
  target_specs_dir
374
374
  end
375
375
 
@@ -393,7 +393,7 @@ By default, this RubyGems will install gem as:
393
393
  end
394
394
 
395
395
  bundler_bin_dir = bundler_spec.bin_dir
396
- mkdir_p bundler_bin_dir, :mode => 0755
396
+ mkdir_p bundler_bin_dir, :mode => 0o755
397
397
  bundler_spec.executables.each do |e|
398
398
  cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
399
399
  end
@@ -430,10 +430,10 @@ By default, this RubyGems will install gem as:
430
430
  lib_dir, bin_dir = generate_default_dirs
431
431
  end
432
432
 
433
- mkdir_p lib_dir, :mode => 0755
434
- mkdir_p bin_dir, :mode => 0755
433
+ mkdir_p lib_dir, :mode => 0o755
434
+ mkdir_p bin_dir, :mode => 0o755
435
435
 
436
- return lib_dir, bin_dir
436
+ [lib_dir, bin_dir]
437
437
  end
438
438
 
439
439
  def generate_default_man_dir
@@ -639,10 +639,10 @@ abort "#{deprecation_message}"
639
639
  dest_file = File.join dest_dir, file
640
640
  dest_dir = File.dirname dest_file
641
641
  unless File.directory? dest_dir
642
- mkdir_p dest_dir, :mode => 0755
642
+ mkdir_p dest_dir, :mode => 0o755
643
643
  end
644
644
 
645
- install file, dest_file, :mode => options[:data_mode] || 0644
645
+ install file, dest_file, :mode => options[:data_mode] || 0o644
646
646
  end
647
647
 
648
648
  def remove_file_list(files, dir)
@@ -107,7 +107,11 @@ Specific fields in the specification can be extracted in YAML format:
107
107
 
108
108
  if local?
109
109
  if File.exist? gem
110
- specs << Gem::Package.new(gem).spec rescue nil
110
+ begin
111
+ specs << Gem::Package.new(gem).spec
112
+ rescue StandardError
113
+ nil
114
+ end
111
115
  end
112
116
 
113
117
  if specs.empty?
@@ -34,7 +34,7 @@ longer using.
34
34
  end
35
35
 
36
36
  gem_to_atime.sort_by {|_, atime| atime }.each do |name, atime|
37
- say "#{name} at #{atime.strftime '%c'}"
37
+ say "#{name} at #{atime.strftime "%c"}"
38
38
  end
39
39
  end
40
40
  end
@@ -169,10 +169,10 @@ that is a dependency of an existing gem. You can use the
169
169
  gems_to_uninstall = {}
170
170
 
171
171
  deps.each do |dep|
172
- next if gems_to_uninstall[dep.name]
173
- gems_to_uninstall[dep.name] = true
174
-
175
- unless original_gem_version[dep.name] == Gem::Requirement.default
172
+ if original_gem_version[dep.name] == Gem::Requirement.default
173
+ next if gems_to_uninstall[dep.name]
174
+ gems_to_uninstall[dep.name] = true
175
+ else
176
176
  options[:version] = dep.version
177
177
  end
178
178
 
@@ -130,7 +130,7 @@ command help for an example.
130
130
  return this_path if File.exist? this_path
131
131
  end
132
132
 
133
- return nil
133
+ nil
134
134
  end
135
135
 
136
136
  ##
@@ -151,7 +151,7 @@ command help for an example.
151
151
  # source directories?
152
152
 
153
153
  def get_path(dependency)
154
- return dependency.name if dependency.name =~ /\.gem$/i
154
+ return dependency.name if /\.gem$/i.match?(dependency.name)
155
155
 
156
156
  specs = dependency.matching_specs
157
157
 
@@ -160,7 +160,7 @@ command help for an example.
160
160
  return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless
161
161
  selected
162
162
 
163
- return unless dependency.name =~ /^#{selected.name}$/i
163
+ return unless /^#{selected.name}$/i.match?(dependency.name)
164
164
 
165
165
  # We expect to find (basename).gem in the 'cache' directory. Furthermore,
166
166
  # the name match must be exact (ignoring case).