rubygems-update 3.5.23 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -0
  3. data/Manifest.txt +23 -16
  4. data/README.md +14 -9
  5. data/bundler/CHANGELOG.md +59 -0
  6. data/bundler/bundler.gemspec +2 -2
  7. data/bundler/lib/bundler/build_metadata.rb +2 -2
  8. data/bundler/lib/bundler/cli/console.rb +0 -4
  9. data/bundler/lib/bundler/cli/doctor.rb +4 -4
  10. data/bundler/lib/bundler/cli/exec.rb +1 -0
  11. data/bundler/lib/bundler/cli/gem.rb +1 -1
  12. data/bundler/lib/bundler/cli/info.rb +2 -2
  13. data/bundler/lib/bundler/cli/inject.rb +1 -1
  14. data/bundler/lib/bundler/cli/install.rb +4 -0
  15. data/bundler/lib/bundler/cli/lock.rb +20 -1
  16. data/bundler/lib/bundler/cli/pristine.rb +1 -1
  17. data/bundler/lib/bundler/cli/show.rb +2 -2
  18. data/bundler/lib/bundler/cli.rb +22 -53
  19. data/bundler/lib/bundler/compact_index_client/cache_file.rb +0 -5
  20. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -11
  21. data/bundler/lib/bundler/definition.rb +134 -61
  22. data/bundler/lib/bundler/dependency.rb +1 -1
  23. data/bundler/lib/bundler/dsl.rb +2 -13
  24. data/bundler/lib/bundler/endpoint_specification.rb +10 -1
  25. data/bundler/lib/bundler/errors.rb +10 -0
  26. data/bundler/lib/bundler/feature_flag.rb +1 -0
  27. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  28. data/bundler/lib/bundler/fetcher.rb +10 -3
  29. data/bundler/lib/bundler/gem_helpers.rb +21 -5
  30. data/bundler/lib/bundler/injector.rb +2 -2
  31. data/bundler/lib/bundler/installer/standalone.rb +2 -2
  32. data/bundler/lib/bundler/installer.rb +4 -38
  33. data/bundler/lib/bundler/lazy_specification.rb +65 -24
  34. data/bundler/lib/bundler/lockfile_parser.rb +9 -1
  35. data/bundler/lib/bundler/man/bundle-add.1 +13 -10
  36. data/bundler/lib/bundler/man/bundle-add.1.ronn +12 -9
  37. data/bundler/lib/bundler/man/bundle-binstubs.1 +7 -4
  38. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  39. data/bundler/lib/bundler/man/bundle-cache.1 +30 -2
  40. data/bundler/lib/bundler/man/bundle-cache.1.ronn +31 -2
  41. data/bundler/lib/bundler/man/bundle-check.1 +3 -3
  42. data/bundler/lib/bundler/man/bundle-check.1.ronn +4 -2
  43. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-config.1 +3 -1
  45. data/bundler/lib/bundler/man/bundle-config.1.ronn +2 -0
  46. data/bundler/lib/bundler/man/bundle-console.1 +2 -4
  47. data/bundler/lib/bundler/man/bundle-console.1.ronn +2 -7
  48. data/bundler/lib/bundler/man/bundle-doctor.1 +2 -2
  49. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  50. data/bundler/lib/bundler/man/bundle-env.1 +9 -0
  51. data/bundler/lib/bundler/man/bundle-env.1.ronn +10 -0
  52. data/bundler/lib/bundler/man/bundle-exec.1 +5 -2
  53. data/bundler/lib/bundler/man/bundle-exec.1.ronn +4 -1
  54. data/bundler/lib/bundler/man/bundle-fund.1 +22 -0
  55. data/bundler/lib/bundler/man/bundle-fund.1.ronn +25 -0
  56. data/bundler/lib/bundler/man/bundle-gem.1 +17 -5
  57. data/bundler/lib/bundler/man/bundle-gem.1.ronn +27 -6
  58. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  59. data/bundler/lib/bundler/man/bundle-info.1 +5 -2
  60. data/bundler/lib/bundler/man/bundle-info.1.ronn +6 -2
  61. data/bundler/lib/bundler/man/bundle-init.1 +3 -3
  62. data/bundler/lib/bundler/man/bundle-init.1.ronn +3 -2
  63. data/bundler/lib/bundler/man/bundle-inject.1 +10 -2
  64. data/bundler/lib/bundler/man/bundle-inject.1.ronn +9 -1
  65. data/bundler/lib/bundler/man/bundle-install.1 +14 -11
  66. data/bundler/lib/bundler/man/bundle-install.1.ronn +21 -16
  67. data/bundler/lib/bundler/man/bundle-issue.1 +45 -0
  68. data/bundler/lib/bundler/man/bundle-issue.1.ronn +37 -0
  69. data/bundler/lib/bundler/man/bundle-licenses.1 +9 -0
  70. data/bundler/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  71. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  72. data/bundler/lib/bundler/man/bundle-list.1.ronn +4 -1
  73. data/bundler/lib/bundler/man/bundle-lock.1 +21 -6
  74. data/bundler/lib/bundler/man/bundle-lock.1.ronn +25 -4
  75. data/bundler/lib/bundler/man/bundle-open.1 +2 -2
  76. data/bundler/lib/bundler/man/bundle-open.1.ronn +2 -1
  77. data/bundler/lib/bundler/man/bundle-outdated.1 +8 -5
  78. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  79. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  80. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  81. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  82. data/bundler/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  83. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  84. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -1
  85. data/bundler/lib/bundler/man/bundle-show.1 +5 -2
  86. data/bundler/lib/bundler/man/bundle-show.1.ronn +4 -0
  87. data/bundler/lib/bundler/man/bundle-update.1 +13 -7
  88. data/bundler/lib/bundler/man/bundle-update.1.ronn +14 -6
  89. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  90. data/bundler/lib/bundler/man/bundle-viz.1 +4 -4
  91. data/bundler/lib/bundler/man/bundle-viz.1.ronn +7 -3
  92. data/bundler/lib/bundler/man/bundle.1 +1 -1
  93. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  94. data/bundler/lib/bundler/man/index.txt +4 -0
  95. data/bundler/lib/bundler/materialization.rb +59 -0
  96. data/bundler/lib/bundler/plugin/events.rb +24 -0
  97. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  98. data/bundler/lib/bundler/process_lock.rb +1 -1
  99. data/bundler/lib/bundler/remote_specification.rb +6 -1
  100. data/bundler/lib/bundler/resolver/base.rb +2 -6
  101. data/bundler/lib/bundler/resolver/candidate.rb +2 -2
  102. data/bundler/lib/bundler/resolver/spec_group.rb +4 -3
  103. data/bundler/lib/bundler/resolver.rb +5 -5
  104. data/bundler/lib/bundler/rubygems_ext.rb +17 -28
  105. data/bundler/lib/bundler/rubygems_gem_installer.rb +0 -1
  106. data/bundler/lib/bundler/rubygems_integration.rb +21 -11
  107. data/bundler/lib/bundler/runtime.rb +27 -7
  108. data/bundler/lib/bundler/self_manager.rb +2 -3
  109. data/bundler/lib/bundler/settings.rb +1 -0
  110. data/bundler/lib/bundler/shared_helpers.rb +2 -2
  111. data/bundler/lib/bundler/source/git/git_proxy.rb +0 -6
  112. data/bundler/lib/bundler/source/git.rb +56 -31
  113. data/bundler/lib/bundler/source/path.rb +2 -2
  114. data/bundler/lib/bundler/source_list.rb +1 -1
  115. data/bundler/lib/bundler/spec_set.rb +81 -56
  116. data/bundler/lib/bundler/stub_specification.rb +8 -0
  117. data/bundler/lib/bundler/templates/newgem/README.md.tt +1 -1
  118. data/bundler/lib/bundler/uri_credentials_filter.rb +1 -1
  119. data/bundler/lib/bundler/vendor/fileutils/COPYING +56 -0
  120. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  121. data/bundler/lib/bundler/vendor/securerandom/COPYING +56 -0
  122. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +5 -5
  123. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  124. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  125. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  126. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  127. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  128. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  129. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  130. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  131. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  132. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  133. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  134. data/bundler/lib/bundler/vendor/uri/COPYING +56 -0
  135. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +37 -16
  136. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  137. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  138. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +16 -26
  139. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  140. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  141. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  142. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  143. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  144. data/bundler/lib/bundler/vendored_securerandom.rb +0 -2
  145. data/bundler/lib/bundler/version.rb +1 -1
  146. data/bundler/lib/bundler.rb +37 -13
  147. data/{CONTRIBUTING.md → doc/rubygems/CONTRIBUTING.md} +9 -9
  148. data/{POLICIES.md → doc/rubygems/POLICIES.md} +11 -11
  149. data/lib/rubygems/basic_specification.rb +5 -4
  150. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  151. data/lib/rubygems/commands/contents_command.rb +4 -4
  152. data/lib/rubygems/commands/exec_command.rb +3 -0
  153. data/lib/rubygems/commands/pristine_command.rb +2 -2
  154. data/lib/rubygems/commands/push_command.rb +29 -5
  155. data/lib/rubygems/commands/rdoc_command.rb +2 -2
  156. data/lib/rubygems/commands/rebuild_command.rb +0 -2
  157. data/lib/rubygems/commands/setup_command.rb +1 -16
  158. data/lib/rubygems/commands/unpack_command.rb +0 -6
  159. data/lib/rubygems/commands/update_command.rb +2 -8
  160. data/lib/rubygems/config_file.rb +12 -0
  161. data/lib/rubygems/core_ext/kernel_warn.rb +2 -6
  162. data/lib/rubygems/defaults.rb +1 -1
  163. data/lib/rubygems/exceptions.rb +0 -6
  164. data/lib/rubygems/ext/builder.rb +6 -4
  165. data/lib/rubygems/ext/cargo_builder.rb +7 -4
  166. data/lib/rubygems/ext/cmake_builder.rb +7 -2
  167. data/lib/rubygems/ext/configure_builder.rb +7 -2
  168. data/lib/rubygems/ext/ext_conf_builder.rb +9 -5
  169. data/lib/rubygems/ext/rake_builder.rb +6 -1
  170. data/lib/rubygems/install_update_options.rb +5 -0
  171. data/lib/rubygems/installer.rb +2 -2
  172. data/lib/rubygems/platform.rb +4 -3
  173. data/lib/rubygems/psych_tree.rb +4 -0
  174. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  175. data/lib/rubygems/requirement.rb +0 -4
  176. data/lib/rubygems/resolver/composed_set.rb +3 -3
  177. data/lib/rubygems/resolver/git_set.rb +0 -1
  178. data/lib/rubygems/resolver/index_set.rb +2 -2
  179. data/lib/rubygems/resolver.rb +3 -3
  180. data/lib/rubygems/source/git.rb +13 -10
  181. data/lib/rubygems/spec_fetcher.rb +16 -5
  182. data/lib/rubygems/specification.rb +37 -31
  183. data/lib/rubygems/target_rbconfig.rb +50 -0
  184. data/lib/rubygems/uri.rb +1 -1
  185. data/lib/rubygems/util/licenses.rb +10 -1
  186. data/lib/rubygems/vendor/net-http/COPYING +56 -0
  187. data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +1 -1
  188. data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +5 -0
  189. data/lib/rubygems/vendor/net-http/lib/net/http.rb +120 -36
  190. data/lib/rubygems/vendor/optparse/lib/optparse/ac.rb +16 -0
  191. data/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb +8 -3
  192. data/lib/rubygems/vendor/optparse/lib/optparse/version.rb +9 -0
  193. data/lib/rubygems/vendor/optparse/lib/optparse.rb +147 -51
  194. data/lib/rubygems/vendor/resolv/COPYING +56 -0
  195. data/lib/rubygems/vendor/resolv/lib/resolv.rb +50 -37
  196. data/lib/rubygems/vendor/securerandom/COPYING +56 -0
  197. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +5 -5
  198. data/lib/rubygems/vendor/timeout/COPYING +56 -0
  199. data/lib/rubygems/vendor/timeout/lib/timeout.rb +5 -8
  200. data/lib/rubygems/vendor/uri/COPYING +56 -0
  201. data/lib/rubygems/vendor/uri/lib/uri/common.rb +37 -16
  202. data/lib/rubygems/vendor/uri/lib/uri/file.rb +3 -3
  203. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +1 -1
  204. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +16 -26
  205. data/lib/rubygems/vendor/uri/lib/uri/http.rb +2 -2
  206. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  207. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  208. data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
  209. data/lib/rubygems/vendor/uri/lib/uri.rb +9 -9
  210. data/lib/rubygems/vendored_securerandom.rb +0 -1
  211. data/lib/rubygems/version.rb +0 -4
  212. data/lib/rubygems.rb +29 -20
  213. data/rubygems-update.gemspec +5 -5
  214. data/setup.rb +1 -1
  215. metadata +36 -27
  216. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  217. data/bundler/lib/bundler/vendor/securerandom/LICENSE.txt +0 -22
  218. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +0 -373
  219. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +0 -22
  220. data/lib/rubygems/vendor/net-http/LICENSE.txt +0 -22
  221. data/lib/rubygems/vendor/net-http/lib/net/http/backward.rb +0 -40
  222. data/lib/rubygems/vendor/resolv/LICENSE.txt +0 -22
  223. data/lib/rubygems/vendor/securerandom/LICENSE.txt +0 -22
  224. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +0 -373
  225. data/lib/rubygems/vendor/timeout/LICENSE.txt +0 -22
  226. data/lib/rubygems/vendor/uri/LICENSE.txt +0 -22
  227. /data/{MAINTAINERS.txt → doc/MAINTAINERS.txt} +0 -0
  228. /data/{bundler → doc/bundler}/UPGRADING.md +0 -0
  229. /data/{UPGRADING.md → doc/rubygems/UPGRADING.md} +0 -0
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: false
2
2
  require_relative '../optparse'
3
3
 
4
+ #
5
+ # autoconf-like options.
6
+ #
4
7
  class Gem::OptionParser::AC < Gem::OptionParser
8
+ # :stopdoc:
5
9
  private
6
10
 
7
11
  def _check_ac_args(name, block)
@@ -14,6 +18,7 @@ class Gem::OptionParser::AC < Gem::OptionParser
14
18
  end
15
19
 
16
20
  ARG_CONV = proc {|val| val.nil? ? true : val}
21
+ private_constant :ARG_CONV
17
22
 
18
23
  def _ac_arg_enable(prefix, name, help_string, block)
19
24
  _check_ac_args(name, block)
@@ -29,16 +34,27 @@ class Gem::OptionParser::AC < Gem::OptionParser
29
34
  enable
30
35
  end
31
36
 
37
+ # :startdoc:
38
+
32
39
  public
33
40
 
41
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
42
+ #
43
+ # Appears as <tt>--enable-<i>name</i></tt> in help message.
34
44
  def ac_arg_enable(name, help_string, &block)
35
45
  _ac_arg_enable("enable", name, help_string, block)
36
46
  end
37
47
 
48
+ # Define <tt>--enable</tt> / <tt>--disable</tt> style option
49
+ #
50
+ # Appears as <tt>--disable-<i>name</i></tt> in help message.
38
51
  def ac_arg_disable(name, help_string, &block)
39
52
  _ac_arg_enable("disable", name, help_string, block)
40
53
  end
41
54
 
55
+ # Define <tt>--with</tt> / <tt>--without</tt> style option
56
+ #
57
+ # Appears as <tt>--with-<i>name</i></tt> in help message.
42
58
  def ac_arg_with(name, help_string, &block)
43
59
  _check_ac_args(name, block)
44
60
 
@@ -7,12 +7,17 @@ class Gem::OptionParser
7
7
  #
8
8
  # :include: ../../doc/optparse/creates_option.rdoc
9
9
  #
10
- def define_by_keywords(options, meth, **opts)
11
- meth.parameters.each do |type, name|
10
+ # Defines options which set in to _options_ for keyword parameters
11
+ # of _method_.
12
+ #
13
+ # Parameters for each keywords are given as elements of _params_.
14
+ #
15
+ def define_by_keywords(options, method, **params)
16
+ method.parameters.each do |type, name|
12
17
  case type
13
18
  when :key, :keyreq
14
19
  op, cl = *(type == :key ? %w"[ ]" : ["", ""])
15
- define("--#{name}=#{op}#{name.upcase}#{cl}", *opts[name]) do |o|
20
+ define("--#{name}=#{op}#{name.upcase}#{cl}", *params[name]) do |o|
16
21
  options[name] = o
17
22
  end
18
23
  end
@@ -2,6 +2,11 @@
2
2
  # Gem::OptionParser internal utility
3
3
 
4
4
  class << Gem::OptionParser
5
+ #
6
+ # Shows version string in packages if Version is defined.
7
+ #
8
+ # +pkgs+:: package list
9
+ #
5
10
  def show_version(*pkgs)
6
11
  progname = ARGV.options.program_name
7
12
  result = false
@@ -47,6 +52,8 @@ class << Gem::OptionParser
47
52
  result
48
53
  end
49
54
 
55
+ # :stopdoc:
56
+
50
57
  def each_const(path, base = ::Object)
51
58
  path.split(/::|\//).inject(base) do |klass, name|
52
59
  raise NameError, path unless Module === klass
@@ -68,4 +75,6 @@ class << Gem::OptionParser
68
75
  end
69
76
  end
70
77
  end
78
+
79
+ # :startdoc:
71
80
  end
@@ -8,7 +8,6 @@
8
8
  # See Gem::OptionParser for documentation.
9
9
  #
10
10
 
11
-
12
11
  #--
13
12
  # == Developer Documentation (not for RDoc output)
14
13
  #
@@ -425,7 +424,8 @@
425
424
  # If you have any questions, file a ticket at http://bugs.ruby-lang.org.
426
425
  #
427
426
  class Gem::OptionParser
428
- Gem::OptionParser::Version = "0.4.0"
427
+ # The version string
428
+ Gem::OptionParser::Version = "0.6.0"
429
429
 
430
430
  # :stopdoc:
431
431
  NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
@@ -438,6 +438,8 @@ class Gem::OptionParser
438
438
  # and resolved against a list of acceptable values.
439
439
  #
440
440
  module Completion
441
+ # :nodoc:
442
+
441
443
  def self.regexp(key, icase)
442
444
  Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'), icase)
443
445
  end
@@ -459,7 +461,7 @@ class Gem::OptionParser
459
461
  candidates
460
462
  end
461
463
 
462
- def candidate(key, icase = false, pat = nil)
464
+ def candidate(key, icase = false, pat = nil, &_)
463
465
  Completion.candidate(key, icase, pat, &method(:each))
464
466
  end
465
467
 
@@ -510,6 +512,8 @@ class Gem::OptionParser
510
512
  # RequiredArgument, etc.
511
513
  #
512
514
  class Switch
515
+ # :nodoc:
516
+
513
517
  attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block
514
518
 
515
519
  #
@@ -697,6 +701,11 @@ class Gem::OptionParser
697
701
  q.object_group(self) {pretty_print_contents(q)}
698
702
  end
699
703
 
704
+ def omitted_argument(val) # :nodoc:
705
+ val.pop if val.size == 3 and val.last.nil?
706
+ val
707
+ end
708
+
700
709
  #
701
710
  # Switch that takes no arguments.
702
711
  #
@@ -710,10 +719,10 @@ class Gem::OptionParser
710
719
  conv_arg(arg)
711
720
  end
712
721
 
713
- def self.incompatible_argument_styles(*)
722
+ def self.incompatible_argument_styles(*) # :nodoc:
714
723
  end
715
724
 
716
- def self.pattern
725
+ def self.pattern # :nodoc:
717
726
  Object
718
727
  end
719
728
 
@@ -730,7 +739,7 @@ class Gem::OptionParser
730
739
  #
731
740
  # Raises an exception if argument is not present.
732
741
  #
733
- def parse(arg, argv)
742
+ def parse(arg, argv, &_)
734
743
  unless arg
735
744
  raise MissingArgument if argv.empty?
736
745
  arg = argv.shift
@@ -755,7 +764,7 @@ class Gem::OptionParser
755
764
  if arg
756
765
  conv_arg(*parse_arg(arg, &error))
757
766
  else
758
- conv_arg(arg)
767
+ omitted_argument conv_arg(arg)
759
768
  end
760
769
  end
761
770
 
@@ -774,13 +783,14 @@ class Gem::OptionParser
774
783
  #
775
784
  def parse(arg, argv, &error)
776
785
  if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
777
- return nil, block, nil
786
+ return nil, block
778
787
  end
779
788
  opt = (val = parse_arg(val, &error))[1]
780
789
  val = conv_arg(*val)
781
790
  if opt and !arg
782
791
  argv.shift
783
792
  else
793
+ omitted_argument val
784
794
  val[0] = nil
785
795
  end
786
796
  val
@@ -798,6 +808,8 @@ class Gem::OptionParser
798
808
  # matching pattern and converter pair. Also provides summary feature.
799
809
  #
800
810
  class List
811
+ # :nodoc:
812
+
801
813
  # Map from acceptable argument types to pattern and converter pairs.
802
814
  attr_reader :atype
803
815
 
@@ -837,7 +849,7 @@ class Gem::OptionParser
837
849
  def accept(t, pat = /.*/m, &block)
838
850
  if pat
839
851
  pat.respond_to?(:match) or
840
- raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2))
852
+ raise TypeError, "has no 'match'", ParseError.filter_backtrace(caller(2))
841
853
  else
842
854
  pat = t if t.respond_to?(:match)
843
855
  end
@@ -1033,11 +1045,31 @@ XXX
1033
1045
  to << "#compdef #{name}\n"
1034
1046
  to << COMPSYS_HEADER
1035
1047
  visit(:compsys, {}, {}) {|o, d|
1036
- to << %Q[ "#{o}[#{d.gsub(/[\"\[\]]/, '\\\\\&')}]" \\\n]
1048
+ to << %Q[ "#{o}[#{d.gsub(/[\\\"\[\]]/, '\\\\\&')}]" \\\n]
1037
1049
  }
1038
1050
  to << " '*:file:_files' && return 0\n"
1039
1051
  end
1040
1052
 
1053
+ def help_exit
1054
+ if STDOUT.tty? && (pager = ENV.values_at(*%w[RUBY_PAGER PAGER]).find {|e| e && !e.empty?})
1055
+ less = ENV["LESS"]
1056
+ args = [{"LESS" => "#{!less || less.empty? ? '-' : less}Fe"}, pager, "w"]
1057
+ print = proc do |f|
1058
+ f.puts help
1059
+ rescue Errno::EPIPE
1060
+ # pager terminated
1061
+ end
1062
+ if Process.respond_to?(:fork) and false
1063
+ IO.popen("-") {|f| f ? Process.exec(*args, in: f) : print.call(STDOUT)}
1064
+ # unreachable
1065
+ end
1066
+ IO.popen(*args, &print)
1067
+ else
1068
+ puts help
1069
+ end
1070
+ exit
1071
+ end
1072
+
1041
1073
  #
1042
1074
  # Default options for ARGV, which never appear in option summary.
1043
1075
  #
@@ -1049,8 +1081,7 @@ XXX
1049
1081
  #
1050
1082
  Officious['help'] = proc do |parser|
1051
1083
  Switch::NoArgument.new do |arg|
1052
- puts parser.help
1053
- exit
1084
+ parser.help_exit
1054
1085
  end
1055
1086
  end
1056
1087
 
@@ -1129,6 +1160,10 @@ XXX
1129
1160
  default.to_i + 1
1130
1161
  end
1131
1162
  end
1163
+
1164
+ #
1165
+ # See self.inc
1166
+ #
1132
1167
  def inc(*args)
1133
1168
  self.class.inc(*args)
1134
1169
  end
@@ -1167,11 +1202,19 @@ XXX
1167
1202
  def terminate(arg = nil)
1168
1203
  self.class.terminate(arg)
1169
1204
  end
1205
+ #
1206
+ # See #terminate.
1207
+ #
1170
1208
  def self.terminate(arg = nil)
1171
1209
  throw :terminate, arg
1172
1210
  end
1173
1211
 
1174
1212
  @stack = [DefaultList]
1213
+ #
1214
+ # Returns the global top option list.
1215
+ #
1216
+ # Do not use directly.
1217
+ #
1175
1218
  def self.top() DefaultList end
1176
1219
 
1177
1220
  #
@@ -1192,9 +1235,9 @@ XXX
1192
1235
  #
1193
1236
  # Directs to reject specified class argument.
1194
1237
  #
1195
- # +t+:: Argument class specifier, any object including Class.
1238
+ # +type+:: Argument class specifier, any object including Class.
1196
1239
  #
1197
- # reject(t)
1240
+ # reject(type)
1198
1241
  #
1199
1242
  def reject(*args, &blk) top.reject(*args, &blk) end
1200
1243
  #
@@ -1284,10 +1327,24 @@ XXX
1284
1327
  end
1285
1328
  end
1286
1329
 
1330
+ #
1331
+ # Shows warning message with the program name
1332
+ #
1333
+ # +mesg+:: Message, defaulted to +$!+.
1334
+ #
1335
+ # See Kernel#warn.
1336
+ #
1287
1337
  def warn(mesg = $!)
1288
1338
  super("#{program_name}: #{mesg}")
1289
1339
  end
1290
1340
 
1341
+ #
1342
+ # Shows message with the program name then aborts.
1343
+ #
1344
+ # +mesg+:: Message, defaulted to +$!+.
1345
+ #
1346
+ # See Kernel#abort.
1347
+ #
1291
1348
  def abort(mesg = $!)
1292
1349
  super("#{program_name}: #{mesg}")
1293
1350
  end
@@ -1309,6 +1366,9 @@ XXX
1309
1366
  #
1310
1367
  # Pushes a new List.
1311
1368
  #
1369
+ # If a block is given, yields +self+ and returns the result of the
1370
+ # block, otherwise returns +self+.
1371
+ #
1312
1372
  def new
1313
1373
  @stack.push(List.new)
1314
1374
  if block_given?
@@ -1532,6 +1592,12 @@ XXX
1532
1592
  nolong
1533
1593
  end
1534
1594
 
1595
+ # ----
1596
+ # Option definition phase methods
1597
+ #
1598
+ # These methods are used to define options, or to construct an
1599
+ # Gem::OptionParser instance in other words.
1600
+
1535
1601
  # :call-seq:
1536
1602
  # define(*params, &block)
1537
1603
  #
@@ -1607,6 +1673,13 @@ XXX
1607
1673
  top.append(string, nil, nil)
1608
1674
  end
1609
1675
 
1676
+ # ----
1677
+ # Arguments parse phase methods
1678
+ #
1679
+ # These methods parse +argv+, convert, and store the results by
1680
+ # calling handlers. As these methods do not modify +self+, +self+
1681
+ # can be frozen.
1682
+
1610
1683
  #
1611
1684
  # Parses command line arguments +argv+ in order. When a block is given,
1612
1685
  # each non-option argument is yielded. When optional +into+ keyword
@@ -1616,21 +1689,21 @@ XXX
1616
1689
  #
1617
1690
  # Returns the rest of +argv+ left unparsed.
1618
1691
  #
1619
- def order(*argv, into: nil, &nonopt)
1692
+ def order(*argv, **keywords, &nonopt)
1620
1693
  argv = argv[0].dup if argv.size == 1 and Array === argv[0]
1621
- order!(argv, into: into, &nonopt)
1694
+ order!(argv, **keywords, &nonopt)
1622
1695
  end
1623
1696
 
1624
1697
  #
1625
1698
  # Same as #order, but removes switches destructively.
1626
1699
  # Non-option arguments remain in +argv+.
1627
1700
  #
1628
- def order!(argv = default_argv, into: nil, &nonopt)
1701
+ def order!(argv = default_argv, into: nil, **keywords, &nonopt)
1629
1702
  setter = ->(name, val) {into[name.to_sym] = val} if into
1630
- parse_in_order(argv, setter, &nonopt)
1703
+ parse_in_order(argv, setter, **keywords, &nonopt)
1631
1704
  end
1632
1705
 
1633
- def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
1706
+ def parse_in_order(argv = default_argv, setter = nil, exact: require_exact, **, &nonopt) # :nodoc:
1634
1707
  opt, arg, val, rest = nil
1635
1708
  nonopt ||= proc {|a| throw :terminate, a}
1636
1709
  argv.unshift(arg) if arg = catch(:terminate) {
@@ -1641,19 +1714,24 @@ XXX
1641
1714
  opt, rest = $1, $2
1642
1715
  opt.tr!('_', '-')
1643
1716
  begin
1644
- sw, = complete(:long, opt, true)
1645
- if require_exact && !sw.long.include?(arg)
1646
- throw :terminate, arg unless raise_unknown
1647
- raise InvalidOption, arg
1717
+ if exact
1718
+ sw, = search(:long, opt)
1719
+ else
1720
+ sw, = complete(:long, opt, true)
1648
1721
  end
1649
1722
  rescue ParseError
1650
1723
  throw :terminate, arg unless raise_unknown
1651
1724
  raise $!.set_option(arg, true)
1725
+ else
1726
+ unless sw
1727
+ throw :terminate, arg unless raise_unknown
1728
+ raise InvalidOption, arg
1729
+ end
1652
1730
  end
1653
1731
  begin
1654
1732
  opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
1655
- val = cb.call(val) if cb
1656
- setter.call(sw.switch_name, val) if setter
1733
+ val = callback!(cb, 1, val) if cb
1734
+ callback!(setter, 2, sw.switch_name, val) if setter
1657
1735
  rescue ParseError
1658
1736
  raise $!.set_option(arg, rest)
1659
1737
  end
@@ -1671,7 +1749,7 @@ XXX
1671
1749
  val = arg.delete_prefix('-')
1672
1750
  has_arg = true
1673
1751
  rescue InvalidOption
1674
- raise if require_exact
1752
+ raise if exact
1675
1753
  # if no short options match, try completion with long
1676
1754
  # options.
1677
1755
  sw, = complete(:long, opt)
@@ -1691,8 +1769,8 @@ XXX
1691
1769
  end
1692
1770
  begin
1693
1771
  argv.unshift(opt) if opt and (!rest or (opt = opt.sub(/\A-*/, '-')) != '-')
1694
- val = cb.call(val) if cb
1695
- setter.call(sw.switch_name, val) if setter
1772
+ val = callback!(cb, 1, val) if cb
1773
+ callback!(setter, 2, sw.switch_name, val) if setter
1696
1774
  rescue ParseError
1697
1775
  raise $!.set_option(arg, arg.length > 2)
1698
1776
  end
@@ -1718,6 +1796,19 @@ XXX
1718
1796
  end
1719
1797
  private :parse_in_order
1720
1798
 
1799
+ # Calls callback with _val_.
1800
+ def callback!(cb, max_arity, *args) # :nodoc:
1801
+ args.compact!
1802
+
1803
+ if (size = args.size) < max_arity and cb.to_proc.lambda?
1804
+ (arity = cb.arity) < 0 and arity = (1-arity)
1805
+ arity = max_arity if arity > max_arity
1806
+ args[arity - 1] = nil if arity > size
1807
+ end
1808
+ cb.call(*args)
1809
+ end
1810
+ private :callback!
1811
+
1721
1812
  #
1722
1813
  # Parses command line arguments +argv+ in permutation mode and returns
1723
1814
  # list of non-option arguments. When optional +into+ keyword
@@ -1725,18 +1816,18 @@ XXX
1725
1816
  # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
1726
1817
  # similar object).
1727
1818
  #
1728
- def permute(*argv, into: nil)
1819
+ def permute(*argv, **keywords)
1729
1820
  argv = argv[0].dup if argv.size == 1 and Array === argv[0]
1730
- permute!(argv, into: into)
1821
+ permute!(argv, **keywords)
1731
1822
  end
1732
1823
 
1733
1824
  #
1734
1825
  # Same as #permute, but removes switches destructively.
1735
1826
  # Non-option arguments remain in +argv+.
1736
1827
  #
1737
- def permute!(argv = default_argv, into: nil)
1828
+ def permute!(argv = default_argv, **keywords)
1738
1829
  nonopts = []
1739
- order!(argv, into: into, &nonopts.method(:<<))
1830
+ order!(argv, **keywords, &nonopts.method(:<<))
1740
1831
  argv[0, 0] = nonopts
1741
1832
  argv
1742
1833
  end
@@ -1748,20 +1839,20 @@ XXX
1748
1839
  # values are stored there via <code>[]=</code> method (so it can be Hash,
1749
1840
  # or OpenStruct, or other similar object).
1750
1841
  #
1751
- def parse(*argv, into: nil)
1842
+ def parse(*argv, **keywords)
1752
1843
  argv = argv[0].dup if argv.size == 1 and Array === argv[0]
1753
- parse!(argv, into: into)
1844
+ parse!(argv, **keywords)
1754
1845
  end
1755
1846
 
1756
1847
  #
1757
1848
  # Same as #parse, but removes switches destructively.
1758
1849
  # Non-option arguments remain in +argv+.
1759
1850
  #
1760
- def parse!(argv = default_argv, into: nil)
1851
+ def parse!(argv = default_argv, **keywords)
1761
1852
  if ENV.include?('POSIXLY_CORRECT')
1762
- order!(argv, into: into)
1853
+ order!(argv, **keywords)
1763
1854
  else
1764
- permute!(argv, into: into)
1855
+ permute!(argv, **keywords)
1765
1856
  end
1766
1857
  end
1767
1858
 
@@ -1784,7 +1875,7 @@ XXX
1784
1875
  # # params[:bar] = "x" # --bar x
1785
1876
  # # params[:zot] = "z" # --zot Z
1786
1877
  #
1787
- def getopts(*args, symbolize_names: false)
1878
+ def getopts(*args, symbolize_names: false, **keywords)
1788
1879
  argv = Array === args.first ? args.shift : default_argv
1789
1880
  single_options, *long_options = *args
1790
1881
 
@@ -1812,7 +1903,7 @@ XXX
1812
1903
  end
1813
1904
  end
1814
1905
 
1815
- parse_in_order(argv, result.method(:[]=))
1906
+ parse_in_order(argv, result.method(:[]=), **keywords)
1816
1907
  symbolize_names ? result.transform_keys(&:to_sym) : result
1817
1908
  end
1818
1909
 
@@ -1881,6 +1972,9 @@ XXX
1881
1972
  DidYouMean.formatter.message_for(all_candidates & checker.correct(opt))
1882
1973
  end
1883
1974
 
1975
+ #
1976
+ # Return candidates for +word+.
1977
+ #
1884
1978
  def candidate(word)
1885
1979
  list = []
1886
1980
  case word
@@ -1922,10 +2016,10 @@ XXX
1922
2016
  # The optional +into+ keyword argument works exactly like that accepted in
1923
2017
  # method #parse.
1924
2018
  #
1925
- def load(filename = nil, into: nil)
2019
+ def load(filename = nil, **keywords)
1926
2020
  unless filename
1927
2021
  basename = File.basename($0, '.*')
1928
- return true if load(File.expand_path(basename, '~/.options'), into: into) rescue nil
2022
+ return true if load(File.expand_path(basename, '~/.options'), **keywords) rescue nil
1929
2023
  basename << ".options"
1930
2024
  return [
1931
2025
  # XDG
@@ -1937,11 +2031,11 @@ XXX
1937
2031
  '~/config/settings',
1938
2032
  ].any? {|dir|
1939
2033
  next if !dir or dir.empty?
1940
- load(File.expand_path(basename, dir), into: into) rescue nil
2034
+ load(File.expand_path(basename, dir), **keywords) rescue nil
1941
2035
  }
1942
2036
  end
1943
2037
  begin
1944
- parse(*File.readlines(filename, chomp: true), into: into)
2038
+ parse(*File.readlines(filename, chomp: true), **keywords)
1945
2039
  true
1946
2040
  rescue Errno::ENOENT, Errno::ENOTDIR
1947
2041
  false
@@ -1954,10 +2048,10 @@ XXX
1954
2048
  #
1955
2049
  # +env+ defaults to the basename of the program.
1956
2050
  #
1957
- def environment(env = File.basename($0, '.*'))
2051
+ def environment(env = File.basename($0, '.*'), **keywords)
1958
2052
  env = ENV[env] || ENV[env.upcase] or return
1959
2053
  require 'shellwords'
1960
- parse(*Shellwords.shellwords(env))
2054
+ parse(*Shellwords.shellwords(env), **keywords)
1961
2055
  end
1962
2056
 
1963
2057
  #
@@ -2123,6 +2217,7 @@ XXX
2123
2217
  # Reason which caused the error.
2124
2218
  Reason = 'parse error'
2125
2219
 
2220
+ # :nodoc:
2126
2221
  def initialize(*args, additional: nil)
2127
2222
  @additional = additional
2128
2223
  @arg0, = args
@@ -2273,19 +2368,19 @@ XXX
2273
2368
  # Parses +self+ destructively in order and returns +self+ containing the
2274
2369
  # rest arguments left unparsed.
2275
2370
  #
2276
- def order!(&blk) options.order!(self, &blk) end
2371
+ def order!(**keywords, &blk) options.order!(self, **keywords, &blk) end
2277
2372
 
2278
2373
  #
2279
2374
  # Parses +self+ destructively in permutation mode and returns +self+
2280
2375
  # containing the rest arguments left unparsed.
2281
2376
  #
2282
- def permute!() options.permute!(self) end
2377
+ def permute!(**keywords) options.permute!(self, **keywords) end
2283
2378
 
2284
2379
  #
2285
2380
  # Parses +self+ destructively and returns +self+ containing the
2286
2381
  # rest arguments left unparsed.
2287
2382
  #
2288
- def parse!() options.parse!(self) end
2383
+ def parse!(**keywords) options.parse!(self, **keywords) end
2289
2384
 
2290
2385
  #
2291
2386
  # Substitution of getopts is possible as follows. Also see
@@ -2298,8 +2393,8 @@ XXX
2298
2393
  # rescue Gem::OptionParser::ParseError
2299
2394
  # end
2300
2395
  #
2301
- def getopts(*args, symbolize_names: false)
2302
- options.getopts(self, *args, symbolize_names: symbolize_names)
2396
+ def getopts(*args, symbolize_names: false, **keywords)
2397
+ options.getopts(self, *args, symbolize_names: symbolize_names, **keywords)
2303
2398
  end
2304
2399
 
2305
2400
  #
@@ -2309,7 +2404,8 @@ XXX
2309
2404
  super
2310
2405
  obj.instance_eval {@optparse = nil}
2311
2406
  end
2312
- def initialize(*args)
2407
+
2408
+ def initialize(*args) # :nodoc:
2313
2409
  super
2314
2410
  @optparse = nil
2315
2411
  end
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.