rubygems-update 3.2.30 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -4
  3. data/CONTRIBUTING.md +40 -10
  4. data/Manifest.txt +28 -5
  5. data/POLICIES.md +22 -8
  6. data/README.md +9 -7
  7. data/UPGRADING.md +5 -81
  8. data/bin/gem +1 -6
  9. data/bundler/CHANGELOG.md +86 -0
  10. data/bundler/exe/bundle +7 -8
  11. data/bundler/lib/bundler/build_metadata.rb +2 -2
  12. data/bundler/lib/bundler/cli/doctor.rb +3 -2
  13. data/bundler/lib/bundler/cli/gem.rb +70 -8
  14. data/bundler/lib/bundler/cli/info.rb +6 -1
  15. data/bundler/lib/bundler/cli/install.rb +2 -0
  16. data/bundler/lib/bundler/cli/update.rb +2 -2
  17. data/bundler/lib/bundler/cli.rb +9 -1
  18. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -5
  19. data/bundler/lib/bundler/definition.rb +66 -120
  20. data/bundler/lib/bundler/dependency.rb +5 -7
  21. data/bundler/lib/bundler/dsl.rb +18 -30
  22. data/bundler/lib/bundler/endpoint_specification.rb +0 -8
  23. data/bundler/lib/bundler/environment_preserver.rb +4 -1
  24. data/bundler/lib/bundler/fetcher/compact_index.rb +9 -4
  25. data/bundler/lib/bundler/fetcher.rb +2 -5
  26. data/bundler/lib/bundler/gem_helper.rb +2 -2
  27. data/bundler/lib/bundler/injector.rb +10 -1
  28. data/bundler/lib/bundler/installer/gem_installer.rb +1 -6
  29. data/bundler/lib/bundler/installer.rb +1 -4
  30. data/bundler/lib/bundler/lazy_specification.rb +17 -1
  31. data/bundler/lib/bundler/lockfile_parser.rb +10 -12
  32. data/bundler/lib/bundler/man/bundle-add.1 +10 -2
  33. data/bundler/lib/bundler/man/bundle-add.1.ronn +7 -1
  34. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-config.1 +5 -5
  39. data/bundler/lib/bundler/man/bundle-config.1.ronn +5 -5
  40. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-gem.1 +14 -1
  43. data/bundler/lib/bundler/man/bundle-gem.1.ronn +16 -0
  44. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  45. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  46. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  47. data/bundler/lib/bundler/man/bundle-install.1 +2 -2
  48. data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
  49. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  55. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  56. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  57. data/bundler/lib/bundler/man/bundle-update.1 +2 -2
  58. data/bundler/lib/bundler/man/bundle-update.1.ronn +2 -1
  59. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  60. data/bundler/lib/bundler/man/bundle.1 +1 -1
  61. data/bundler/lib/bundler/man/gemfile.5 +28 -2
  62. data/bundler/lib/bundler/man/gemfile.5.ronn +9 -1
  63. data/bundler/lib/bundler/plugin/api/source.rb +1 -0
  64. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  65. data/bundler/lib/bundler/process_lock.rb +1 -1
  66. data/bundler/lib/bundler/psyched_yaml.rb +1 -13
  67. data/bundler/lib/bundler/resolver.rb +34 -31
  68. data/bundler/lib/bundler/rubygems_ext.rb +2 -0
  69. data/bundler/lib/bundler/rubygems_integration.rb +11 -48
  70. data/bundler/lib/bundler/runtime.rb +1 -1
  71. data/bundler/lib/bundler/self_manager.rb +73 -0
  72. data/bundler/lib/bundler/shared_helpers.rb +4 -12
  73. data/bundler/lib/bundler/source/git/git_proxy.rb +7 -4
  74. data/bundler/lib/bundler/source/metadata.rb +1 -1
  75. data/bundler/lib/bundler/source/rubygems.rb +17 -13
  76. data/bundler/lib/bundler/source/rubygems_aggregate.rb +1 -1
  77. data/bundler/lib/bundler/source.rb +1 -1
  78. data/bundler/lib/bundler/source_list.rb +7 -29
  79. data/bundler/lib/bundler/spec_set.rb +1 -1
  80. data/bundler/lib/bundler/templates/Executable.bundler +1 -1
  81. data/bundler/lib/bundler/templates/Gemfile +0 -2
  82. data/bundler/lib/bundler/templates/gems.rb +0 -3
  83. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  84. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  85. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -2
  86. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +13 -13
  87. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  88. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  89. data/bundler/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  90. data/bundler/lib/bundler/ui/shell.rb +1 -1
  91. data/bundler/lib/bundler/vendor/.document +1 -0
  92. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  93. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  94. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  95. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  96. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  97. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  98. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  99. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  100. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  101. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  102. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  103. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  104. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  105. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  106. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  107. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  108. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  109. data/bundler/lib/bundler/version.rb +1 -1
  110. data/bundler/lib/bundler.rb +9 -3
  111. data/hide_lib_for_update/note.txt +0 -4
  112. data/lib/rubygems/command.rb +4 -4
  113. data/lib/rubygems/command_manager.rb +4 -2
  114. data/lib/rubygems/commands/cert_command.rb +6 -6
  115. data/lib/rubygems/commands/fetch_command.rb +1 -1
  116. data/lib/rubygems/commands/install_command.rb +5 -2
  117. data/lib/rubygems/commands/pristine_command.rb +8 -2
  118. data/lib/rubygems/commands/server_command.rb +14 -77
  119. data/lib/rubygems/commands/setup_command.rb +84 -76
  120. data/lib/rubygems/commands/uninstall_command.rb +1 -1
  121. data/lib/rubygems/commands/update_command.rb +10 -5
  122. data/lib/rubygems/defaults.rb +2 -20
  123. data/lib/rubygems/dependency_list.rb +2 -2
  124. data/lib/rubygems/deprecate.rb +53 -6
  125. data/lib/rubygems/exceptions.rb +27 -1
  126. data/lib/rubygems/ext/builder.rb +11 -8
  127. data/lib/rubygems/ext/cmake_builder.rb +1 -1
  128. data/lib/rubygems/install_update_options.rb +13 -4
  129. data/lib/rubygems/installer.rb +46 -27
  130. data/lib/rubygems/local_remote_options.rb +3 -3
  131. data/lib/rubygems/name_tuple.rb +2 -3
  132. data/lib/rubygems/optparse/.document +1 -0
  133. data/lib/rubygems/optparse/COPYING +56 -0
  134. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  135. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  136. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  137. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  138. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  139. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  140. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  141. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  142. data/lib/rubygems/optparse/lib/optparse.rb +2230 -0
  143. data/lib/rubygems/optparse.rb +3 -0
  144. data/lib/rubygems/path_support.rb +1 -6
  145. data/lib/rubygems/platform.rb +4 -0
  146. data/lib/rubygems/remote_fetcher.rb +1 -1
  147. data/lib/rubygems/request_set.rb +2 -2
  148. data/lib/rubygems/requirement.rb +1 -1
  149. data/lib/rubygems/resolver/installer_set.rb +1 -1
  150. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  151. data/lib/rubygems/security.rb +4 -3
  152. data/lib/rubygems/security_option.rb +3 -3
  153. data/lib/rubygems/source.rb +3 -1
  154. data/lib/rubygems/spec_fetcher.rb +1 -1
  155. data/lib/rubygems/specification.rb +46 -46
  156. data/lib/rubygems/text.rb +21 -20
  157. data/lib/rubygems/tsort/.document +1 -0
  158. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  159. data/lib/rubygems/tsort/lib/tsort.rb +454 -0
  160. data/lib/rubygems/tsort.rb +3 -0
  161. data/lib/rubygems/uninstaller.rb +4 -1
  162. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  163. data/lib/rubygems/util/licenses.rb +2 -0
  164. data/lib/rubygems/version.rb +2 -0
  165. data/lib/rubygems/version_option.rb +2 -2
  166. data/lib/rubygems.rb +13 -10
  167. data/rubygems-update.gemspec +1 -1
  168. data/setup.rb +1 -6
  169. data/test/rubygems/encrypted_private_key.pem +26 -26
  170. data/test/rubygems/helper.rb +48 -38
  171. data/test/rubygems/test_config.rb +2 -2
  172. data/test/rubygems/test_exit.rb +11 -0
  173. data/test/rubygems/test_gem.rb +46 -41
  174. data/test/rubygems/test_gem_command.rb +1 -1
  175. data/test/rubygems/test_gem_command_manager.rb +28 -2
  176. data/test/rubygems/test_gem_commands_cert_command.rb +8 -8
  177. data/test/rubygems/test_gem_commands_fetch_command.rb +36 -0
  178. data/test/rubygems/test_gem_commands_open_command.rb +1 -1
  179. data/test/rubygems/test_gem_commands_server_command.rb +4 -46
  180. data/test/rubygems/test_gem_commands_setup_command.rb +67 -19
  181. data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
  182. data/test/rubygems/test_gem_commands_uninstall_command.rb +1 -1
  183. data/test/rubygems/test_gem_commands_update_command.rb +2 -2
  184. data/test/rubygems/test_gem_commands_yank_command.rb +1 -1
  185. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +7 -3
  186. data/test/rubygems/test_gem_install_update_options.rb +2 -2
  187. data/test/rubygems/test_gem_installer.rb +37 -5
  188. data/test/rubygems/test_gem_path_support.rb +2 -6
  189. data/test/rubygems/test_gem_remote_fetcher.rb +15 -0
  190. data/test/rubygems/test_gem_request.rb +10 -4
  191. data/test/rubygems/test_gem_requirement.rb +0 -1
  192. data/test/rubygems/test_gem_resolver.rb +7 -7
  193. data/test/rubygems/test_gem_security.rb +1 -1
  194. data/test/rubygems/test_gem_specification.rb +27 -25
  195. data/test/rubygems/test_gem_text.rb +6 -0
  196. data/test/rubygems/test_project_sanity.rb +1 -1
  197. data/test/rubygems/test_require.rb +8 -35
  198. data/test/rubygems/test_rubygems.rb +23 -0
  199. metadata +31 -8
  200. data/bundler/lib/bundler/gemdeps.rb +0 -29
  201. data/lib/rubygems/server.rb +0 -882
  202. data/test/rubygems/bogussources.rb +0 -9
  203. data/test/rubygems/test_gem_server.rb +0 -608
@@ -0,0 +1,454 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # tsort.rb - provides a module for topological sorting and strongly connected components.
5
+ #++
6
+ #
7
+
8
+ #
9
+ # Gem::TSort implements topological sorting using Tarjan's algorithm for
10
+ # strongly connected components.
11
+ #
12
+ # Gem::TSort is designed to be able to be used with any object which can be
13
+ # interpreted as a directed graph.
14
+ #
15
+ # Gem::TSort requires two methods to interpret an object as a graph,
16
+ # tsort_each_node and tsort_each_child.
17
+ #
18
+ # * tsort_each_node is used to iterate for all nodes over a graph.
19
+ # * tsort_each_child is used to iterate for child nodes of a given node.
20
+ #
21
+ # The equality of nodes are defined by eql? and hash since
22
+ # Gem::TSort uses Hash internally.
23
+ #
24
+ # == A Simple Example
25
+ #
26
+ # The following example demonstrates how to mix the Gem::TSort module into an
27
+ # existing class (in this case, Hash). Here, we're treating each key in
28
+ # the hash as a node in the graph, and so we simply alias the required
29
+ # #tsort_each_node method to Hash's #each_key method. For each key in the
30
+ # hash, the associated value is an array of the node's child nodes. This
31
+ # choice in turn leads to our implementation of the required #tsort_each_child
32
+ # method, which fetches the array of child nodes and then iterates over that
33
+ # array using the user-supplied block.
34
+ #
35
+ # require 'rubygems/tsort/lib/tsort'
36
+ #
37
+ # class Hash
38
+ # include Gem::TSort
39
+ # alias tsort_each_node each_key
40
+ # def tsort_each_child(node, &block)
41
+ # fetch(node).each(&block)
42
+ # end
43
+ # end
44
+ #
45
+ # {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
46
+ # #=> [3, 2, 1, 4]
47
+ #
48
+ # {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
49
+ # #=> [[4], [2, 3], [1]]
50
+ #
51
+ # == A More Realistic Example
52
+ #
53
+ # A very simple `make' like tool can be implemented as follows:
54
+ #
55
+ # require 'rubygems/tsort/lib/tsort'
56
+ #
57
+ # class Make
58
+ # def initialize
59
+ # @dep = {}
60
+ # @dep.default = []
61
+ # end
62
+ #
63
+ # def rule(outputs, inputs=[], &block)
64
+ # triple = [outputs, inputs, block]
65
+ # outputs.each {|f| @dep[f] = [triple]}
66
+ # @dep[triple] = inputs
67
+ # end
68
+ #
69
+ # def build(target)
70
+ # each_strongly_connected_component_from(target) {|ns|
71
+ # if ns.length != 1
72
+ # fs = ns.delete_if {|n| Array === n}
73
+ # raise Gem::TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
74
+ # end
75
+ # n = ns.first
76
+ # if Array === n
77
+ # outputs, inputs, block = n
78
+ # inputs_time = inputs.map {|f| File.mtime f}.max
79
+ # begin
80
+ # outputs_time = outputs.map {|f| File.mtime f}.min
81
+ # rescue Errno::ENOENT
82
+ # outputs_time = nil
83
+ # end
84
+ # if outputs_time == nil ||
85
+ # inputs_time != nil && outputs_time <= inputs_time
86
+ # sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
87
+ # block.call
88
+ # end
89
+ # end
90
+ # }
91
+ # end
92
+ #
93
+ # def tsort_each_child(node, &block)
94
+ # @dep[node].each(&block)
95
+ # end
96
+ # include Gem::TSort
97
+ # end
98
+ #
99
+ # def command(arg)
100
+ # print arg, "\n"
101
+ # system arg
102
+ # end
103
+ #
104
+ # m = Make.new
105
+ # m.rule(%w[t1]) { command 'date > t1' }
106
+ # m.rule(%w[t2]) { command 'date > t2' }
107
+ # m.rule(%w[t3]) { command 'date > t3' }
108
+ # m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' }
109
+ # m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' }
110
+ # m.build('t5')
111
+ #
112
+ # == Bugs
113
+ #
114
+ # * 'tsort.rb' is wrong name because this library uses
115
+ # Tarjan's algorithm for strongly connected components.
116
+ # Although 'strongly_connected_components.rb' is correct but too long.
117
+ #
118
+ # == References
119
+ #
120
+ # R. E. Tarjan, "Depth First Search and Linear Graph Algorithms",
121
+ # <em>SIAM Journal on Computing</em>, Vol. 1, No. 2, pp. 146-160, June 1972.
122
+ #
123
+
124
+ module Gem
125
+ module TSort
126
+ class Cyclic < StandardError
127
+ end
128
+
129
+ # Returns a topologically sorted array of nodes.
130
+ # The array is sorted from children to parents, i.e.
131
+ # the first element has no child and the last node has no parent.
132
+ #
133
+ # If there is a cycle, Gem::TSort::Cyclic is raised.
134
+ #
135
+ # class G
136
+ # include Gem::TSort
137
+ # def initialize(g)
138
+ # @g = g
139
+ # end
140
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
141
+ # def tsort_each_node(&b) @g.each_key(&b) end
142
+ # end
143
+ #
144
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
145
+ # p graph.tsort #=> [4, 2, 3, 1]
146
+ #
147
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
148
+ # p graph.tsort # raises Gem::TSort::Cyclic
149
+ #
150
+ def tsort
151
+ each_node = method(:tsort_each_node)
152
+ each_child = method(:tsort_each_child)
153
+ Gem::TSort.tsort(each_node, each_child)
154
+ end
155
+
156
+ # Returns a topologically sorted array of nodes.
157
+ # The array is sorted from children to parents, i.e.
158
+ # the first element has no child and the last node has no parent.
159
+ #
160
+ # The graph is represented by _each_node_ and _each_child_.
161
+ # _each_node_ should have +call+ method which yields for each node in the graph.
162
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
163
+ #
164
+ # If there is a cycle, Gem::TSort::Cyclic is raised.
165
+ #
166
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
167
+ # each_node = lambda {|&b| g.each_key(&b) }
168
+ # each_child = lambda {|n, &b| g[n].each(&b) }
169
+ # p Gem::TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1]
170
+ #
171
+ # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
172
+ # each_node = lambda {|&b| g.each_key(&b) }
173
+ # each_child = lambda {|n, &b| g[n].each(&b) }
174
+ # p Gem::TSort.tsort(each_node, each_child) # raises Gem::TSort::Cyclic
175
+ #
176
+ def TSort.tsort(each_node, each_child)
177
+ Gem::TSort.tsort_each(each_node, each_child).to_a
178
+ end
179
+
180
+ # The iterator version of the #tsort method.
181
+ # <tt><em>obj</em>.tsort_each</tt> is similar to <tt><em>obj</em>.tsort.each</tt>, but
182
+ # modification of _obj_ during the iteration may lead to unexpected results.
183
+ #
184
+ # #tsort_each returns +nil+.
185
+ # If there is a cycle, Gem::TSort::Cyclic is raised.
186
+ #
187
+ # class G
188
+ # include Gem::TSort
189
+ # def initialize(g)
190
+ # @g = g
191
+ # end
192
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
193
+ # def tsort_each_node(&b) @g.each_key(&b) end
194
+ # end
195
+ #
196
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
197
+ # graph.tsort_each {|n| p n }
198
+ # #=> 4
199
+ # # 2
200
+ # # 3
201
+ # # 1
202
+ #
203
+ def tsort_each(&block) # :yields: node
204
+ each_node = method(:tsort_each_node)
205
+ each_child = method(:tsort_each_child)
206
+ Gem::TSort.tsort_each(each_node, each_child, &block)
207
+ end
208
+
209
+ # The iterator version of the Gem::TSort.tsort method.
210
+ #
211
+ # The graph is represented by _each_node_ and _each_child_.
212
+ # _each_node_ should have +call+ method which yields for each node in the graph.
213
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
214
+ #
215
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
216
+ # each_node = lambda {|&b| g.each_key(&b) }
217
+ # each_child = lambda {|n, &b| g[n].each(&b) }
218
+ # Gem::TSort.tsort_each(each_node, each_child) {|n| p n }
219
+ # #=> 4
220
+ # # 2
221
+ # # 3
222
+ # # 1
223
+ #
224
+ def TSort.tsort_each(each_node, each_child) # :yields: node
225
+ return to_enum(__method__, each_node, each_child) unless block_given?
226
+
227
+ Gem::TSort.each_strongly_connected_component(each_node, each_child) {|component|
228
+ if component.size == 1
229
+ yield component.first
230
+ else
231
+ raise Cyclic.new("topological sort failed: #{component.inspect}")
232
+ end
233
+ }
234
+ end
235
+
236
+ # Returns strongly connected components as an array of arrays of nodes.
237
+ # The array is sorted from children to parents.
238
+ # Each elements of the array represents a strongly connected component.
239
+ #
240
+ # class G
241
+ # include Gem::TSort
242
+ # def initialize(g)
243
+ # @g = g
244
+ # end
245
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
246
+ # def tsort_each_node(&b) @g.each_key(&b) end
247
+ # end
248
+ #
249
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
250
+ # p graph.strongly_connected_components #=> [[4], [2], [3], [1]]
251
+ #
252
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
253
+ # p graph.strongly_connected_components #=> [[4], [2, 3], [1]]
254
+ #
255
+ def strongly_connected_components
256
+ each_node = method(:tsort_each_node)
257
+ each_child = method(:tsort_each_child)
258
+ Gem::TSort.strongly_connected_components(each_node, each_child)
259
+ end
260
+
261
+ # Returns strongly connected components as an array of arrays of nodes.
262
+ # The array is sorted from children to parents.
263
+ # Each elements of the array represents a strongly connected component.
264
+ #
265
+ # The graph is represented by _each_node_ and _each_child_.
266
+ # _each_node_ should have +call+ method which yields for each node in the graph.
267
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
268
+ #
269
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
270
+ # each_node = lambda {|&b| g.each_key(&b) }
271
+ # each_child = lambda {|n, &b| g[n].each(&b) }
272
+ # p Gem::TSort.strongly_connected_components(each_node, each_child)
273
+ # #=> [[4], [2], [3], [1]]
274
+ #
275
+ # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
276
+ # each_node = lambda {|&b| g.each_key(&b) }
277
+ # each_child = lambda {|n, &b| g[n].each(&b) }
278
+ # p Gem::TSort.strongly_connected_components(each_node, each_child)
279
+ # #=> [[4], [2, 3], [1]]
280
+ #
281
+ def TSort.strongly_connected_components(each_node, each_child)
282
+ Gem::TSort.each_strongly_connected_component(each_node, each_child).to_a
283
+ end
284
+
285
+ # The iterator version of the #strongly_connected_components method.
286
+ # <tt><em>obj</em>.each_strongly_connected_component</tt> is similar to
287
+ # <tt><em>obj</em>.strongly_connected_components.each</tt>, but
288
+ # modification of _obj_ during the iteration may lead to unexpected results.
289
+ #
290
+ # #each_strongly_connected_component returns +nil+.
291
+ #
292
+ # class G
293
+ # include Gem::TSort
294
+ # def initialize(g)
295
+ # @g = g
296
+ # end
297
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
298
+ # def tsort_each_node(&b) @g.each_key(&b) end
299
+ # end
300
+ #
301
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
302
+ # graph.each_strongly_connected_component {|scc| p scc }
303
+ # #=> [4]
304
+ # # [2]
305
+ # # [3]
306
+ # # [1]
307
+ #
308
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
309
+ # graph.each_strongly_connected_component {|scc| p scc }
310
+ # #=> [4]
311
+ # # [2, 3]
312
+ # # [1]
313
+ #
314
+ def each_strongly_connected_component(&block) # :yields: nodes
315
+ each_node = method(:tsort_each_node)
316
+ each_child = method(:tsort_each_child)
317
+ Gem::TSort.each_strongly_connected_component(each_node, each_child, &block)
318
+ end
319
+
320
+ # The iterator version of the Gem::TSort.strongly_connected_components method.
321
+ #
322
+ # The graph is represented by _each_node_ and _each_child_.
323
+ # _each_node_ should have +call+ method which yields for each node in the graph.
324
+ # _each_child_ should have +call+ method which takes a node argument and yields for each child node.
325
+ #
326
+ # g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
327
+ # each_node = lambda {|&b| g.each_key(&b) }
328
+ # each_child = lambda {|n, &b| g[n].each(&b) }
329
+ # Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
330
+ # #=> [4]
331
+ # # [2]
332
+ # # [3]
333
+ # # [1]
334
+ #
335
+ # g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
336
+ # each_node = lambda {|&b| g.each_key(&b) }
337
+ # each_child = lambda {|n, &b| g[n].each(&b) }
338
+ # Gem::TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
339
+ # #=> [4]
340
+ # # [2, 3]
341
+ # # [1]
342
+ #
343
+ def TSort.each_strongly_connected_component(each_node, each_child) # :yields: nodes
344
+ return to_enum(__method__, each_node, each_child) unless block_given?
345
+
346
+ id_map = {}
347
+ stack = []
348
+ each_node.call {|node|
349
+ unless id_map.include? node
350
+ Gem::TSort.each_strongly_connected_component_from(node, each_child, id_map, stack) {|c|
351
+ yield c
352
+ }
353
+ end
354
+ }
355
+ nil
356
+ end
357
+
358
+ # Iterates over strongly connected component in the subgraph reachable from
359
+ # _node_.
360
+ #
361
+ # Return value is unspecified.
362
+ #
363
+ # #each_strongly_connected_component_from doesn't call #tsort_each_node.
364
+ #
365
+ # class G
366
+ # include Gem::TSort
367
+ # def initialize(g)
368
+ # @g = g
369
+ # end
370
+ # def tsort_each_child(n, &b) @g[n].each(&b) end
371
+ # def tsort_each_node(&b) @g.each_key(&b) end
372
+ # end
373
+ #
374
+ # graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
375
+ # graph.each_strongly_connected_component_from(2) {|scc| p scc }
376
+ # #=> [4]
377
+ # # [2]
378
+ #
379
+ # graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
380
+ # graph.each_strongly_connected_component_from(2) {|scc| p scc }
381
+ # #=> [4]
382
+ # # [2, 3]
383
+ #
384
+ def each_strongly_connected_component_from(node, id_map={}, stack=[], &block) # :yields: nodes
385
+ Gem::TSort.each_strongly_connected_component_from(node, method(:tsort_each_child), id_map, stack, &block)
386
+ end
387
+
388
+ # Iterates over strongly connected components in a graph.
389
+ # The graph is represented by _node_ and _each_child_.
390
+ #
391
+ # _node_ is the first node.
392
+ # _each_child_ should have +call+ method which takes a node argument
393
+ # and yields for each child node.
394
+ #
395
+ # Return value is unspecified.
396
+ #
397
+ # #Gem::TSort.each_strongly_connected_component_from is a class method and
398
+ # it doesn't need a class to represent a graph which includes Gem::TSort.
399
+ #
400
+ # graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
401
+ # each_child = lambda {|n, &b| graph[n].each(&b) }
402
+ # Gem::TSort.each_strongly_connected_component_from(1, each_child) {|scc|
403
+ # p scc
404
+ # }
405
+ # #=> [4]
406
+ # # [2, 3]
407
+ # # [1]
408
+ #
409
+ def TSort.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) # :yields: nodes
410
+ return to_enum(__method__, node, each_child, id_map, stack) unless block_given?
411
+
412
+ minimum_id = node_id = id_map[node] = id_map.size
413
+ stack_length = stack.length
414
+ stack << node
415
+
416
+ each_child.call(node) {|child|
417
+ if id_map.include? child
418
+ child_id = id_map[child]
419
+ minimum_id = child_id if child_id && child_id < minimum_id
420
+ else
421
+ sub_minimum_id =
422
+ Gem::TSort.each_strongly_connected_component_from(child, each_child, id_map, stack) {|c|
423
+ yield c
424
+ }
425
+ minimum_id = sub_minimum_id if sub_minimum_id < minimum_id
426
+ end
427
+ }
428
+
429
+ if node_id == minimum_id
430
+ component = stack.slice!(stack_length .. -1)
431
+ component.each {|n| id_map[n] = nil}
432
+ yield component
433
+ end
434
+
435
+ minimum_id
436
+ end
437
+
438
+ # Should be implemented by a extended class.
439
+ #
440
+ # #tsort_each_node is used to iterate for all nodes over a graph.
441
+ #
442
+ def tsort_each_node # :yields: node
443
+ raise NotImplementedError.new
444
+ end
445
+
446
+ # Should be implemented by a extended class.
447
+ #
448
+ # #tsort_each_child is used to iterate for child nodes of _node_.
449
+ #
450
+ def tsort_each_child(node) # :yields: child
451
+ raise NotImplementedError.new
452
+ end
453
+ end
454
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tsort/lib/tsort'
@@ -262,7 +262,10 @@ class Gem::Uninstaller
262
262
 
263
263
  safe_delete { FileUtils.rm_r gem }
264
264
 
265
- Gem::RDoc.new(spec).remove
265
+ begin
266
+ Gem::RDoc.new(spec).remove
267
+ rescue NameError
268
+ end
266
269
 
267
270
  gemspec = spec.spec_file
268
271
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gem::UnknownCommandSpellChecker
4
+ attr_reader :error
5
+
6
+ def initialize(error)
7
+ @error = error
8
+ end
9
+
10
+ def corrections
11
+ @corrections ||=
12
+ spell_checker.correct(error.unknown_command).map(&:inspect)
13
+ end
14
+
15
+ private
16
+
17
+ def spell_checker
18
+ dictionary = Gem::CommandManager.instance.command_names
19
+ DidYouMean::SpellChecker.new(dictionary: dictionary)
20
+ end
21
+ end
@@ -5,6 +5,7 @@ class Gem::Licenses
5
5
  extend Gem::Text
6
6
 
7
7
  NONSTANDARD = 'Nonstandard'.freeze
8
+ LICENSE_REF = 'LicenseRef-.+'.freeze
8
9
 
9
10
  # Software Package Data Exchange (SPDX) standard open-source software
10
11
  # license identifiers
@@ -523,6 +524,7 @@ class Gem::Licenses
523
524
  \+?
524
525
  (?:\s WITH \s #{Regexp.union(EXCEPTION_IDENTIFIERS)})?
525
526
  | #{NONSTANDARD}
527
+ | #{LICENSE_REF}
526
528
  )
527
529
  \Z
528
530
  }ox.freeze
@@ -149,6 +149,8 @@
149
149
  # For the last example, single-digit versions are automatically extended with
150
150
  # a zero to give a sensible result.
151
151
 
152
+ require_relative "deprecate"
153
+
152
154
  class Gem::Version
153
155
  autoload :Requirement, File.expand_path('requirement', __dir__)
154
156
 
@@ -16,7 +16,7 @@ module Gem::VersionOption
16
16
  # Add the --platform option to the option parser.
17
17
 
18
18
  def add_platform_option(task = command, *wrap)
19
- OptionParser.accept Gem::Platform do |value|
19
+ Gem::OptionParser.accept Gem::Platform do |value|
20
20
  if value == Gem::Platform::RUBY
21
21
  value
22
22
  else
@@ -51,7 +51,7 @@ module Gem::VersionOption
51
51
  # Add the --version option to the option parser.
52
52
 
53
53
  def add_version_option(task = command, *wrap)
54
- OptionParser.accept Gem::Requirement do |value|
54
+ Gem::OptionParser.accept Gem::Requirement do |value|
55
55
  Gem::Requirement.new(*value.split(/\s*,\s*/))
56
56
  end
57
57
 
data/lib/rubygems.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  require 'rbconfig'
9
9
 
10
10
  module Gem
11
- VERSION = "3.2.30".freeze
11
+ VERSION = "3.3.0".freeze
12
12
  end
13
13
 
14
14
  # Must be first since it unloads the prelude from 1.9.2
@@ -800,11 +800,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
800
800
  ##
801
801
  # Safely write a file in binary mode on all platforms.
802
802
  def self.write_binary(path, data)
803
+ File.open(path, File::RDWR | File::CREAT | File::LOCK_EX, binmode: true) do |io|
804
+ io.write data
805
+ end
806
+ rescue *WRITE_BINARY_ERRORS
803
807
  File.open(path, 'wb') do |io|
804
- begin
805
- io.flock(File::LOCK_EX)
806
- rescue *WRITE_BINARY_ERRORS
807
- end
808
808
  io.write data
809
809
  end
810
810
  rescue Errno::ENOLCK # NFS
@@ -854,7 +854,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
854
854
  fetcher = Gem::SpecFetcher.fetcher
855
855
  spec_tuples, = fetcher.spec_for_dependency dependency
856
856
 
857
- spec, = spec_tuples.first
857
+ spec, = spec_tuples.last
858
858
 
859
859
  spec
860
860
  end
@@ -1293,7 +1293,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
1293
1293
  end
1294
1294
 
1295
1295
  def default_gem_load_paths
1296
- @default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1]
1296
+ @default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1].map do |lp|
1297
+ expanded = File.expand_path(lp)
1298
+ next expanded unless File.exist?(expanded)
1299
+
1300
+ File.realpath(expanded)
1301
+ end
1297
1302
  end
1298
1303
  end
1299
1304
 
@@ -1310,19 +1315,17 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
1310
1315
  autoload :Licenses, File.expand_path('rubygems/util/licenses', __dir__)
1311
1316
  autoload :NameTuple, File.expand_path('rubygems/name_tuple', __dir__)
1312
1317
  autoload :PathSupport, File.expand_path('rubygems/path_support', __dir__)
1313
- autoload :Platform, File.expand_path('rubygems/platform', __dir__)
1314
1318
  autoload :RequestSet, File.expand_path('rubygems/request_set', __dir__)
1315
- autoload :Requirement, File.expand_path('rubygems/requirement', __dir__)
1316
1319
  autoload :Resolver, File.expand_path('rubygems/resolver', __dir__)
1317
1320
  autoload :Source, File.expand_path('rubygems/source', __dir__)
1318
1321
  autoload :SourceList, File.expand_path('rubygems/source_list', __dir__)
1319
1322
  autoload :SpecFetcher, File.expand_path('rubygems/spec_fetcher', __dir__)
1320
- autoload :Specification, File.expand_path('rubygems/specification', __dir__)
1321
1323
  autoload :Util, File.expand_path('rubygems/util', __dir__)
1322
1324
  autoload :Version, File.expand_path('rubygems/version', __dir__)
1323
1325
  end
1324
1326
 
1325
1327
  require_relative 'rubygems/exceptions'
1328
+ require_relative 'rubygems/specification'
1326
1329
 
1327
1330
  # REFACTOR: This should be pulled out into some kind of hacks file.
1328
1331
  begin
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rubygems-update"
5
- s.version = "3.2.30"
5
+ s.version = "3.3.0"
6
6
  s.authors = ["Jim Weirich", "Chad Fowler", "Eric Hodel", "Luis Lavena", "Aaron Patterson", "Samuel Giddins", "André Arko", "Evan Phoenix", "Hiroshi SHIBATA"]
7
7
  s.email = ["", "", "drbrain@segment7.net", "luislavena@gmail.com", "aaron@tenderlovemaking.com", "segiddins@segiddins.me", "andre@arko.net", "evan@phx.io", "hsbt@ruby-lang.org"]
8
8
 
data/setup.rb CHANGED
@@ -21,7 +21,6 @@ Dir.chdir File.dirname(__FILE__)
21
21
  $:.unshift File.expand_path('lib')
22
22
  require 'rubygems'
23
23
  require 'rubygems/gem_runner'
24
- require 'rubygems/exceptions'
25
24
 
26
25
  Gem::CommandManager.instance.register_command :setup
27
26
 
@@ -31,8 +30,4 @@ if ENV["GEM_PREV_VER"]
31
30
  end
32
31
  args.unshift 'setup'
33
32
 
34
- begin
35
- Gem::GemRunner.new.run args
36
- rescue Gem::SystemExitException => e
37
- exit e.exit_code
38
- end
33
+ Gem::GemRunner.new.run args