rubygems-update 3.5.22 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +91 -0
  3. data/Manifest.txt +23 -16
  4. data/README.md +14 -9
  5. data/bundler/CHANGELOG.md +83 -0
  6. data/bundler/bundler.gemspec +2 -2
  7. data/bundler/lib/bundler/build_metadata.rb +2 -2
  8. data/bundler/lib/bundler/cli/add.rb +2 -0
  9. data/bundler/lib/bundler/cli/check.rb +2 -2
  10. data/bundler/lib/bundler/cli/console.rb +0 -4
  11. data/bundler/lib/bundler/cli/doctor.rb +4 -4
  12. data/bundler/lib/bundler/cli/exec.rb +1 -0
  13. data/bundler/lib/bundler/cli/gem.rb +1 -1
  14. data/bundler/lib/bundler/cli/info.rb +2 -2
  15. data/bundler/lib/bundler/cli/inject.rb +1 -1
  16. data/bundler/lib/bundler/cli/install.rb +4 -0
  17. data/bundler/lib/bundler/cli/lock.rb +20 -1
  18. data/bundler/lib/bundler/cli/pristine.rb +1 -1
  19. data/bundler/lib/bundler/cli/show.rb +2 -2
  20. data/bundler/lib/bundler/cli.rb +23 -53
  21. data/bundler/lib/bundler/compact_index_client/cache_file.rb +0 -5
  22. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -11
  23. data/bundler/lib/bundler/definition.rb +143 -76
  24. data/bundler/lib/bundler/dependency.rb +1 -1
  25. data/bundler/lib/bundler/dsl.rb +33 -28
  26. data/bundler/lib/bundler/endpoint_specification.rb +10 -1
  27. data/bundler/lib/bundler/errors.rb +10 -0
  28. data/bundler/lib/bundler/feature_flag.rb +1 -0
  29. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  30. data/bundler/lib/bundler/fetcher.rb +10 -3
  31. data/bundler/lib/bundler/gem_helpers.rb +21 -5
  32. data/bundler/lib/bundler/injector.rb +2 -2
  33. data/bundler/lib/bundler/inline.rb +12 -8
  34. data/bundler/lib/bundler/installer/standalone.rb +2 -2
  35. data/bundler/lib/bundler/installer.rb +4 -38
  36. data/bundler/lib/bundler/lazy_specification.rb +74 -26
  37. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  38. data/bundler/lib/bundler/lockfile_parser.rb +9 -1
  39. data/bundler/lib/bundler/man/bundle-add.1 +17 -11
  40. data/bundler/lib/bundler/man/bundle-add.1.ronn +16 -10
  41. data/bundler/lib/bundler/man/bundle-binstubs.1 +7 -4
  42. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  43. data/bundler/lib/bundler/man/bundle-cache.1 +30 -2
  44. data/bundler/lib/bundler/man/bundle-cache.1.ronn +31 -2
  45. data/bundler/lib/bundler/man/bundle-check.1 +3 -3
  46. data/bundler/lib/bundler/man/bundle-check.1.ronn +4 -2
  47. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  48. data/bundler/lib/bundler/man/bundle-config.1 +3 -5
  49. data/bundler/lib/bundler/man/bundle-config.1.ronn +2 -7
  50. data/bundler/lib/bundler/man/bundle-console.1 +2 -4
  51. data/bundler/lib/bundler/man/bundle-console.1.ronn +2 -7
  52. data/bundler/lib/bundler/man/bundle-doctor.1 +2 -2
  53. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  54. data/bundler/lib/bundler/man/bundle-env.1 +9 -0
  55. data/bundler/lib/bundler/man/bundle-env.1.ronn +10 -0
  56. data/bundler/lib/bundler/man/bundle-exec.1 +5 -2
  57. data/bundler/lib/bundler/man/bundle-exec.1.ronn +4 -1
  58. data/bundler/lib/bundler/man/bundle-fund.1 +22 -0
  59. data/bundler/lib/bundler/man/bundle-fund.1.ronn +25 -0
  60. data/bundler/lib/bundler/man/bundle-gem.1 +17 -5
  61. data/bundler/lib/bundler/man/bundle-gem.1.ronn +27 -6
  62. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-info.1 +5 -2
  64. data/bundler/lib/bundler/man/bundle-info.1.ronn +6 -2
  65. data/bundler/lib/bundler/man/bundle-init.1 +3 -3
  66. data/bundler/lib/bundler/man/bundle-init.1.ronn +3 -2
  67. data/bundler/lib/bundler/man/bundle-inject.1 +10 -2
  68. data/bundler/lib/bundler/man/bundle-inject.1.ronn +9 -1
  69. data/bundler/lib/bundler/man/bundle-install.1 +15 -12
  70. data/bundler/lib/bundler/man/bundle-install.1.ronn +22 -18
  71. data/bundler/lib/bundler/man/bundle-issue.1 +45 -0
  72. data/bundler/lib/bundler/man/bundle-issue.1.ronn +37 -0
  73. data/bundler/lib/bundler/man/bundle-licenses.1 +9 -0
  74. data/bundler/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  75. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  76. data/bundler/lib/bundler/man/bundle-list.1.ronn +4 -1
  77. data/bundler/lib/bundler/man/bundle-lock.1 +21 -6
  78. data/bundler/lib/bundler/man/bundle-lock.1.ronn +25 -4
  79. data/bundler/lib/bundler/man/bundle-open.1 +2 -2
  80. data/bundler/lib/bundler/man/bundle-open.1.ronn +2 -1
  81. data/bundler/lib/bundler/man/bundle-outdated.1 +8 -5
  82. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  83. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  84. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  85. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  86. data/bundler/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  87. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  88. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -1
  89. data/bundler/lib/bundler/man/bundle-show.1 +5 -2
  90. data/bundler/lib/bundler/man/bundle-show.1.ronn +4 -0
  91. data/bundler/lib/bundler/man/bundle-update.1 +13 -7
  92. data/bundler/lib/bundler/man/bundle-update.1.ronn +14 -6
  93. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  94. data/bundler/lib/bundler/man/bundle-viz.1 +4 -4
  95. data/bundler/lib/bundler/man/bundle-viz.1.ronn +7 -3
  96. data/bundler/lib/bundler/man/bundle.1 +1 -1
  97. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  98. data/bundler/lib/bundler/man/index.txt +4 -0
  99. data/bundler/lib/bundler/materialization.rb +59 -0
  100. data/bundler/lib/bundler/plugin/events.rb +24 -0
  101. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  102. data/bundler/lib/bundler/plugin.rb +20 -1
  103. data/bundler/lib/bundler/process_lock.rb +10 -14
  104. data/bundler/lib/bundler/remote_specification.rb +6 -1
  105. data/bundler/lib/bundler/resolver/base.rb +6 -6
  106. data/bundler/lib/bundler/resolver/candidate.rb +2 -2
  107. data/bundler/lib/bundler/resolver/spec_group.rb +4 -3
  108. data/bundler/lib/bundler/resolver.rb +5 -5
  109. data/bundler/lib/bundler/rubygems_ext.rb +30 -27
  110. data/bundler/lib/bundler/rubygems_gem_installer.rb +3 -2
  111. data/bundler/lib/bundler/rubygems_integration.rb +23 -40
  112. data/bundler/lib/bundler/runtime.rb +27 -7
  113. data/bundler/lib/bundler/self_manager.rb +2 -3
  114. data/bundler/lib/bundler/settings.rb +6 -1
  115. data/bundler/lib/bundler/shared_helpers.rb +29 -17
  116. data/bundler/lib/bundler/source/git/git_proxy.rb +0 -6
  117. data/bundler/lib/bundler/source/git.rb +56 -31
  118. data/bundler/lib/bundler/source/metadata.rb +2 -3
  119. data/bundler/lib/bundler/source/path.rb +2 -2
  120. data/bundler/lib/bundler/source_list.rb +1 -1
  121. data/bundler/lib/bundler/spec_set.rb +81 -56
  122. data/bundler/lib/bundler/stub_specification.rb +8 -0
  123. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +0 -3
  124. data/bundler/lib/bundler/templates/newgem/README.md.tt +1 -1
  125. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +15 -15
  126. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -4
  127. data/bundler/lib/bundler/uri_credentials_filter.rb +1 -1
  128. data/bundler/lib/bundler/vendor/fileutils/COPYING +56 -0
  129. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  130. data/bundler/lib/bundler/vendor/securerandom/COPYING +56 -0
  131. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +5 -5
  132. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  133. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  134. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  135. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  136. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  137. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  138. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  139. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  140. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  141. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  142. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  143. data/bundler/lib/bundler/vendor/uri/COPYING +56 -0
  144. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +37 -16
  145. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  146. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  147. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +16 -26
  148. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  149. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  150. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  151. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  152. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  153. data/bundler/lib/bundler/vendored_securerandom.rb +0 -2
  154. data/bundler/lib/bundler/version.rb +1 -1
  155. data/bundler/lib/bundler.rb +38 -14
  156. data/{CONTRIBUTING.md → doc/rubygems/CONTRIBUTING.md} +9 -9
  157. data/{POLICIES.md → doc/rubygems/POLICIES.md} +11 -11
  158. data/lib/rubygems/basic_specification.rb +5 -4
  159. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  160. data/lib/rubygems/commands/contents_command.rb +4 -4
  161. data/lib/rubygems/commands/exec_command.rb +3 -0
  162. data/lib/rubygems/commands/pristine_command.rb +2 -2
  163. data/lib/rubygems/commands/push_command.rb +29 -5
  164. data/lib/rubygems/commands/rdoc_command.rb +2 -2
  165. data/lib/rubygems/commands/rebuild_command.rb +0 -2
  166. data/lib/rubygems/commands/setup_command.rb +7 -16
  167. data/lib/rubygems/commands/unpack_command.rb +0 -6
  168. data/lib/rubygems/commands/update_command.rb +2 -8
  169. data/lib/rubygems/config_file.rb +12 -0
  170. data/lib/rubygems/core_ext/kernel_warn.rb +2 -6
  171. data/lib/rubygems/defaults.rb +1 -1
  172. data/lib/rubygems/exceptions.rb +0 -6
  173. data/lib/rubygems/ext/builder.rb +6 -4
  174. data/lib/rubygems/ext/cargo_builder.rb +7 -4
  175. data/lib/rubygems/ext/cmake_builder.rb +7 -2
  176. data/lib/rubygems/ext/configure_builder.rb +7 -2
  177. data/lib/rubygems/ext/ext_conf_builder.rb +9 -5
  178. data/lib/rubygems/ext/rake_builder.rb +6 -1
  179. data/lib/rubygems/gem_runner.rb +9 -0
  180. data/lib/rubygems/gemcutter_utilities.rb +8 -2
  181. data/lib/rubygems/install_update_options.rb +5 -0
  182. data/lib/rubygems/installer.rb +8 -9
  183. data/lib/rubygems/package/tar_header.rb +11 -0
  184. data/lib/rubygems/package/tar_reader/entry.rb +1 -5
  185. data/lib/rubygems/platform.rb +4 -3
  186. data/lib/rubygems/psych_tree.rb +4 -0
  187. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  188. data/lib/rubygems/requirement.rb +0 -4
  189. data/lib/rubygems/resolver/composed_set.rb +3 -3
  190. data/lib/rubygems/resolver/git_set.rb +0 -1
  191. data/lib/rubygems/resolver/index_set.rb +2 -2
  192. data/lib/rubygems/resolver.rb +3 -3
  193. data/lib/rubygems/source/git.rb +13 -10
  194. data/lib/rubygems/spec_fetcher.rb +46 -7
  195. data/lib/rubygems/specification.rb +38 -32
  196. data/lib/rubygems/target_rbconfig.rb +50 -0
  197. data/lib/rubygems/uri.rb +1 -1
  198. data/lib/rubygems/util/licenses.rb +10 -1
  199. data/lib/rubygems/vendor/net-http/COPYING +56 -0
  200. data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +1 -1
  201. data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +5 -0
  202. data/lib/rubygems/vendor/net-http/lib/net/http.rb +120 -36
  203. data/lib/rubygems/vendor/optparse/lib/optparse/ac.rb +16 -0
  204. data/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb +8 -3
  205. data/lib/rubygems/vendor/optparse/lib/optparse/version.rb +9 -0
  206. data/lib/rubygems/vendor/optparse/lib/optparse.rb +147 -51
  207. data/lib/rubygems/vendor/resolv/COPYING +56 -0
  208. data/lib/rubygems/vendor/resolv/lib/resolv.rb +50 -37
  209. data/lib/rubygems/vendor/securerandom/COPYING +56 -0
  210. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +5 -5
  211. data/lib/rubygems/vendor/timeout/COPYING +56 -0
  212. data/lib/rubygems/vendor/timeout/lib/timeout.rb +5 -8
  213. data/lib/rubygems/vendor/uri/COPYING +56 -0
  214. data/lib/rubygems/vendor/uri/lib/uri/common.rb +37 -16
  215. data/lib/rubygems/vendor/uri/lib/uri/file.rb +3 -3
  216. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +1 -1
  217. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +16 -26
  218. data/lib/rubygems/vendor/uri/lib/uri/http.rb +2 -2
  219. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  220. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  221. data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
  222. data/lib/rubygems/vendor/uri/lib/uri.rb +9 -9
  223. data/lib/rubygems/vendored_securerandom.rb +0 -1
  224. data/lib/rubygems/version.rb +0 -4
  225. data/lib/rubygems.rb +30 -20
  226. data/rubygems-update.gemspec +5 -5
  227. data/setup.rb +1 -1
  228. metadata +36 -27
  229. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  230. data/bundler/lib/bundler/vendor/securerandom/LICENSE.txt +0 -22
  231. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +0 -373
  232. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +0 -22
  233. data/lib/rubygems/vendor/net-http/LICENSE.txt +0 -22
  234. data/lib/rubygems/vendor/net-http/lib/net/http/backward.rb +0 -40
  235. data/lib/rubygems/vendor/resolv/LICENSE.txt +0 -22
  236. data/lib/rubygems/vendor/securerandom/LICENSE.txt +0 -22
  237. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +0 -373
  238. data/lib/rubygems/vendor/timeout/LICENSE.txt +0 -22
  239. data/lib/rubygems/vendor/uri/LICENSE.txt +0 -22
  240. /data/{MAINTAINERS.txt → doc/MAINTAINERS.txt} +0 -0
  241. /data/{bundler → doc/bundler}/UPGRADING.md +0 -0
  242. /data/{UPGRADING.md → doc/rubygems/UPGRADING.md} +0 -0
@@ -67,6 +67,8 @@ module Gem::Net #:nodoc:
67
67
  # Gem::Net::HTTP.post(uri, data)
68
68
  # params = {title: 'foo', body: 'bar', userId: 1}
69
69
  # Gem::Net::HTTP.post_form(uri, params)
70
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
71
+ # Gem::Net::HTTP.put(uri, data)
70
72
  #
71
73
  # - If performance is important, consider using sessions, which lower request overhead.
72
74
  # This {session}[rdoc-ref:Gem::Net::HTTP@Sessions] has multiple requests for
@@ -456,6 +458,10 @@ module Gem::Net #:nodoc:
456
458
  #
457
459
  # == What's Here
458
460
  #
461
+ # First, what's elsewhere. Class Gem::Net::HTTP:
462
+ #
463
+ # - Inherits from {class Object}[https://docs.ruby-lang.org/en/master/Object.html#class-Object-label-What-27s+Here].
464
+ #
459
465
  # This is a categorized summary of methods and attributes.
460
466
  #
461
467
  # === \Gem::Net::HTTP Objects
@@ -520,6 +526,8 @@ module Gem::Net #:nodoc:
520
526
  # Sends a POST request with form data and returns a response object.
521
527
  # - {::post}[rdoc-ref:Gem::Net::HTTP.post]:
522
528
  # Sends a POST request with data and returns a response object.
529
+ # - {::put}[rdoc-ref:Gem::Net::HTTP.put]:
530
+ # Sends a PUT request with data and returns a response object.
523
531
  # - {#copy}[rdoc-ref:Gem::Net::HTTP#copy]:
524
532
  # Sends a COPY request and returns a response object.
525
533
  # - {#delete}[rdoc-ref:Gem::Net::HTTP#delete]:
@@ -722,7 +730,7 @@ module Gem::Net #:nodoc:
722
730
  class HTTP < Protocol
723
731
 
724
732
  # :stopdoc:
725
- VERSION = "0.4.1"
733
+ VERSION = "0.6.0"
726
734
  HTTPVersion = '1.1'
727
735
  begin
728
736
  require 'zlib'
@@ -889,6 +897,39 @@ module Gem::Net #:nodoc:
889
897
  }
890
898
  end
891
899
 
900
+ # Sends a PUT request to the server; returns a Gem::Net::HTTPResponse object.
901
+ #
902
+ # Argument +url+ must be a URL;
903
+ # argument +data+ must be a string:
904
+ #
905
+ # _uri = uri.dup
906
+ # _uri.path = '/posts'
907
+ # data = '{"title": "foo", "body": "bar", "userId": 1}'
908
+ # headers = {'content-type': 'application/json'}
909
+ # res = Gem::Net::HTTP.put(_uri, data, headers) # => #<Gem::Net::HTTPCreated 201 Created readbody=true>
910
+ # puts res.body
911
+ #
912
+ # Output:
913
+ #
914
+ # {
915
+ # "title": "foo",
916
+ # "body": "bar",
917
+ # "userId": 1,
918
+ # "id": 101
919
+ # }
920
+ #
921
+ # Related:
922
+ #
923
+ # - Gem::Net::HTTP::Put: request class for \HTTP method +PUT+.
924
+ # - Gem::Net::HTTP#put: convenience method for \HTTP method +PUT+.
925
+ #
926
+ def HTTP.put(url, data, header = nil)
927
+ start(url.hostname, url.port,
928
+ :use_ssl => url.scheme == 'https' ) {|http|
929
+ http.put(url, data, header)
930
+ }
931
+ end
932
+
892
933
  #
893
934
  # \HTTP session management
894
935
  #
@@ -1062,7 +1103,7 @@ module Gem::Net #:nodoc:
1062
1103
  # For proxy-defining arguments +p_addr+ through +p_no_proxy+,
1063
1104
  # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
1064
1105
  #
1065
- def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil)
1106
+ def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil, p_use_ssl = nil)
1066
1107
  http = super address, port
1067
1108
 
1068
1109
  if proxy_class? then # from Gem::Net::HTTP::Proxy()
@@ -1071,6 +1112,7 @@ module Gem::Net #:nodoc:
1071
1112
  http.proxy_port = @proxy_port
1072
1113
  http.proxy_user = @proxy_user
1073
1114
  http.proxy_pass = @proxy_pass
1115
+ http.proxy_use_ssl = @proxy_use_ssl
1074
1116
  elsif p_addr == :ENV then
1075
1117
  http.proxy_from_env = true
1076
1118
  else
@@ -1082,34 +1124,67 @@ module Gem::Net #:nodoc:
1082
1124
  http.proxy_port = p_port || default_port
1083
1125
  http.proxy_user = p_user
1084
1126
  http.proxy_pass = p_pass
1127
+ http.proxy_use_ssl = p_use_ssl
1085
1128
  end
1086
1129
 
1087
1130
  http
1088
1131
  end
1089
1132
 
1133
+ class << HTTP
1134
+ # Allows to set the default configuration that will be used
1135
+ # when creating a new connection.
1136
+ #
1137
+ # Example:
1138
+ #
1139
+ # Gem::Net::HTTP.default_configuration = {
1140
+ # read_timeout: 1,
1141
+ # write_timeout: 1
1142
+ # }
1143
+ # http = Gem::Net::HTTP.new(hostname)
1144
+ # http.open_timeout # => 60
1145
+ # http.read_timeout # => 1
1146
+ # http.write_timeout # => 1
1147
+ #
1148
+ attr_accessor :default_configuration
1149
+ end
1150
+
1090
1151
  # Creates a new \Gem::Net::HTTP object for the specified server address,
1091
1152
  # without opening the TCP connection or initializing the \HTTP session.
1092
1153
  # The +address+ should be a DNS hostname or IP address.
1093
1154
  def initialize(address, port = nil) # :nodoc:
1155
+ defaults = {
1156
+ keep_alive_timeout: 2,
1157
+ close_on_empty_response: false,
1158
+ open_timeout: 60,
1159
+ read_timeout: 60,
1160
+ write_timeout: 60,
1161
+ continue_timeout: nil,
1162
+ max_retries: 1,
1163
+ debug_output: nil,
1164
+ response_body_encoding: false,
1165
+ ignore_eof: true
1166
+ }
1167
+ options = defaults.merge(self.class.default_configuration || {})
1168
+
1094
1169
  @address = address
1095
1170
  @port = (port || HTTP.default_port)
1096
1171
  @ipaddr = nil
1097
1172
  @local_host = nil
1098
1173
  @local_port = nil
1099
1174
  @curr_http_version = HTTPVersion
1100
- @keep_alive_timeout = 2
1175
+ @keep_alive_timeout = options[:keep_alive_timeout]
1101
1176
  @last_communicated = nil
1102
- @close_on_empty_response = false
1177
+ @close_on_empty_response = options[:close_on_empty_response]
1103
1178
  @socket = nil
1104
1179
  @started = false
1105
- @open_timeout = 60
1106
- @read_timeout = 60
1107
- @write_timeout = 60
1108
- @continue_timeout = nil
1109
- @max_retries = 1
1110
- @debug_output = nil
1111
- @response_body_encoding = false
1112
- @ignore_eof = true
1180
+ @open_timeout = options[:open_timeout]
1181
+ @read_timeout = options[:read_timeout]
1182
+ @write_timeout = options[:write_timeout]
1183
+ @continue_timeout = options[:continue_timeout]
1184
+ @max_retries = options[:max_retries]
1185
+ @debug_output = options[:debug_output]
1186
+ @response_body_encoding = options[:response_body_encoding]
1187
+ @ignore_eof = options[:ignore_eof]
1113
1188
 
1114
1189
  @proxy_from_env = false
1115
1190
  @proxy_uri = nil
@@ -1117,6 +1192,7 @@ module Gem::Net #:nodoc:
1117
1192
  @proxy_port = nil
1118
1193
  @proxy_user = nil
1119
1194
  @proxy_pass = nil
1195
+ @proxy_use_ssl = nil
1120
1196
 
1121
1197
  @use_ssl = false
1122
1198
  @ssl_context = nil
@@ -1251,6 +1327,7 @@ module Gem::Net #:nodoc:
1251
1327
  # Sets the proxy password;
1252
1328
  # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
1253
1329
  attr_writer :proxy_pass
1330
+ attr_writer :proxy_use_ssl
1254
1331
 
1255
1332
  # Returns the IP address for the connection.
1256
1333
  #
@@ -1440,23 +1517,6 @@ module Gem::Net #:nodoc:
1440
1517
  @use_ssl = flag
1441
1518
  end
1442
1519
 
1443
- SSL_IVNAMES = [
1444
- :@ca_file,
1445
- :@ca_path,
1446
- :@cert,
1447
- :@cert_store,
1448
- :@ciphers,
1449
- :@extra_chain_cert,
1450
- :@key,
1451
- :@ssl_timeout,
1452
- :@ssl_version,
1453
- :@min_version,
1454
- :@max_version,
1455
- :@verify_callback,
1456
- :@verify_depth,
1457
- :@verify_mode,
1458
- :@verify_hostname,
1459
- ] # :nodoc:
1460
1520
  SSL_ATTRIBUTES = [
1461
1521
  :ca_file,
1462
1522
  :ca_path,
@@ -1475,6 +1535,8 @@ module Gem::Net #:nodoc:
1475
1535
  :verify_hostname,
1476
1536
  ] # :nodoc:
1477
1537
 
1538
+ SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym } # :nodoc:
1539
+
1478
1540
  # Sets or returns the path to a CA certification file in PEM format.
1479
1541
  attr_accessor :ca_file
1480
1542
 
@@ -1610,7 +1672,13 @@ module Gem::Net #:nodoc:
1610
1672
  debug "opened"
1611
1673
  if use_ssl?
1612
1674
  if proxy?
1613
- plain_sock = BufferedIO.new(s, read_timeout: @read_timeout,
1675
+ if @proxy_use_ssl
1676
+ proxy_sock = OpenSSL::SSL::SSLSocket.new(s)
1677
+ ssl_socket_connect(proxy_sock, @open_timeout)
1678
+ else
1679
+ proxy_sock = s
1680
+ end
1681
+ proxy_sock = BufferedIO.new(proxy_sock, read_timeout: @read_timeout,
1614
1682
  write_timeout: @write_timeout,
1615
1683
  continue_timeout: @continue_timeout,
1616
1684
  debug_output: @debug_output)
@@ -1621,8 +1689,8 @@ module Gem::Net #:nodoc:
1621
1689
  buf << "Proxy-Authorization: Basic #{credential}\r\n"
1622
1690
  end
1623
1691
  buf << "\r\n"
1624
- plain_sock.write(buf)
1625
- HTTPResponse.read_new(plain_sock).value
1692
+ proxy_sock.write(buf)
1693
+ HTTPResponse.read_new(proxy_sock).value
1626
1694
  # assuming nothing left in buffers after successful CONNECT response
1627
1695
  end
1628
1696
 
@@ -1730,13 +1798,14 @@ module Gem::Net #:nodoc:
1730
1798
  @proxy_port = nil
1731
1799
  @proxy_user = nil
1732
1800
  @proxy_pass = nil
1801
+ @proxy_use_ssl = nil
1733
1802
 
1734
1803
  # Creates an \HTTP proxy class which behaves like \Gem::Net::HTTP, but
1735
1804
  # performs all access via the specified proxy.
1736
1805
  #
1737
1806
  # This class is obsolete. You may pass these same parameters directly to
1738
1807
  # \Gem::Net::HTTP.new. See Gem::Net::HTTP.new for details of the arguments.
1739
- def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil) #:nodoc:
1808
+ def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_use_ssl = nil) #:nodoc:
1740
1809
  return self unless p_addr
1741
1810
 
1742
1811
  Class.new(self) {
@@ -1754,6 +1823,7 @@ module Gem::Net #:nodoc:
1754
1823
 
1755
1824
  @proxy_user = p_user
1756
1825
  @proxy_pass = p_pass
1826
+ @proxy_use_ssl = p_use_ssl
1757
1827
  }
1758
1828
  end
1759
1829
 
@@ -1778,6 +1848,9 @@ module Gem::Net #:nodoc:
1778
1848
  # Returns the password for accessing the proxy, or +nil+ if none;
1779
1849
  # see Gem::Net::HTTP@Proxy+Server.
1780
1850
  attr_reader :proxy_pass
1851
+
1852
+ # Use SSL when talking to the proxy. If Gem::Net::HTTP does not use a proxy, nil.
1853
+ attr_reader :proxy_use_ssl
1781
1854
  end
1782
1855
 
1783
1856
  # Returns +true+ if a proxy server is defined, +false+ otherwise;
@@ -2012,6 +2085,11 @@ module Gem::Net #:nodoc:
2012
2085
  # http = Gem::Net::HTTP.new(hostname)
2013
2086
  # http.put('/todos/1', data) # => #<Gem::Net::HTTPOK 200 OK readbody=true>
2014
2087
  #
2088
+ # Related:
2089
+ #
2090
+ # - Gem::Net::HTTP::Put: request class for \HTTP method PUT.
2091
+ # - Gem::Net::HTTP.put: sends PUT request, returns response body.
2092
+ #
2015
2093
  def put(path, data, initheader = nil)
2016
2094
  request(Put.new(path, initheader), data)
2017
2095
  end
@@ -2350,7 +2428,10 @@ module Gem::Net #:nodoc:
2350
2428
  res
2351
2429
  }
2352
2430
  res.reading_body(@socket, req.response_body_permitted?) {
2353
- yield res if block_given?
2431
+ if block_given?
2432
+ count = max_retries # Don't restart in the middle of a download
2433
+ yield res
2434
+ end
2354
2435
  }
2355
2436
  rescue Gem::Net::OpenTimeout
2356
2437
  raise
@@ -2478,6 +2559,11 @@ module Gem::Net #:nodoc:
2478
2559
  alias_method :D, :debug
2479
2560
  end
2480
2561
 
2562
+ # for backward compatibility until Ruby 3.5
2563
+ # https://bugs.ruby-lang.org/issues/20900
2564
+ # https://github.com/bblimke/webmock/pull/1081
2565
+ HTTPSession = HTTP
2566
+ deprecate_constant :HTTPSession
2481
2567
  end
2482
2568
 
2483
2569
  require_relative 'http/exceptions'
@@ -2492,5 +2578,3 @@ require_relative 'http/response'
2492
2578
  require_relative 'http/responses'
2493
2579
 
2494
2580
  require_relative 'http/proxy_delta'
2495
-
2496
- require_relative 'http/backward'
@@ -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