rubygems-update 3.5.5 → 3.5.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +107 -0
  3. data/Manifest.txt +84 -64
  4. data/POLICIES.md +75 -6
  5. data/bundler/CHANGELOG.md +75 -0
  6. data/bundler/lib/bundler/build_metadata.rb +2 -2
  7. data/bundler/lib/bundler/cli/binstubs.rb +1 -1
  8. data/bundler/lib/bundler/cli/gem.rb +1 -1
  9. data/bundler/lib/bundler/cli/lock.rb +5 -4
  10. data/bundler/lib/bundler/cli/plugin.rb +3 -2
  11. data/bundler/lib/bundler/cli.rb +7 -24
  12. data/bundler/lib/bundler/definition.rb +111 -56
  13. data/bundler/lib/bundler/dependency.rb +2 -1
  14. data/bundler/lib/bundler/dsl.rb +16 -1
  15. data/bundler/lib/bundler/environment_preserver.rb +5 -23
  16. data/bundler/lib/bundler/fetcher/downloader.rb +1 -1
  17. data/bundler/lib/bundler/fetcher.rb +2 -2
  18. data/bundler/lib/bundler/gem_version_promoter.rb +42 -38
  19. data/bundler/lib/bundler/injector.rb +3 -2
  20. data/bundler/lib/bundler/installer.rb +2 -2
  21. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  22. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  23. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  24. data/bundler/lib/bundler/man/bundle-check.1 +3 -1
  25. data/bundler/lib/bundler/man/bundle-check.1.ronn +3 -0
  26. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  27. data/bundler/lib/bundler/man/bundle-config.1 +1 -3
  28. data/bundler/lib/bundler/man/bundle-config.1.ronn +0 -3
  29. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  33. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  34. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-install.1 +3 -3
  38. data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
  39. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  40. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-plugin.1 +7 -4
  45. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +7 -3
  46. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  47. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  48. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  49. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle.1 +1 -1
  53. data/bundler/lib/bundler/man/gemfile.5 +3 -3
  54. data/bundler/lib/bundler/man/gemfile.5.ronn +2 -2
  55. data/bundler/lib/bundler/mirror.rb +3 -3
  56. data/bundler/lib/bundler/plugin/api/source.rb +2 -2
  57. data/bundler/lib/bundler/plugin/installer/path.rb +18 -0
  58. data/bundler/lib/bundler/plugin/installer.rb +36 -16
  59. data/bundler/lib/bundler/plugin/source_list.rb +4 -4
  60. data/bundler/lib/bundler/resolver/candidate.rb +1 -1
  61. data/bundler/lib/bundler/resolver.rb +54 -24
  62. data/bundler/lib/bundler/rubygems_ext.rb +12 -0
  63. data/bundler/lib/bundler/runtime.rb +1 -1
  64. data/bundler/lib/bundler/self_manager.rb +1 -1
  65. data/bundler/lib/bundler/settings.rb +14 -12
  66. data/bundler/lib/bundler/setup.rb +3 -0
  67. data/bundler/lib/bundler/source/git/git_proxy.rb +1 -1
  68. data/bundler/lib/bundler/source/git.rb +1 -1
  69. data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
  70. data/bundler/lib/bundler/source/rubygems.rb +7 -20
  71. data/bundler/lib/bundler/source_list.rb +17 -4
  72. data/bundler/lib/bundler/spec_set.rb +1 -1
  73. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -3
  74. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
  75. data/bundler/lib/bundler/uri_credentials_filter.rb +2 -2
  76. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +22 -22
  77. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +1 -0
  78. data/bundler/lib/bundler/vendored_net_http.rb +7 -3
  79. data/bundler/lib/bundler/vendored_timeout.rb +7 -3
  80. data/bundler/lib/bundler/vendored_uri.rb +18 -1
  81. data/bundler/lib/bundler/version.rb +1 -1
  82. data/bundler/lib/bundler/yaml_serializer.rb +12 -0
  83. data/bundler/lib/bundler.rb +23 -2
  84. data/lib/rubygems/command.rb +1 -1
  85. data/lib/rubygems/command_manager.rb +2 -1
  86. data/lib/rubygems/commands/build_command.rb +2 -11
  87. data/lib/rubygems/commands/help_command.rb +2 -2
  88. data/lib/rubygems/commands/rdoc_command.rb +1 -8
  89. data/lib/rubygems/commands/rebuild_command.rb +264 -0
  90. data/lib/rubygems/commands/sources_command.rb +2 -2
  91. data/lib/rubygems/commands/update_command.rb +8 -9
  92. data/lib/rubygems/config_file.rb +20 -8
  93. data/lib/rubygems/defaults.rb +4 -4
  94. data/lib/rubygems/dependency.rb +2 -2
  95. data/lib/rubygems/dependency_list.rb +1 -1
  96. data/lib/rubygems/deprecate.rb +79 -77
  97. data/lib/rubygems/ext/cargo_builder.rb +1 -1
  98. data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +1 -1
  99. data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +3 -1
  100. data/lib/rubygems/gemcutter_utilities.rb +40 -23
  101. data/lib/rubygems/gemspec_helpers.rb +19 -0
  102. data/lib/rubygems/local_remote_options.rb +6 -6
  103. data/lib/rubygems/package.rb +13 -7
  104. data/lib/rubygems/remote_fetcher.rb +3 -3
  105. data/lib/rubygems/request.rb +5 -5
  106. data/lib/rubygems/request_set.rb +1 -1
  107. data/lib/rubygems/requirement.rb +5 -0
  108. data/lib/rubygems/resolver/api_set.rb +1 -1
  109. data/lib/rubygems/resolver/best_set.rb +1 -1
  110. data/lib/rubygems/resolver/spec_specification.rb +7 -0
  111. data/lib/rubygems/resolver.rb +5 -5
  112. data/lib/rubygems/s3_uri_signer.rb +3 -3
  113. data/lib/rubygems/safe_yaml.rb +10 -1
  114. data/lib/rubygems/security.rb +1 -1
  115. data/lib/rubygems/source/git.rb +2 -2
  116. data/lib/rubygems/source_list.rb +1 -1
  117. data/lib/rubygems/specification.rb +6 -6
  118. data/lib/rubygems/specification_policy.rb +15 -7
  119. data/lib/rubygems/uri.rb +6 -6
  120. data/lib/rubygems/util/licenses.rb +43 -0
  121. data/lib/rubygems/util.rb +1 -1
  122. data/lib/rubygems/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
  123. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/delegates/specification_provider.rb +11 -11
  124. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/action.rb +1 -1
  125. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  126. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  127. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  128. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  129. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/log.rb +1 -1
  130. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  131. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  132. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/vertex.rb +1 -1
  133. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  134. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/errors.rb +1 -1
  135. data/lib/rubygems/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
  136. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/specification_provider.rb +2 -2
  137. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/ui.rb +1 -1
  138. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolution.rb +3 -3
  139. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolver.rb +1 -1
  140. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/state.rb +1 -1
  141. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo.rb +2 -2
  142. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/generic_request.rb +9 -9
  143. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/header.rb +2 -2
  144. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/request.rb +3 -3
  145. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/requests.rb +30 -30
  146. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/response.rb +2 -2
  147. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/responses.rb +6 -6
  148. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/status.rb +1 -1
  149. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http.rb +15 -15
  150. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/https.rb +1 -1
  151. data/lib/rubygems/vendor/optparse/lib/optparse/uri.rb +7 -0
  152. data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse.rb +11 -11
  153. data/lib/rubygems/{timeout → vendor/timeout}/lib/timeout.rb +1 -1
  154. data/lib/rubygems/{tsort → vendor/tsort}/lib/tsort.rb +2 -2
  155. data/lib/rubygems/vendor/uri/.document +1 -0
  156. data/lib/rubygems/vendor/uri/LICENSE.txt +22 -0
  157. data/lib/rubygems/vendor/uri/lib/uri/common.rb +853 -0
  158. data/lib/rubygems/vendor/uri/lib/uri/file.rb +100 -0
  159. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +267 -0
  160. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +1588 -0
  161. data/lib/rubygems/vendor/uri/lib/uri/http.rb +125 -0
  162. data/lib/rubygems/vendor/uri/lib/uri/https.rb +23 -0
  163. data/lib/rubygems/vendor/uri/lib/uri/ldap.rb +261 -0
  164. data/lib/rubygems/vendor/uri/lib/uri/ldaps.rb +22 -0
  165. data/lib/rubygems/vendor/uri/lib/uri/mailto.rb +293 -0
  166. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
  167. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +183 -0
  168. data/lib/rubygems/vendor/uri/lib/uri/version.rb +6 -0
  169. data/lib/rubygems/vendor/uri/lib/uri/ws.rb +83 -0
  170. data/lib/rubygems/vendor/uri/lib/uri/wss.rb +23 -0
  171. data/lib/rubygems/vendor/uri/lib/uri.rb +104 -0
  172. data/lib/rubygems/vendored_molinillo.rb +3 -0
  173. data/lib/rubygems/vendored_net_http.rb +5 -0
  174. data/lib/rubygems/vendored_optparse.rb +3 -0
  175. data/lib/rubygems/vendored_timeout.rb +5 -0
  176. data/lib/rubygems/vendored_tsort.rb +3 -0
  177. data/lib/rubygems/yaml_serializer.rb +12 -0
  178. data/lib/rubygems.rb +2 -2
  179. data/rubygems-update.gemspec +7 -2
  180. metadata +90 -67
  181. data/lib/rubygems/net/http.rb +0 -3
  182. data/lib/rubygems/optparse/lib/optparse/uri.rb +0 -7
  183. data/lib/rubygems/optparse.rb +0 -3
  184. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  185. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  186. data/lib/rubygems/resolver/molinillo.rb +0 -3
  187. data/lib/rubygems/timeout.rb +0 -3
  188. data/lib/rubygems/tsort.rb +0 -3
  189. /data/lib/rubygems/{net-http → vendor/molinillo}/.document +0 -0
  190. /data/lib/rubygems/{resolver → vendor}/molinillo/LICENSE +0 -0
  191. /data/lib/rubygems/{net-protocol → vendor/net-http}/.document +0 -0
  192. /data/lib/rubygems/{net-http → vendor/net-http}/LICENSE.txt +0 -0
  193. /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/backward.rb +0 -0
  194. /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/exceptions.rb +0 -0
  195. /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/proxy_delta.rb +0 -0
  196. /data/lib/rubygems/{optparse → vendor/net-protocol}/.document +0 -0
  197. /data/lib/rubygems/{net-protocol → vendor/net-protocol}/LICENSE.txt +0 -0
  198. /data/lib/rubygems/{net-protocol → vendor/net-protocol}/lib/net/protocol.rb +0 -0
  199. /data/lib/rubygems/{resolv → vendor/optparse}/.document +0 -0
  200. /data/lib/rubygems/{optparse → vendor/optparse}/COPYING +0 -0
  201. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optionparser.rb +0 -0
  202. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/ac.rb +0 -0
  203. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/date.rb +0 -0
  204. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/kwargs.rb +0 -0
  205. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/shellwords.rb +0 -0
  206. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/time.rb +0 -0
  207. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/version.rb +0 -0
  208. /data/lib/rubygems/{resolver/molinillo → vendor/resolv}/.document +0 -0
  209. /data/lib/rubygems/{resolv → vendor/resolv}/LICENSE.txt +0 -0
  210. /data/lib/rubygems/{resolv → vendor/resolv}/lib/resolv.rb +0 -0
  211. /data/lib/rubygems/{timeout → vendor/timeout}/.document +0 -0
  212. /data/lib/rubygems/{timeout → vendor/timeout}/LICENSE.txt +0 -0
  213. /data/lib/rubygems/{tsort → vendor/tsort}/.document +0 -0
  214. /data/lib/rubygems/{tsort → vendor/tsort}/LICENSE.txt +0 -0
@@ -0,0 +1,853 @@
1
+ # frozen_string_literal: true
2
+ #--
3
+ # = uri/common.rb
4
+ #
5
+ # Author:: Akira Yamada <akira@ruby-lang.org>
6
+ # License::
7
+ # You can redistribute it and/or modify it under the same term as Ruby.
8
+ #
9
+ # See Gem::URI for general documentation
10
+ #
11
+
12
+ require_relative "rfc2396_parser"
13
+ require_relative "rfc3986_parser"
14
+
15
+ module Gem::URI
16
+ include RFC2396_REGEXP
17
+
18
+ REGEXP = RFC2396_REGEXP
19
+ Parser = RFC2396_Parser
20
+ RFC3986_PARSER = RFC3986_Parser.new
21
+ Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
22
+
23
+ # Gem::URI::Parser.new
24
+ DEFAULT_PARSER = Parser.new
25
+ DEFAULT_PARSER.pattern.each_pair do |sym, str|
26
+ unless REGEXP::PATTERN.const_defined?(sym)
27
+ REGEXP::PATTERN.const_set(sym, str)
28
+ end
29
+ end
30
+ DEFAULT_PARSER.regexp.each_pair do |sym, str|
31
+ const_set(sym, str)
32
+ end
33
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
34
+
35
+ module Util # :nodoc:
36
+ def make_components_hash(klass, array_hash)
37
+ tmp = {}
38
+ if array_hash.kind_of?(Array) &&
39
+ array_hash.size == klass.component.size - 1
40
+ klass.component[1..-1].each_index do |i|
41
+ begin
42
+ tmp[klass.component[i + 1]] = array_hash[i].clone
43
+ rescue TypeError
44
+ tmp[klass.component[i + 1]] = array_hash[i]
45
+ end
46
+ end
47
+
48
+ elsif array_hash.kind_of?(Hash)
49
+ array_hash.each do |key, value|
50
+ begin
51
+ tmp[key] = value.clone
52
+ rescue TypeError
53
+ tmp[key] = value
54
+ end
55
+ end
56
+ else
57
+ raise ArgumentError,
58
+ "expected Array of or Hash of components of #{klass} (#{klass.component[1..-1].join(', ')})"
59
+ end
60
+ tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase
61
+
62
+ return tmp
63
+ end
64
+ module_function :make_components_hash
65
+ end
66
+
67
+ module Schemes
68
+ end
69
+ private_constant :Schemes
70
+
71
+ # Registers the given +klass+ as the class to be instantiated
72
+ # when parsing a \Gem::URI with the given +scheme+:
73
+ #
74
+ # Gem::URI.register_scheme('MS_SEARCH', Gem::URI::Generic) # => Gem::URI::Generic
75
+ # Gem::URI.scheme_list['MS_SEARCH'] # => Gem::URI::Generic
76
+ #
77
+ # Note that after calling String#upcase on +scheme+, it must be a valid
78
+ # constant name.
79
+ def self.register_scheme(scheme, klass)
80
+ Schemes.const_set(scheme.to_s.upcase, klass)
81
+ end
82
+
83
+ # Returns a hash of the defined schemes:
84
+ #
85
+ # Gem::URI.scheme_list
86
+ # # =>
87
+ # {"MAILTO"=>Gem::URI::MailTo,
88
+ # "LDAPS"=>Gem::URI::LDAPS,
89
+ # "WS"=>Gem::URI::WS,
90
+ # "HTTP"=>Gem::URI::HTTP,
91
+ # "HTTPS"=>Gem::URI::HTTPS,
92
+ # "LDAP"=>Gem::URI::LDAP,
93
+ # "FILE"=>Gem::URI::File,
94
+ # "FTP"=>Gem::URI::FTP}
95
+ #
96
+ # Related: Gem::URI.register_scheme.
97
+ def self.scheme_list
98
+ Schemes.constants.map { |name|
99
+ [name.to_s.upcase, Schemes.const_get(name)]
100
+ }.to_h
101
+ end
102
+
103
+ INITIAL_SCHEMES = scheme_list
104
+ private_constant :INITIAL_SCHEMES
105
+ Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
106
+
107
+ # Returns a new object constructed from the given +scheme+, +arguments+,
108
+ # and +default+:
109
+ #
110
+ # - The new object is an instance of <tt>Gem::URI.scheme_list[scheme.upcase]</tt>.
111
+ # - The object is initialized by calling the class initializer
112
+ # using +scheme+ and +arguments+.
113
+ # See Gem::URI::Generic.new.
114
+ #
115
+ # Examples:
116
+ #
117
+ # values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
118
+ # Gem::URI.for('https', *values)
119
+ # # => #<Gem::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
120
+ # Gem::URI.for('foo', *values, default: Gem::URI::HTTP)
121
+ # # => #<Gem::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
122
+ #
123
+ def self.for(scheme, *arguments, default: Generic)
124
+ const_name = scheme.to_s.upcase
125
+
126
+ uri_class = INITIAL_SCHEMES[const_name]
127
+ uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
128
+ Schemes.const_get(const_name, false)
129
+ end
130
+ uri_class ||= default
131
+
132
+ return uri_class.new(scheme, *arguments)
133
+ end
134
+
135
+ #
136
+ # Base class for all Gem::URI exceptions.
137
+ #
138
+ class Error < StandardError; end
139
+ #
140
+ # Not a Gem::URI.
141
+ #
142
+ class InvalidURIError < Error; end
143
+ #
144
+ # Not a Gem::URI component.
145
+ #
146
+ class InvalidComponentError < Error; end
147
+ #
148
+ # Gem::URI is valid, bad usage is not.
149
+ #
150
+ class BadURIError < Error; end
151
+
152
+ # Returns a 9-element array representing the parts of the \Gem::URI
153
+ # formed from the string +uri+;
154
+ # each array element is a string or +nil+:
155
+ #
156
+ # names = %w[scheme userinfo host port registry path opaque query fragment]
157
+ # values = Gem::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
158
+ # names.zip(values)
159
+ # # =>
160
+ # [["scheme", "https"],
161
+ # ["userinfo", "john.doe"],
162
+ # ["host", "www.example.com"],
163
+ # ["port", "123"],
164
+ # ["registry", nil],
165
+ # ["path", "/forum/questions/"],
166
+ # ["opaque", nil],
167
+ # ["query", "tag=networking&order=newest"],
168
+ # ["fragment", "top"]]
169
+ #
170
+ def self.split(uri)
171
+ RFC3986_PARSER.split(uri)
172
+ end
173
+
174
+ # Returns a new \Gem::URI object constructed from the given string +uri+:
175
+ #
176
+ # Gem::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
177
+ # # => #<Gem::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
178
+ # Gem::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
179
+ # # => #<Gem::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
180
+ #
181
+ # It's recommended to first ::escape string +uri+
182
+ # if it may contain invalid Gem::URI characters.
183
+ #
184
+ def self.parse(uri)
185
+ RFC3986_PARSER.parse(uri)
186
+ end
187
+
188
+ # Merges the given Gem::URI strings +str+
189
+ # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
190
+ #
191
+ # Each string in +str+ is converted to an
192
+ # {RFC3986 Gem::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
193
+ #
194
+ # Examples:
195
+ #
196
+ # Gem::URI.join("http://example.com/","main.rbx")
197
+ # # => #<Gem::URI::HTTP http://example.com/main.rbx>
198
+ #
199
+ # Gem::URI.join('http://example.com', 'foo')
200
+ # # => #<Gem::URI::HTTP http://example.com/foo>
201
+ #
202
+ # Gem::URI.join('http://example.com', '/foo', '/bar')
203
+ # # => #<Gem::URI::HTTP http://example.com/bar>
204
+ #
205
+ # Gem::URI.join('http://example.com', '/foo', 'bar')
206
+ # # => #<Gem::URI::HTTP http://example.com/bar>
207
+ #
208
+ # Gem::URI.join('http://example.com', '/foo/', 'bar')
209
+ # # => #<Gem::URI::HTTP http://example.com/foo/bar>
210
+ #
211
+ def self.join(*str)
212
+ RFC3986_PARSER.join(*str)
213
+ end
214
+
215
+ #
216
+ # == Synopsis
217
+ #
218
+ # Gem::URI::extract(str[, schemes][,&blk])
219
+ #
220
+ # == Args
221
+ #
222
+ # +str+::
223
+ # String to extract URIs from.
224
+ # +schemes+::
225
+ # Limit Gem::URI matching to specific schemes.
226
+ #
227
+ # == Description
228
+ #
229
+ # Extracts URIs from a string. If block given, iterates through all matched URIs.
230
+ # Returns nil if block given or array with matches.
231
+ #
232
+ # == Usage
233
+ #
234
+ # require "rubygems/vendor/uri/lib/uri"
235
+ #
236
+ # Gem::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
237
+ # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
238
+ #
239
+ def self.extract(str, schemes = nil, &block) # :nodoc:
240
+ warn "Gem::URI.extract is obsolete", uplevel: 1 if $VERBOSE
241
+ DEFAULT_PARSER.extract(str, schemes, &block)
242
+ end
243
+
244
+ #
245
+ # == Synopsis
246
+ #
247
+ # Gem::URI::regexp([match_schemes])
248
+ #
249
+ # == Args
250
+ #
251
+ # +match_schemes+::
252
+ # Array of schemes. If given, resulting regexp matches to URIs
253
+ # whose scheme is one of the match_schemes.
254
+ #
255
+ # == Description
256
+ #
257
+ # Returns a Regexp object which matches to Gem::URI-like strings.
258
+ # The Regexp object returned by this method includes arbitrary
259
+ # number of capture group (parentheses). Never rely on its number.
260
+ #
261
+ # == Usage
262
+ #
263
+ # require 'rubygems/vendor/uri/lib/uri'
264
+ #
265
+ # # extract first Gem::URI from html_string
266
+ # html_string.slice(Gem::URI.regexp)
267
+ #
268
+ # # remove ftp URIs
269
+ # html_string.sub(Gem::URI.regexp(['ftp']), '')
270
+ #
271
+ # # You should not rely on the number of parentheses
272
+ # html_string.scan(Gem::URI.regexp) do |*matches|
273
+ # p $&
274
+ # end
275
+ #
276
+ def self.regexp(schemes = nil)# :nodoc:
277
+ warn "Gem::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
278
+ DEFAULT_PARSER.make_regexp(schemes)
279
+ end
280
+
281
+ TBLENCWWWCOMP_ = {} # :nodoc:
282
+ 256.times do |i|
283
+ TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
284
+ end
285
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
286
+ TBLENCWWWCOMP_[' '] = '+'
287
+ TBLENCWWWCOMP_.freeze
288
+ TBLDECWWWCOMP_ = {} # :nodoc:
289
+ 256.times do |i|
290
+ h, l = i>>4, i&15
291
+ TBLDECWWWCOMP_[-('%%%X%X' % [h, l])] = -i.chr
292
+ TBLDECWWWCOMP_[-('%%%x%X' % [h, l])] = -i.chr
293
+ TBLDECWWWCOMP_[-('%%%X%x' % [h, l])] = -i.chr
294
+ TBLDECWWWCOMP_[-('%%%x%x' % [h, l])] = -i.chr
295
+ end
296
+ TBLDECWWWCOMP_['+'] = ' '
297
+ TBLDECWWWCOMP_.freeze
298
+
299
+ # Returns a URL-encoded string derived from the given string +str+.
300
+ #
301
+ # The returned string:
302
+ #
303
+ # - Preserves:
304
+ #
305
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
306
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
307
+ # and <tt>'0'..'9'</tt>.
308
+ #
309
+ # Example:
310
+ #
311
+ # Gem::URI.encode_www_form_component('*.-_azAZ09')
312
+ # # => "*.-_azAZ09"
313
+ #
314
+ # - Converts:
315
+ #
316
+ # - Character <tt>' '</tt> to character <tt>'+'</tt>.
317
+ # - Any other character to "percent notation";
318
+ # the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
319
+ #
320
+ # Example:
321
+ #
322
+ # Gem::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
323
+ # # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
324
+ #
325
+ # Encoding:
326
+ #
327
+ # - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
328
+ # - Otherwise +str+ is converted first to Encoding::UTF_8
329
+ # (with suitable character replacements),
330
+ # and then to encoding +enc+.
331
+ #
332
+ # In either case, the returned string has forced encoding Encoding::US_ASCII.
333
+ #
334
+ # Related: Gem::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
335
+ def self.encode_www_form_component(str, enc=nil)
336
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
337
+ end
338
+
339
+ # Returns a string decoded from the given \URL-encoded string +str+.
340
+ #
341
+ # The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
342
+ # then decoded (as below), and finally force-encoded to the given encoding +enc+.
343
+ #
344
+ # The returned string:
345
+ #
346
+ # - Preserves:
347
+ #
348
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
349
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
350
+ # and <tt>'0'..'9'</tt>.
351
+ #
352
+ # Example:
353
+ #
354
+ # Gem::URI.decode_www_form_component('*.-_azAZ09')
355
+ # # => "*.-_azAZ09"
356
+ #
357
+ # - Converts:
358
+ #
359
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
360
+ # - Each "percent notation" to an ASCII character.
361
+ #
362
+ # Example:
363
+ #
364
+ # Gem::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
365
+ # # => "Here are some punctuation characters: ,;?:"
366
+ #
367
+ # Related: Gem::URI.decode_uri_component (preserves <tt>'+'</tt>).
368
+ def self.decode_www_form_component(str, enc=Encoding::UTF_8)
369
+ _decode_uri_component(/\+|%\h\h/, str, enc)
370
+ end
371
+
372
+ # Like Gem::URI.encode_www_form_component, except that <tt>' '</tt> (space)
373
+ # is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
374
+ def self.encode_uri_component(str, enc=nil)
375
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
376
+ end
377
+
378
+ # Like Gem::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
379
+ def self.decode_uri_component(str, enc=Encoding::UTF_8)
380
+ _decode_uri_component(/%\h\h/, str, enc)
381
+ end
382
+
383
+ def self._encode_uri_component(regexp, table, str, enc)
384
+ str = str.to_s.dup
385
+ if str.encoding != Encoding::ASCII_8BIT
386
+ if enc && enc != Encoding::ASCII_8BIT
387
+ str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
388
+ str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
389
+ end
390
+ str.force_encoding(Encoding::ASCII_8BIT)
391
+ end
392
+ str.gsub!(regexp, table)
393
+ str.force_encoding(Encoding::US_ASCII)
394
+ end
395
+ private_class_method :_encode_uri_component
396
+
397
+ def self._decode_uri_component(regexp, str, enc)
398
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
399
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
400
+ end
401
+ private_class_method :_decode_uri_component
402
+
403
+ # Returns a URL-encoded string derived from the given
404
+ # {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
405
+ # +enum+.
406
+ #
407
+ # The result is suitable for use as form data
408
+ # for an \HTTP request whose <tt>Content-Type</tt> is
409
+ # <tt>'application/x-www-form-urlencoded'</tt>.
410
+ #
411
+ # The returned string consists of the elements of +enum+,
412
+ # each converted to one or more URL-encoded strings,
413
+ # and all joined with character <tt>'&'</tt>.
414
+ #
415
+ # Simple examples:
416
+ #
417
+ # Gem::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
418
+ # # => "foo=0&bar=1&baz=2"
419
+ # Gem::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
420
+ # # => "foo=0&bar=1&baz=2"
421
+ #
422
+ # The returned string is formed using method Gem::URI.encode_www_form_component,
423
+ # which converts certain characters:
424
+ #
425
+ # Gem::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
426
+ # # => "f%23o=%2F&b-r=%24&b+z=%40"
427
+ #
428
+ # When +enum+ is Array-like, each element +ele+ is converted to a field:
429
+ #
430
+ # - If +ele+ is an array of two or more elements,
431
+ # the field is formed from its first two elements
432
+ # (and any additional elements are ignored):
433
+ #
434
+ # name = Gem::URI.encode_www_form_component(ele[0], enc)
435
+ # value = Gem::URI.encode_www_form_component(ele[1], enc)
436
+ # "#{name}=#{value}"
437
+ #
438
+ # Examples:
439
+ #
440
+ # Gem::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
441
+ # # => "foo=bar&baz=bat"
442
+ # Gem::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
443
+ # # => "foo=0&bar=baz"
444
+ #
445
+ # - If +ele+ is an array of one element,
446
+ # the field is formed from <tt>ele[0]</tt>:
447
+ #
448
+ # Gem::URI.encode_www_form_component(ele[0])
449
+ #
450
+ # Example:
451
+ #
452
+ # Gem::URI.encode_www_form([['foo'], [:bar], [0]])
453
+ # # => "foo&bar&0"
454
+ #
455
+ # - Otherwise the field is formed from +ele+:
456
+ #
457
+ # Gem::URI.encode_www_form_component(ele)
458
+ #
459
+ # Example:
460
+ #
461
+ # Gem::URI.encode_www_form(['foo', :bar, 0])
462
+ # # => "foo&bar&0"
463
+ #
464
+ # The elements of an Array-like +enum+ may be mixture:
465
+ #
466
+ # Gem::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
467
+ # # => "foo=0&bar=1&baz&bat"
468
+ #
469
+ # When +enum+ is Hash-like,
470
+ # each +key+/+value+ pair is converted to one or more fields:
471
+ #
472
+ # - If +value+ is
473
+ # {Array-convertible}[https://docs.ruby-lang.org/en/master/implicit_conversion_rdoc.html#label-Array-Convertible+Objects],
474
+ # each element +ele+ in +value+ is paired with +key+ to form a field:
475
+ #
476
+ # name = Gem::URI.encode_www_form_component(key, enc)
477
+ # value = Gem::URI.encode_www_form_component(ele, enc)
478
+ # "#{name}=#{value}"
479
+ #
480
+ # Example:
481
+ #
482
+ # Gem::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
483
+ # # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
484
+ #
485
+ # - Otherwise, +key+ and +value+ are paired to form a field:
486
+ #
487
+ # name = Gem::URI.encode_www_form_component(key, enc)
488
+ # value = Gem::URI.encode_www_form_component(value, enc)
489
+ # "#{name}=#{value}"
490
+ #
491
+ # Example:
492
+ #
493
+ # Gem::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
494
+ # # => "foo=0&bar=1&baz=2"
495
+ #
496
+ # The elements of a Hash-like +enum+ may be mixture:
497
+ #
498
+ # Gem::URI.encode_www_form({foo: [0, 1], bar: 2})
499
+ # # => "foo=0&foo=1&bar=2"
500
+ #
501
+ def self.encode_www_form(enum, enc=nil)
502
+ enum.map do |k,v|
503
+ if v.nil?
504
+ encode_www_form_component(k, enc)
505
+ elsif v.respond_to?(:to_ary)
506
+ v.to_ary.map do |w|
507
+ str = encode_www_form_component(k, enc)
508
+ unless w.nil?
509
+ str << '='
510
+ str << encode_www_form_component(w, enc)
511
+ end
512
+ end.join('&')
513
+ else
514
+ str = encode_www_form_component(k, enc)
515
+ str << '='
516
+ str << encode_www_form_component(v, enc)
517
+ end
518
+ end.join('&')
519
+ end
520
+
521
+ # Returns name/value pairs derived from the given string +str+,
522
+ # which must be an ASCII string.
523
+ #
524
+ # The method may be used to decode the body of Net::HTTPResponse object +res+
525
+ # for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
526
+ #
527
+ # The returned data is an array of 2-element subarrays;
528
+ # each subarray is a name/value pair (both are strings).
529
+ # Each returned string has encoding +enc+,
530
+ # and has had invalid characters removed via
531
+ # {String#scrub}[https://docs.ruby-lang.org/en/master/String.html#method-i-scrub].
532
+ #
533
+ # A simple example:
534
+ #
535
+ # Gem::URI.decode_www_form('foo=0&bar=1&baz')
536
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
537
+ #
538
+ # The returned strings have certain conversions,
539
+ # similar to those performed in Gem::URI.decode_www_form_component:
540
+ #
541
+ # Gem::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
542
+ # # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
543
+ #
544
+ # The given string may contain consecutive separators:
545
+ #
546
+ # Gem::URI.decode_www_form('foo=0&&bar=1&&baz=2')
547
+ # # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
548
+ #
549
+ # A different separator may be specified:
550
+ #
551
+ # Gem::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
552
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
553
+ #
554
+ def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
555
+ raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
556
+ ary = []
557
+ return ary if str.empty?
558
+ enc = Encoding.find(enc)
559
+ str.b.each_line(separator) do |string|
560
+ string.chomp!(separator)
561
+ key, sep, val = string.partition('=')
562
+ if isindex
563
+ if sep.empty?
564
+ val = key
565
+ key = +''
566
+ end
567
+ isindex = false
568
+ end
569
+
570
+ if use__charset_ and key == '_charset_' and e = get_encoding(val)
571
+ enc = e
572
+ use__charset_ = false
573
+ end
574
+
575
+ key.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
576
+ if val
577
+ val.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
578
+ else
579
+ val = +''
580
+ end
581
+
582
+ ary << [key, val]
583
+ end
584
+ ary.each do |k, v|
585
+ k.force_encoding(enc)
586
+ k.scrub!
587
+ v.force_encoding(enc)
588
+ v.scrub!
589
+ end
590
+ ary
591
+ end
592
+
593
+ private
594
+ =begin command for WEB_ENCODINGS_
595
+ curl https://encoding.spec.whatwg.org/encodings.json|
596
+ ruby -rjson -e 'H={}
597
+ h={
598
+ "shift_jis"=>"Windows-31J",
599
+ "euc-jp"=>"cp51932",
600
+ "iso-2022-jp"=>"cp50221",
601
+ "x-mac-cyrillic"=>"macCyrillic",
602
+ }
603
+ JSON($<.read).map{|x|x["encodings"]}.flatten.each{|x|
604
+ Encoding.find(n=h.fetch(n=x["name"].downcase,n))rescue next
605
+ x["labels"].each{|y|H[y]=n}
606
+ }
607
+ puts "{"
608
+ H.each{|k,v|puts %[ #{k.dump}=>#{v.dump},]}
609
+ puts "}"
610
+ '
611
+ =end
612
+ WEB_ENCODINGS_ = {
613
+ "unicode-1-1-utf-8"=>"utf-8",
614
+ "utf-8"=>"utf-8",
615
+ "utf8"=>"utf-8",
616
+ "866"=>"ibm866",
617
+ "cp866"=>"ibm866",
618
+ "csibm866"=>"ibm866",
619
+ "ibm866"=>"ibm866",
620
+ "csisolatin2"=>"iso-8859-2",
621
+ "iso-8859-2"=>"iso-8859-2",
622
+ "iso-ir-101"=>"iso-8859-2",
623
+ "iso8859-2"=>"iso-8859-2",
624
+ "iso88592"=>"iso-8859-2",
625
+ "iso_8859-2"=>"iso-8859-2",
626
+ "iso_8859-2:1987"=>"iso-8859-2",
627
+ "l2"=>"iso-8859-2",
628
+ "latin2"=>"iso-8859-2",
629
+ "csisolatin3"=>"iso-8859-3",
630
+ "iso-8859-3"=>"iso-8859-3",
631
+ "iso-ir-109"=>"iso-8859-3",
632
+ "iso8859-3"=>"iso-8859-3",
633
+ "iso88593"=>"iso-8859-3",
634
+ "iso_8859-3"=>"iso-8859-3",
635
+ "iso_8859-3:1988"=>"iso-8859-3",
636
+ "l3"=>"iso-8859-3",
637
+ "latin3"=>"iso-8859-3",
638
+ "csisolatin4"=>"iso-8859-4",
639
+ "iso-8859-4"=>"iso-8859-4",
640
+ "iso-ir-110"=>"iso-8859-4",
641
+ "iso8859-4"=>"iso-8859-4",
642
+ "iso88594"=>"iso-8859-4",
643
+ "iso_8859-4"=>"iso-8859-4",
644
+ "iso_8859-4:1988"=>"iso-8859-4",
645
+ "l4"=>"iso-8859-4",
646
+ "latin4"=>"iso-8859-4",
647
+ "csisolatincyrillic"=>"iso-8859-5",
648
+ "cyrillic"=>"iso-8859-5",
649
+ "iso-8859-5"=>"iso-8859-5",
650
+ "iso-ir-144"=>"iso-8859-5",
651
+ "iso8859-5"=>"iso-8859-5",
652
+ "iso88595"=>"iso-8859-5",
653
+ "iso_8859-5"=>"iso-8859-5",
654
+ "iso_8859-5:1988"=>"iso-8859-5",
655
+ "arabic"=>"iso-8859-6",
656
+ "asmo-708"=>"iso-8859-6",
657
+ "csiso88596e"=>"iso-8859-6",
658
+ "csiso88596i"=>"iso-8859-6",
659
+ "csisolatinarabic"=>"iso-8859-6",
660
+ "ecma-114"=>"iso-8859-6",
661
+ "iso-8859-6"=>"iso-8859-6",
662
+ "iso-8859-6-e"=>"iso-8859-6",
663
+ "iso-8859-6-i"=>"iso-8859-6",
664
+ "iso-ir-127"=>"iso-8859-6",
665
+ "iso8859-6"=>"iso-8859-6",
666
+ "iso88596"=>"iso-8859-6",
667
+ "iso_8859-6"=>"iso-8859-6",
668
+ "iso_8859-6:1987"=>"iso-8859-6",
669
+ "csisolatingreek"=>"iso-8859-7",
670
+ "ecma-118"=>"iso-8859-7",
671
+ "elot_928"=>"iso-8859-7",
672
+ "greek"=>"iso-8859-7",
673
+ "greek8"=>"iso-8859-7",
674
+ "iso-8859-7"=>"iso-8859-7",
675
+ "iso-ir-126"=>"iso-8859-7",
676
+ "iso8859-7"=>"iso-8859-7",
677
+ "iso88597"=>"iso-8859-7",
678
+ "iso_8859-7"=>"iso-8859-7",
679
+ "iso_8859-7:1987"=>"iso-8859-7",
680
+ "sun_eu_greek"=>"iso-8859-7",
681
+ "csiso88598e"=>"iso-8859-8",
682
+ "csisolatinhebrew"=>"iso-8859-8",
683
+ "hebrew"=>"iso-8859-8",
684
+ "iso-8859-8"=>"iso-8859-8",
685
+ "iso-8859-8-e"=>"iso-8859-8",
686
+ "iso-ir-138"=>"iso-8859-8",
687
+ "iso8859-8"=>"iso-8859-8",
688
+ "iso88598"=>"iso-8859-8",
689
+ "iso_8859-8"=>"iso-8859-8",
690
+ "iso_8859-8:1988"=>"iso-8859-8",
691
+ "visual"=>"iso-8859-8",
692
+ "csisolatin6"=>"iso-8859-10",
693
+ "iso-8859-10"=>"iso-8859-10",
694
+ "iso-ir-157"=>"iso-8859-10",
695
+ "iso8859-10"=>"iso-8859-10",
696
+ "iso885910"=>"iso-8859-10",
697
+ "l6"=>"iso-8859-10",
698
+ "latin6"=>"iso-8859-10",
699
+ "iso-8859-13"=>"iso-8859-13",
700
+ "iso8859-13"=>"iso-8859-13",
701
+ "iso885913"=>"iso-8859-13",
702
+ "iso-8859-14"=>"iso-8859-14",
703
+ "iso8859-14"=>"iso-8859-14",
704
+ "iso885914"=>"iso-8859-14",
705
+ "csisolatin9"=>"iso-8859-15",
706
+ "iso-8859-15"=>"iso-8859-15",
707
+ "iso8859-15"=>"iso-8859-15",
708
+ "iso885915"=>"iso-8859-15",
709
+ "iso_8859-15"=>"iso-8859-15",
710
+ "l9"=>"iso-8859-15",
711
+ "iso-8859-16"=>"iso-8859-16",
712
+ "cskoi8r"=>"koi8-r",
713
+ "koi"=>"koi8-r",
714
+ "koi8"=>"koi8-r",
715
+ "koi8-r"=>"koi8-r",
716
+ "koi8_r"=>"koi8-r",
717
+ "koi8-ru"=>"koi8-u",
718
+ "koi8-u"=>"koi8-u",
719
+ "dos-874"=>"windows-874",
720
+ "iso-8859-11"=>"windows-874",
721
+ "iso8859-11"=>"windows-874",
722
+ "iso885911"=>"windows-874",
723
+ "tis-620"=>"windows-874",
724
+ "windows-874"=>"windows-874",
725
+ "cp1250"=>"windows-1250",
726
+ "windows-1250"=>"windows-1250",
727
+ "x-cp1250"=>"windows-1250",
728
+ "cp1251"=>"windows-1251",
729
+ "windows-1251"=>"windows-1251",
730
+ "x-cp1251"=>"windows-1251",
731
+ "ansi_x3.4-1968"=>"windows-1252",
732
+ "ascii"=>"windows-1252",
733
+ "cp1252"=>"windows-1252",
734
+ "cp819"=>"windows-1252",
735
+ "csisolatin1"=>"windows-1252",
736
+ "ibm819"=>"windows-1252",
737
+ "iso-8859-1"=>"windows-1252",
738
+ "iso-ir-100"=>"windows-1252",
739
+ "iso8859-1"=>"windows-1252",
740
+ "iso88591"=>"windows-1252",
741
+ "iso_8859-1"=>"windows-1252",
742
+ "iso_8859-1:1987"=>"windows-1252",
743
+ "l1"=>"windows-1252",
744
+ "latin1"=>"windows-1252",
745
+ "us-ascii"=>"windows-1252",
746
+ "windows-1252"=>"windows-1252",
747
+ "x-cp1252"=>"windows-1252",
748
+ "cp1253"=>"windows-1253",
749
+ "windows-1253"=>"windows-1253",
750
+ "x-cp1253"=>"windows-1253",
751
+ "cp1254"=>"windows-1254",
752
+ "csisolatin5"=>"windows-1254",
753
+ "iso-8859-9"=>"windows-1254",
754
+ "iso-ir-148"=>"windows-1254",
755
+ "iso8859-9"=>"windows-1254",
756
+ "iso88599"=>"windows-1254",
757
+ "iso_8859-9"=>"windows-1254",
758
+ "iso_8859-9:1989"=>"windows-1254",
759
+ "l5"=>"windows-1254",
760
+ "latin5"=>"windows-1254",
761
+ "windows-1254"=>"windows-1254",
762
+ "x-cp1254"=>"windows-1254",
763
+ "cp1255"=>"windows-1255",
764
+ "windows-1255"=>"windows-1255",
765
+ "x-cp1255"=>"windows-1255",
766
+ "cp1256"=>"windows-1256",
767
+ "windows-1256"=>"windows-1256",
768
+ "x-cp1256"=>"windows-1256",
769
+ "cp1257"=>"windows-1257",
770
+ "windows-1257"=>"windows-1257",
771
+ "x-cp1257"=>"windows-1257",
772
+ "cp1258"=>"windows-1258",
773
+ "windows-1258"=>"windows-1258",
774
+ "x-cp1258"=>"windows-1258",
775
+ "x-mac-cyrillic"=>"macCyrillic",
776
+ "x-mac-ukrainian"=>"macCyrillic",
777
+ "chinese"=>"gbk",
778
+ "csgb2312"=>"gbk",
779
+ "csiso58gb231280"=>"gbk",
780
+ "gb2312"=>"gbk",
781
+ "gb_2312"=>"gbk",
782
+ "gb_2312-80"=>"gbk",
783
+ "gbk"=>"gbk",
784
+ "iso-ir-58"=>"gbk",
785
+ "x-gbk"=>"gbk",
786
+ "gb18030"=>"gb18030",
787
+ "big5"=>"big5",
788
+ "big5-hkscs"=>"big5",
789
+ "cn-big5"=>"big5",
790
+ "csbig5"=>"big5",
791
+ "x-x-big5"=>"big5",
792
+ "cseucpkdfmtjapanese"=>"cp51932",
793
+ "euc-jp"=>"cp51932",
794
+ "x-euc-jp"=>"cp51932",
795
+ "csiso2022jp"=>"cp50221",
796
+ "iso-2022-jp"=>"cp50221",
797
+ "csshiftjis"=>"Windows-31J",
798
+ "ms932"=>"Windows-31J",
799
+ "ms_kanji"=>"Windows-31J",
800
+ "shift-jis"=>"Windows-31J",
801
+ "shift_jis"=>"Windows-31J",
802
+ "sjis"=>"Windows-31J",
803
+ "windows-31j"=>"Windows-31J",
804
+ "x-sjis"=>"Windows-31J",
805
+ "cseuckr"=>"euc-kr",
806
+ "csksc56011987"=>"euc-kr",
807
+ "euc-kr"=>"euc-kr",
808
+ "iso-ir-149"=>"euc-kr",
809
+ "korean"=>"euc-kr",
810
+ "ks_c_5601-1987"=>"euc-kr",
811
+ "ks_c_5601-1989"=>"euc-kr",
812
+ "ksc5601"=>"euc-kr",
813
+ "ksc_5601"=>"euc-kr",
814
+ "windows-949"=>"euc-kr",
815
+ "utf-16be"=>"utf-16be",
816
+ "utf-16"=>"utf-16le",
817
+ "utf-16le"=>"utf-16le",
818
+ } # :nodoc:
819
+ Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
820
+
821
+ # :nodoc:
822
+ # return encoding or nil
823
+ # http://encoding.spec.whatwg.org/#concept-encoding-get
824
+ def self.get_encoding(label)
825
+ Encoding.find(WEB_ENCODINGS_[label.to_str.strip.downcase]) rescue nil
826
+ end
827
+ end # module Gem::URI
828
+
829
+ module Gem
830
+
831
+ #
832
+ # Returns a \Gem::URI object derived from the given +uri+,
833
+ # which may be a \Gem::URI string or an existing \Gem::URI object:
834
+ #
835
+ # # Returns a new Gem::URI.
836
+ # uri = Gem::URI('http://github.com/ruby/ruby')
837
+ # # => #<Gem::URI::HTTP http://github.com/ruby/ruby>
838
+ # # Returns the given Gem::URI.
839
+ # Gem::URI(uri)
840
+ # # => #<Gem::URI::HTTP http://github.com/ruby/ruby>
841
+ #
842
+ def URI(uri)
843
+ if uri.is_a?(Gem::URI::Generic)
844
+ uri
845
+ elsif uri = String.try_convert(uri)
846
+ Gem::URI.parse(uri)
847
+ else
848
+ raise ArgumentError,
849
+ "bad argument (expected Gem::URI object or Gem::URI string)"
850
+ end
851
+ end
852
+ module_function :URI
853
+ end