rubygems-update 2.6.4 → 2.6.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (288) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -24
  3. data/CODE_OF_CONDUCT.md +2 -2
  4. data/CONTRIBUTING.rdoc +1 -1
  5. data/History.txt +30 -1
  6. data/Manifest.txt +233 -3
  7. data/Rakefile +30 -1
  8. data/appveyor.yml +0 -2
  9. data/bundler/CHANGELOG.md +2407 -0
  10. data/bundler/CODE_OF_CONDUCT.md +42 -0
  11. data/bundler/CONTRIBUTING.md +36 -0
  12. data/bundler/DEVELOPMENT.md +148 -0
  13. data/bundler/ISSUES.md +100 -0
  14. data/bundler/LICENSE.md +23 -0
  15. data/bundler/README.md +40 -0
  16. data/bundler/exe/bundle +35 -0
  17. data/bundler/exe/bundle_ruby +61 -0
  18. data/bundler/exe/bundler +22 -0
  19. data/bundler/lib/bundler.rb +455 -0
  20. data/bundler/lib/bundler/capistrano.rb +17 -0
  21. data/bundler/lib/bundler/cli.rb +497 -0
  22. data/bundler/lib/bundler/cli/binstubs.rb +40 -0
  23. data/bundler/lib/bundler/cli/cache.rb +35 -0
  24. data/bundler/lib/bundler/cli/check.rb +40 -0
  25. data/bundler/lib/bundler/cli/clean.rb +26 -0
  26. data/bundler/lib/bundler/cli/common.rb +56 -0
  27. data/bundler/lib/bundler/cli/config.rb +100 -0
  28. data/bundler/lib/bundler/cli/console.rb +39 -0
  29. data/bundler/lib/bundler/cli/exec.rb +82 -0
  30. data/bundler/lib/bundler/cli/gem.rb +214 -0
  31. data/bundler/lib/bundler/cli/init.rb +33 -0
  32. data/bundler/lib/bundler/cli/inject.rb +33 -0
  33. data/bundler/lib/bundler/cli/install.rb +225 -0
  34. data/bundler/lib/bundler/cli/lock.rb +48 -0
  35. data/bundler/lib/bundler/cli/open.rb +25 -0
  36. data/bundler/lib/bundler/cli/outdated.rb +151 -0
  37. data/bundler/lib/bundler/cli/package.rb +46 -0
  38. data/bundler/lib/bundler/cli/platform.rb +45 -0
  39. data/bundler/lib/bundler/cli/plugin.rb +23 -0
  40. data/bundler/lib/bundler/cli/show.rb +75 -0
  41. data/bundler/lib/bundler/cli/update.rb +72 -0
  42. data/bundler/lib/bundler/cli/viz.rb +27 -0
  43. data/bundler/lib/bundler/constants.rb +6 -0
  44. data/bundler/lib/bundler/current_ruby.rb +84 -0
  45. data/bundler/lib/bundler/definition.rb +744 -0
  46. data/bundler/lib/bundler/dep_proxy.rb +46 -0
  47. data/bundler/lib/bundler/dependency.rb +127 -0
  48. data/bundler/lib/bundler/deployment.rb +63 -0
  49. data/bundler/lib/bundler/deprecate.rb +16 -0
  50. data/bundler/lib/bundler/dsl.rb +512 -0
  51. data/bundler/lib/bundler/endpoint_specification.rb +129 -0
  52. data/bundler/lib/bundler/env.rb +83 -0
  53. data/bundler/lib/bundler/environment.rb +42 -0
  54. data/bundler/lib/bundler/environment_preserver.rb +38 -0
  55. data/bundler/lib/bundler/errors.rb +124 -0
  56. data/bundler/lib/bundler/fetcher.rb +304 -0
  57. data/bundler/lib/bundler/fetcher/base.rb +41 -0
  58. data/bundler/lib/bundler/fetcher/compact_index.rb +103 -0
  59. data/bundler/lib/bundler/fetcher/dependency.rb +92 -0
  60. data/bundler/lib/bundler/fetcher/downloader.rb +66 -0
  61. data/bundler/lib/bundler/fetcher/index.rb +51 -0
  62. data/bundler/lib/bundler/friendly_errors.rb +103 -0
  63. data/bundler/lib/bundler/gem_helper.rb +188 -0
  64. data/bundler/lib/bundler/gem_helpers.rb +32 -0
  65. data/bundler/lib/bundler/gem_remote_fetcher.rb +42 -0
  66. data/bundler/lib/bundler/gem_tasks.rb +6 -0
  67. data/bundler/lib/bundler/graph.rb +172 -0
  68. data/bundler/lib/bundler/index.rb +191 -0
  69. data/bundler/lib/bundler/injector.rb +63 -0
  70. data/bundler/lib/bundler/inline.rb +74 -0
  71. data/bundler/lib/bundler/installer.rb +217 -0
  72. data/bundler/lib/bundler/installer/gem_installer.rb +77 -0
  73. data/bundler/lib/bundler/installer/parallel_installer.rb +126 -0
  74. data/bundler/lib/bundler/installer/standalone.rb +52 -0
  75. data/bundler/lib/bundler/lazy_specification.rb +85 -0
  76. data/bundler/lib/bundler/lockfile_parser.rb +233 -0
  77. data/bundler/lib/bundler/match_platform.rb +14 -0
  78. data/bundler/lib/bundler/mirror.rb +218 -0
  79. data/bundler/lib/bundler/plugin.rb +156 -0
  80. data/bundler/lib/bundler/plugin/api.rb +56 -0
  81. data/bundler/lib/bundler/plugin/dsl.rb +29 -0
  82. data/bundler/lib/bundler/plugin/index.rb +88 -0
  83. data/bundler/lib/bundler/plugin/installer.rb +99 -0
  84. data/bundler/lib/bundler/plugin/installer/git.rb +38 -0
  85. data/bundler/lib/bundler/plugin/installer/rubygems.rb +27 -0
  86. data/bundler/lib/bundler/plugin/source_list.rb +24 -0
  87. data/bundler/lib/bundler/postit_trampoline.rb +57 -0
  88. data/bundler/lib/bundler/psyched_yaml.rb +27 -0
  89. data/bundler/lib/bundler/remote_specification.rb +85 -0
  90. data/bundler/lib/bundler/resolver.rb +368 -0
  91. data/bundler/lib/bundler/retry.rb +61 -0
  92. data/bundler/lib/bundler/ruby_dsl.rb +17 -0
  93. data/bundler/lib/bundler/ruby_version.rb +140 -0
  94. data/bundler/lib/bundler/rubygems_ext.rb +178 -0
  95. data/bundler/lib/bundler/rubygems_gem_installer.rb +10 -0
  96. data/bundler/lib/bundler/rubygems_integration.rb +710 -0
  97. data/bundler/lib/bundler/runtime.rb +282 -0
  98. data/bundler/lib/bundler/settings.rb +259 -0
  99. data/bundler/lib/bundler/setup.rb +28 -0
  100. data/bundler/lib/bundler/shared_helpers.rb +212 -0
  101. data/bundler/lib/bundler/similarity_detector.rb +62 -0
  102. data/bundler/lib/bundler/source.rb +37 -0
  103. data/bundler/lib/bundler/source/gemspec.rb +13 -0
  104. data/bundler/lib/bundler/source/git.rb +297 -0
  105. data/bundler/lib/bundler/source/git/git_proxy.rb +218 -0
  106. data/bundler/lib/bundler/source/path.rb +245 -0
  107. data/bundler/lib/bundler/source/path/installer.rb +44 -0
  108. data/bundler/lib/bundler/source/rubygems.rb +450 -0
  109. data/bundler/lib/bundler/source/rubygems/remote.rb +59 -0
  110. data/bundler/lib/bundler/source_list.rb +106 -0
  111. data/bundler/lib/bundler/spec_set.rb +157 -0
  112. data/bundler/lib/bundler/ssl_certs/.document +1 -0
  113. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +65 -0
  114. data/bundler/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  115. data/bundler/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  116. data/{lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot-2048.pem → bundler/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem} +0 -0
  117. data/bundler/lib/bundler/stub_specification.rb +24 -0
  118. data/bundler/lib/bundler/templates/Executable +17 -0
  119. data/bundler/lib/bundler/templates/Executable.standalone +12 -0
  120. data/bundler/lib/bundler/templates/Gemfile +5 -0
  121. data/bundler/lib/bundler/templates/newgem/.travis.yml.tt +5 -0
  122. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
  123. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  124. data/bundler/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
  125. data/bundler/lib/bundler/templates/newgem/README.md.tt +41 -0
  126. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +29 -0
  127. data/bundler/lib/bundler/templates/newgem/bin/console.tt +14 -0
  128. data/bundler/lib/bundler/templates/newgem/bin/setup.tt +8 -0
  129. data/bundler/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  130. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
  131. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  132. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  133. data/bundler/lib/bundler/templates/newgem/gitignore.tt +16 -0
  134. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
  135. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  136. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +46 -0
  137. data/bundler/lib/bundler/templates/newgem/rspec.tt +2 -0
  138. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
  139. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
  140. data/bundler/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
  141. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
  142. data/bundler/lib/bundler/ui.rb +8 -0
  143. data/bundler/lib/bundler/ui/rg_proxy.rb +18 -0
  144. data/bundler/lib/bundler/ui/shell.rb +114 -0
  145. data/bundler/lib/bundler/ui/silent.rb +48 -0
  146. data/bundler/lib/bundler/uri_credentials_filter.rb +36 -0
  147. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +79 -0
  148. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +98 -0
  149. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +80 -0
  150. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +4 -0
  151. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +10 -0
  152. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +50 -0
  153. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +80 -0
  154. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +203 -0
  155. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +35 -0
  156. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +58 -0
  157. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +61 -0
  158. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +53 -0
  159. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +114 -0
  160. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +45 -0
  161. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +35 -0
  162. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +123 -0
  163. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -0
  164. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +5 -0
  165. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +100 -0
  166. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +65 -0
  167. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +460 -0
  168. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +45 -0
  169. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +54 -0
  170. data/bundler/lib/bundler/vendor/net/http/faster.rb +26 -0
  171. data/bundler/lib/bundler/vendor/net/http/persistent.rb +1230 -0
  172. data/bundler/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
  173. data/bundler/lib/bundler/vendor/postit/lib/postit.rb +15 -0
  174. data/bundler/lib/bundler/vendor/postit/lib/postit/environment.rb +44 -0
  175. data/bundler/lib/bundler/vendor/postit/lib/postit/installer.rb +28 -0
  176. data/bundler/lib/bundler/vendor/postit/lib/postit/parser.rb +21 -0
  177. data/bundler/lib/bundler/vendor/postit/lib/postit/setup.rb +12 -0
  178. data/bundler/lib/bundler/vendor/postit/lib/postit/version.rb +3 -0
  179. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +484 -0
  180. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +319 -0
  181. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  182. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +59 -0
  183. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
  184. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
  185. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
  186. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
  187. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +656 -0
  188. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +133 -0
  189. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  190. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
  191. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
  192. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +32 -0
  193. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
  194. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
  195. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
  196. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
  197. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  198. data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  199. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +73 -0
  200. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  201. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +125 -0
  202. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +218 -0
  203. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
  204. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +322 -0
  205. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
  206. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +421 -0
  207. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
  208. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
  209. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +267 -0
  210. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
  211. data/bundler/lib/bundler/vendored_molinillo.rb +3 -0
  212. data/bundler/lib/bundler/vendored_persistent.rb +12 -0
  213. data/bundler/lib/bundler/vendored_thor.rb +4 -0
  214. data/bundler/lib/bundler/version.rb +11 -0
  215. data/bundler/lib/bundler/vlad.rb +12 -0
  216. data/bundler/lib/bundler/worker.rb +82 -0
  217. data/bundler/lib/bundler/yaml_serializer.rb +67 -0
  218. data/bundler/man/bundle-config.ronn +193 -0
  219. data/bundler/man/bundle-exec.ronn +136 -0
  220. data/bundler/man/bundle-gem.ronn +77 -0
  221. data/bundler/man/bundle-install.ronn +404 -0
  222. data/bundler/man/bundle-lock.ronn +47 -0
  223. data/bundler/man/bundle-package.ronn +67 -0
  224. data/bundler/man/bundle-platform.ronn +42 -0
  225. data/bundler/man/bundle-update.ronn +194 -0
  226. data/bundler/man/bundle.ronn +98 -0
  227. data/bundler/man/gemfile.5.ronn +499 -0
  228. data/bundler/man/index.txt +8 -0
  229. data/lib/rubygems.rb +42 -2
  230. data/lib/rubygems/config_file.rb +1 -1
  231. data/lib/rubygems/defaults.rb +18 -0
  232. data/lib/rubygems/installer.rb +1 -0
  233. data/lib/rubygems/package.rb +3 -1
  234. data/lib/rubygems/package/tar_writer.rb +10 -16
  235. data/lib/rubygems/remote_fetcher.rb +1 -15
  236. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +50 -0
  237. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +80 -0
  238. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +57 -145
  239. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +35 -0
  240. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +58 -0
  241. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +61 -0
  242. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +53 -0
  243. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +114 -0
  244. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +45 -0
  245. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +35 -0
  246. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +123 -0
  247. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +1 -1
  248. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  249. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +55 -54
  250. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +4 -2
  251. data/lib/rubygems/security/signer.rb +2 -0
  252. data/lib/rubygems/specification.rb +4 -4
  253. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  254. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  255. data/test/rubygems/alternate_cert.pem +10 -9
  256. data/test/rubygems/alternate_cert_32.pem +10 -9
  257. data/test/rubygems/child_cert.pem +11 -9
  258. data/test/rubygems/child_cert_32.pem +11 -9
  259. data/test/rubygems/encrypted_private_key.pem +26 -26
  260. data/test/rubygems/expired_cert.pem +9 -8
  261. data/test/rubygems/future_cert.pem +9 -8
  262. data/test/rubygems/future_cert_32.pem +9 -8
  263. data/test/rubygems/grandchild_cert.pem +11 -9
  264. data/test/rubygems/grandchild_cert_32.pem +11 -9
  265. data/test/rubygems/invalid_issuer_cert.pem +11 -9
  266. data/test/rubygems/invalid_issuer_cert_32.pem +11 -9
  267. data/test/rubygems/invalid_signer_cert.pem +10 -9
  268. data/test/rubygems/invalid_signer_cert_32.pem +10 -9
  269. data/test/rubygems/invalidchild_cert.pem +11 -9
  270. data/test/rubygems/invalidchild_cert_32.pem +11 -9
  271. data/test/rubygems/public_cert.pem +11 -9
  272. data/test/rubygems/public_cert_32.pem +10 -9
  273. data/test/rubygems/test_bundled_ca.rb +1 -1
  274. data/test/rubygems/test_gem.rb +7 -0
  275. data/test/rubygems/test_gem_installer.rb +119 -0
  276. data/test/rubygems/test_gem_package.rb +9 -3
  277. data/test/rubygems/test_gem_package_tar_writer.rb +24 -0
  278. data/test/rubygems/test_gem_remote_fetcher.rb +0 -12
  279. data/test/rubygems/test_gem_security_signer.rb +8 -0
  280. data/test/rubygems/test_gem_specification.rb +1 -1
  281. data/test/rubygems/wrong_key_cert.pem +10 -9
  282. data/test/rubygems/wrong_key_cert_32.pem +10 -9
  283. data/util/ci +73 -0
  284. data/util/create_certs.rb +64 -49
  285. data/util/update_bundled_ca_certificates.rb +23 -2
  286. metadata +257 -19
  287. data/lib/gauntlet_rubygems.rb +0 -51
  288. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRoot.pem +0 -18
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ module Gem::Resolver::Molinillo
3
+ class DependencyGraph
4
+ # An action that modifies a {DependencyGraph} that is reversible.
5
+ # @abstract
6
+ class Action
7
+ # rubocop:disable Lint/UnusedMethodArgument
8
+
9
+ # @return [Symbol] The name of the action.
10
+ def self.name
11
+ raise 'Abstract'
12
+ end
13
+
14
+ # Performs the action on the given graph.
15
+ # @param [DependencyGraph] graph the graph to perform the action on.
16
+ # @return [Void]
17
+ def up(graph)
18
+ raise 'Abstract'
19
+ end
20
+
21
+ # Reverses the action on the given graph.
22
+ # @param [DependencyGraph] graph the graph to reverse the action on.
23
+ # @return [Void]
24
+ def down(graph)
25
+ raise 'Abstract'
26
+ end
27
+
28
+ # @return [Action,Nil] The previous action
29
+ attr_accessor :previous
30
+
31
+ # @return [Action,Nil] The next action
32
+ attr_accessor :next
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action'
3
+ module Gem::Resolver::Molinillo
4
+ class DependencyGraph
5
+ # @!visibility private
6
+ # (see DependencyGraph#add_edge_no_circular)
7
+ class AddEdgeNoCircular < Action
8
+ # @!group Action
9
+
10
+ # (see Action.name)
11
+ def self.name
12
+ :add_vertex
13
+ end
14
+
15
+ # (see Action#up)
16
+ def up(graph)
17
+ edge = make_edge(graph)
18
+ edge.origin.outgoing_edges << edge
19
+ edge.destination.incoming_edges << edge
20
+ edge
21
+ end
22
+
23
+ # (see Action#down)
24
+ def down(graph)
25
+ edge = make_edge(graph)
26
+ edge.origin.outgoing_edges.delete(edge)
27
+ edge.destination.incoming_edges.delete(edge)
28
+ end
29
+
30
+ # @!group AddEdgeNoCircular
31
+
32
+ # @return [String] the name of the origin of the edge
33
+ attr_reader :origin
34
+
35
+ # @return [String] the name of the destination of the edge
36
+ attr_reader :destination
37
+
38
+ # @return [Object] the requirement that the edge represents
39
+ attr_reader :requirement
40
+
41
+ # @param [DependencyGraph] graph the graph to find vertices from
42
+ # @return [Edge] The edge this action adds
43
+ def make_edge(graph)
44
+ Edge.new(graph.vertex_named(origin), graph.vertex_named(destination), requirement)
45
+ end
46
+
47
+ # Initialize an action to add an edge to a dependency graph
48
+ # @param [String] origin the name of the origin of the edge
49
+ # @param [String] destination the name of the destination of the edge
50
+ # @param [Object] requirement the requirement that the edge represents
51
+ def initialize(origin, destination, requirement)
52
+ @origin = origin
53
+ @destination = destination
54
+ @requirement = requirement
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action'
3
+ module Gem::Resolver::Molinillo
4
+ class DependencyGraph
5
+ # @!visibility private
6
+ # (see DependencyGraph#add_vertex)
7
+ class AddVertex < Action # :nodoc:
8
+ # @!group Action
9
+
10
+ # (see Action.name)
11
+ def self.name
12
+ :add_vertex
13
+ end
14
+
15
+ # (see Action#up)
16
+ def up(graph)
17
+ if existing = graph.vertices[name]
18
+ @existing_payload = existing.payload
19
+ @existing_root = existing.root
20
+ end
21
+ vertex = existing || Vertex.new(name, payload)
22
+ graph.vertices[vertex.name] = vertex
23
+ vertex.payload ||= payload
24
+ vertex.root ||= root
25
+ vertex
26
+ end
27
+
28
+ # (see Action#down)
29
+ def down(graph)
30
+ if defined?(@existing_payload)
31
+ vertex = graph.vertices[name]
32
+ vertex.payload = @existing_payload
33
+ vertex.root = @existing_root
34
+ else
35
+ graph.vertices.delete(name)
36
+ end
37
+ end
38
+
39
+ # @!group AddVertex
40
+
41
+ # @return [String] the name of the vertex
42
+ attr_reader :name
43
+
44
+ # @return [Object] the payload for the vertex
45
+ attr_reader :payload
46
+
47
+ # @return [Boolean] whether the vertex is root or not
48
+ attr_reader :root
49
+
50
+ # Initialize an action to add a vertex to a dependency graph
51
+ # @param [String] name the name of the vertex
52
+ # @param [Object] payload the payload for the vertex
53
+ # @param [Boolean] root whether the vertex is root or not
54
+ def initialize(name, payload, root)
55
+ @name = name
56
+ @payload = payload
57
+ @root = root
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action'
3
+ module Gem::Resolver::Molinillo
4
+ class DependencyGraph
5
+ # @!visibility private
6
+ # @see DependencyGraph#detach_vertex_named
7
+ class DetachVertexNamed < Action
8
+ # @!group Action
9
+
10
+ # (see Action#name)
11
+ def self.name
12
+ :add_vertex
13
+ end
14
+
15
+ # (see Action#up)
16
+ def up(graph)
17
+ return unless @vertex = graph.vertices.delete(name)
18
+ @vertex.outgoing_edges.each do |e|
19
+ v = e.destination
20
+ v.incoming_edges.delete(e)
21
+ graph.detach_vertex_named(v.name) unless v.root? || v.predecessors.any?
22
+ end
23
+ @vertex.incoming_edges.each do |e|
24
+ v = e.origin
25
+ v.outgoing_edges.delete(e)
26
+ end
27
+ end
28
+
29
+ # (see Action#down)
30
+ def down(graph)
31
+ return unless @vertex
32
+ graph.vertices[@vertex.name] = @vertex
33
+ @vertex.outgoing_edges.each do |e|
34
+ e.destination.incoming_edges << e
35
+ end
36
+ @vertex.incoming_edges.each do |e|
37
+ e.origin.outgoing_edges << e
38
+ end
39
+ end
40
+
41
+ # @!group DetachVertexNamed
42
+
43
+ # @return [String] the name of the vertex to detach
44
+ attr_reader :name
45
+
46
+ # Initialize an action to detach a vertex from a dependency graph
47
+ # @param [String] name the name of the vertex to detach
48
+ def initialize(name)
49
+ @name = name
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular'
3
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex'
4
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named'
5
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload'
6
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag'
7
+
8
+ module Gem::Resolver::Molinillo
9
+ class DependencyGraph
10
+ # A log for dependency graph actions
11
+ class Log
12
+ # Initializes an empty log
13
+ def initialize
14
+ @current_action = @first_action = nil
15
+ end
16
+
17
+ # @!macro [new] action
18
+ # {include:DependencyGraph#$0}
19
+ # @param [Graph] graph the graph to perform the action on
20
+ # @param (see DependencyGraph#$0)
21
+ # @return (see DependencyGraph#$0)
22
+
23
+ # @macro action
24
+ def tag(graph, tag)
25
+ push_action(graph, Tag.new(tag))
26
+ end
27
+
28
+ # @macro action
29
+ def add_vertex(graph, name, payload, root)
30
+ push_action(graph, AddVertex.new(name, payload, root))
31
+ end
32
+
33
+ # @macro action
34
+ def detach_vertex_named(graph, name)
35
+ push_action(graph, DetachVertexNamed.new(name))
36
+ end
37
+
38
+ # @macro action
39
+ def add_edge_no_circular(graph, origin, destination, requirement)
40
+ push_action(graph, AddEdgeNoCircular.new(origin, destination, requirement))
41
+ end
42
+
43
+ # @macro action
44
+ def set_payload(graph, name, payload)
45
+ push_action(graph, SetPayload.new(name, payload))
46
+ end
47
+
48
+ # Pops the most recent action from the log and undoes the action
49
+ # @param [DependencyGraph] graph
50
+ # @return [Action] the action that was popped off the log
51
+ def pop!(graph)
52
+ return unless action = @current_action
53
+ unless @current_action = action.previous
54
+ @first_action = nil
55
+ end
56
+ action.down(graph)
57
+ action
58
+ end
59
+
60
+ extend Enumerable
61
+
62
+ # @!visibility private
63
+ # Enumerates each action in the log
64
+ # @yield [Action]
65
+ def each
66
+ return enum_for unless block_given?
67
+ action = @first_action
68
+ loop do
69
+ break unless action
70
+ yield action
71
+ action = action.next
72
+ end
73
+ self
74
+ end
75
+
76
+ # @!visibility private
77
+ # Enumerates each action in the log in reverse order
78
+ # @yield [Action]
79
+ def reverse_each
80
+ return enum_for(:reverse_each) unless block_given?
81
+ action = @current_action
82
+ loop do
83
+ break unless action
84
+ yield action
85
+ action = action.previous
86
+ end
87
+ self
88
+ end
89
+
90
+ # @macro action
91
+ def rewind_to(graph, tag)
92
+ loop do
93
+ action = pop!(graph)
94
+ raise "No tag #{tag.inspect} found" unless action
95
+ break if action.class.name == :tag && action.tag == tag
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ # Adds the given action to the log, running the action
102
+ # @param [DependencyGraph] graph
103
+ # @param [Action] action
104
+ # @return The value returned by `action.up`
105
+ def push_action(graph, action)
106
+ action.previous = @current_action
107
+ @current_action.next = action if @current_action
108
+ @current_action = action
109
+ @first_action ||= action
110
+ action.up(graph)
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action'
3
+ module Gem::Resolver::Molinillo
4
+ class DependencyGraph
5
+ # @!visibility private
6
+ # @see DependencyGraph#set_payload
7
+ class SetPayload < Action # :nodoc:
8
+ # @!group Action
9
+
10
+ # (see Action.name)
11
+ def self.name
12
+ :set_payload
13
+ end
14
+
15
+ # (see Action#up)
16
+ def up(graph)
17
+ vertex = graph.vertex_named(name)
18
+ @old_payload = vertex.payload
19
+ vertex.payload = payload
20
+ end
21
+
22
+ # (see Action#down)
23
+ def down(graph)
24
+ graph.vertex_named(name).payload = @old_payload
25
+ end
26
+
27
+ # @!group SetPayload
28
+
29
+ # @return [String] the name of the vertex
30
+ attr_reader :name
31
+
32
+ # @return [Object] the payload for the vertex
33
+ attr_reader :payload
34
+
35
+ # Initialize an action to add set the payload for a vertex in a dependency
36
+ # graph
37
+ # @param [String] name the name of the vertex
38
+ # @param [Object] payload the payload for the vertex
39
+ def initialize(name, payload)
40
+ @name = name
41
+ @payload = payload
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action'
3
+ module Gem::Resolver::Molinillo
4
+ class DependencyGraph
5
+ # @!visibility private
6
+ # @see DependencyGraph#tag
7
+ class Tag < Action
8
+ # @!group Action
9
+
10
+ # (see Action.name)
11
+ def self.name
12
+ :tag
13
+ end
14
+
15
+ # (see Action#up)
16
+ def up(_graph)
17
+ end
18
+
19
+ # (see Action#down)
20
+ def down(_graph)
21
+ end
22
+
23
+ # @!group Tag
24
+
25
+ # @return [Object] An opaque tag
26
+ attr_reader :tag
27
+
28
+ # Initialize an action to tag a state of a dependency graph
29
+ # @param [Object] tag an opaque tag
30
+ def initialize(tag)
31
+ @tag = tag
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+ module Gem::Resolver::Molinillo
3
+ class DependencyGraph
4
+ # A vertex in a {DependencyGraph} that encapsulates a {#name} and a
5
+ # {#payload}
6
+ class Vertex
7
+ # @return [String] the name of the vertex
8
+ attr_accessor :name
9
+
10
+ # @return [Object] the payload the vertex holds
11
+ attr_accessor :payload
12
+
13
+ # @return [Arrary<Object>] the explicit requirements that required
14
+ # this vertex
15
+ attr_reader :explicit_requirements
16
+
17
+ # @return [Boolean] whether the vertex is considered a root vertex
18
+ attr_accessor :root
19
+ alias root? root
20
+
21
+ # Initializes a vertex with the given name and payload.
22
+ # @param [String] name see {#name}
23
+ # @param [Object] payload see {#payload}
24
+ def initialize(name, payload)
25
+ @name = name.frozen? ? name : name.dup.freeze
26
+ @payload = payload
27
+ @explicit_requirements = []
28
+ @outgoing_edges = []
29
+ @incoming_edges = []
30
+ end
31
+
32
+ # @return [Array<Object>] all of the requirements that required
33
+ # this vertex
34
+ def requirements
35
+ incoming_edges.map(&:requirement) + explicit_requirements
36
+ end
37
+
38
+ # @return [Array<Edge>] the edges of {#graph} that have `self` as their
39
+ # {Edge#origin}
40
+ attr_accessor :outgoing_edges
41
+
42
+ # @return [Array<Edge>] the edges of {#graph} that have `self` as their
43
+ # {Edge#destination}
44
+ attr_accessor :incoming_edges
45
+
46
+ # @return [Array<Vertex>] the vertices of {#graph} that have an edge with
47
+ # `self` as their {Edge#destination}
48
+ def predecessors
49
+ incoming_edges.map(&:origin)
50
+ end
51
+
52
+ # @return [Array<Vertex>] the vertices of {#graph} where `self` is a
53
+ # {#descendent?}
54
+ def recursive_predecessors
55
+ vertices = predecessors
56
+ vertices += vertices.map(&:recursive_predecessors).flatten(1)
57
+ vertices.uniq!
58
+ vertices
59
+ end
60
+
61
+ # @return [Array<Vertex>] the vertices of {#graph} that have an edge with
62
+ # `self` as their {Edge#origin}
63
+ def successors
64
+ outgoing_edges.map(&:destination)
65
+ end
66
+
67
+ # @return [Array<Vertex>] the vertices of {#graph} where `self` is an
68
+ # {#ancestor?}
69
+ def recursive_successors
70
+ vertices = successors
71
+ vertices += vertices.map(&:recursive_successors).flatten(1)
72
+ vertices.uniq!
73
+ vertices
74
+ end
75
+
76
+ # @return [String] a string suitable for debugging
77
+ def inspect
78
+ "#{self.class}:#{name}(#{payload.inspect})"
79
+ end
80
+
81
+ # @return [Boolean] whether the two vertices are equal, determined
82
+ # by a recursive traversal of each {Vertex#successors}
83
+ def ==(other)
84
+ shallow_eql?(other) &&
85
+ successors.to_set == other.successors.to_set
86
+ end
87
+
88
+ # @param [Vertex] other the other vertex to compare to
89
+ # @return [Boolean] whether the two vertices are equal, determined
90
+ # solely by {#name} and {#payload} equality
91
+ def shallow_eql?(other)
92
+ other &&
93
+ name == other.name &&
94
+ payload == other.payload
95
+ end
96
+
97
+ alias eql? ==
98
+
99
+ # @return [Fixnum] a hash for the vertex based upon its {#name}
100
+ def hash
101
+ name.hash
102
+ end
103
+
104
+ # Is there a path from `self` to `other` following edges in the
105
+ # dependency graph?
106
+ # @return true iff there is a path following edges within this {#graph}
107
+ def path_to?(other)
108
+ equal?(other) || successors.any? { |v| v.path_to?(other) }
109
+ end
110
+
111
+ alias descendent? path_to?
112
+
113
+ # Is there a path from `other` to `self` following edges in the
114
+ # dependency graph?
115
+ # @return true iff there is a path following edges within this {#graph}
116
+ def ancestor?(other)
117
+ other.path_to?(self)
118
+ end
119
+
120
+ alias is_reachable_from? ancestor?
121
+ end
122
+ end
123
+ end