rubygems-update 3.4.10 → 3.5.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (725) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +714 -4
  3. data/CODE_OF_CONDUCT.md +79 -28
  4. data/CONTRIBUTING.md +3 -3
  5. data/Manifest.txt +128 -257
  6. data/POLICIES.md +82 -13
  7. data/README.md +1 -3
  8. data/bundler/CHANGELOG.md +556 -2
  9. data/bundler/README.md +1 -2
  10. data/bundler/bundler.gemspec +4 -2
  11. data/bundler/exe/bundle +5 -22
  12. data/bundler/lib/bundler/build_metadata.rb +3 -3
  13. data/bundler/lib/bundler/capistrano.rb +1 -1
  14. data/bundler/lib/bundler/checksum.rb +254 -0
  15. data/bundler/lib/bundler/ci_detector.rb +75 -0
  16. data/bundler/lib/bundler/cli/add.rb +4 -4
  17. data/bundler/lib/bundler/cli/binstubs.rb +5 -5
  18. data/bundler/lib/bundler/cli/cache.rb +1 -1
  19. data/bundler/lib/bundler/cli/check.rb +3 -3
  20. data/bundler/lib/bundler/cli/common.rb +9 -1
  21. data/bundler/lib/bundler/cli/config.rb +8 -7
  22. data/bundler/lib/bundler/cli/console.rb +3 -2
  23. data/bundler/lib/bundler/cli/doctor.rb +2 -2
  24. data/bundler/lib/bundler/cli/exec.rb +1 -1
  25. data/bundler/lib/bundler/cli/fund.rb +1 -1
  26. data/bundler/lib/bundler/cli/gem.rb +44 -42
  27. data/bundler/lib/bundler/cli/info.rb +2 -13
  28. data/bundler/lib/bundler/cli/install.rb +18 -12
  29. data/bundler/lib/bundler/cli/issue.rb +1 -1
  30. data/bundler/lib/bundler/cli/lock.rb +33 -29
  31. data/bundler/lib/bundler/cli/open.rb +5 -7
  32. data/bundler/lib/bundler/cli/outdated.rb +23 -25
  33. data/bundler/lib/bundler/cli/platform.rb +7 -5
  34. data/bundler/lib/bundler/cli/plugin.rb +9 -15
  35. data/bundler/lib/bundler/cli/pristine.rb +38 -30
  36. data/bundler/lib/bundler/cli/show.rb +2 -2
  37. data/bundler/lib/bundler/cli/update.rb +6 -5
  38. data/bundler/lib/bundler/cli.rb +226 -291
  39. data/bundler/lib/bundler/compact_index_client/cache.rb +55 -60
  40. data/bundler/lib/bundler/compact_index_client/cache_file.rb +153 -0
  41. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +7 -3
  42. data/bundler/lib/bundler/compact_index_client/parser.rb +84 -0
  43. data/bundler/lib/bundler/compact_index_client/updater.rb +79 -81
  44. data/bundler/lib/bundler/compact_index_client.rb +58 -80
  45. data/bundler/lib/bundler/constants.rb +8 -1
  46. data/bundler/lib/bundler/current_ruby.rb +5 -21
  47. data/bundler/lib/bundler/definition.rb +341 -180
  48. data/bundler/lib/bundler/dependency.rb +22 -13
  49. data/bundler/lib/bundler/digest.rb +2 -2
  50. data/bundler/lib/bundler/dsl.rb +100 -54
  51. data/bundler/lib/bundler/endpoint_specification.rb +17 -2
  52. data/bundler/lib/bundler/env.rb +4 -6
  53. data/bundler/lib/bundler/environment_preserver.rb +5 -23
  54. data/bundler/lib/bundler/errors.rb +74 -0
  55. data/bundler/lib/bundler/feature_flag.rb +0 -1
  56. data/bundler/lib/bundler/fetcher/base.rb +5 -3
  57. data/bundler/lib/bundler/fetcher/compact_index.rb +21 -34
  58. data/bundler/lib/bundler/fetcher/dependency.rb +1 -1
  59. data/bundler/lib/bundler/fetcher/downloader.rb +15 -11
  60. data/bundler/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  61. data/bundler/lib/bundler/fetcher/index.rb +2 -3
  62. data/bundler/lib/bundler/fetcher.rb +72 -58
  63. data/bundler/lib/bundler/force_platform.rb +0 -2
  64. data/bundler/lib/bundler/friendly_errors.rb +6 -6
  65. data/bundler/lib/bundler/gem_helper.rb +5 -6
  66. data/bundler/lib/bundler/gem_helpers.rb +21 -4
  67. data/bundler/lib/bundler/gem_version_promoter.rb +43 -39
  68. data/bundler/lib/bundler/graph.rb +9 -9
  69. data/bundler/lib/bundler/index.rb +63 -33
  70. data/bundler/lib/bundler/injector.rb +6 -8
  71. data/bundler/lib/bundler/inline.rb +33 -12
  72. data/bundler/lib/bundler/installer/gem_installer.rb +13 -12
  73. data/bundler/lib/bundler/installer/parallel_installer.rb +19 -36
  74. data/bundler/lib/bundler/installer/standalone.rb +16 -6
  75. data/bundler/lib/bundler/installer.rb +29 -33
  76. data/bundler/lib/bundler/lazy_specification.rb +31 -17
  77. data/bundler/lib/bundler/lockfile_generator.rb +10 -1
  78. data/bundler/lib/bundler/lockfile_parser.rb +110 -45
  79. data/bundler/lib/bundler/man/bundle-add.1 +29 -41
  80. data/bundler/lib/bundler/man/bundle-add.1.ronn +37 -14
  81. data/bundler/lib/bundler/man/bundle-binstubs.1 +4 -16
  82. data/bundler/lib/bundler/man/bundle-cache.1 +5 -26
  83. data/bundler/lib/bundler/man/bundle-cache.1.ronn +2 -2
  84. data/bundler/lib/bundler/man/bundle-check.1 +5 -12
  85. data/bundler/lib/bundler/man/bundle-check.1.ronn +3 -0
  86. data/bundler/lib/bundler/man/bundle-clean.1 +3 -10
  87. data/bundler/lib/bundler/man/bundle-config.1 +21 -217
  88. data/bundler/lib/bundler/man/bundle-config.1.ronn +9 -9
  89. data/bundler/lib/bundler/man/bundle-console.1 +4 -22
  90. data/bundler/lib/bundler/man/bundle-doctor.1 +4 -18
  91. data/bundler/lib/bundler/man/bundle-exec.1 +13 -74
  92. data/bundler/lib/bundler/man/bundle-exec.1.ronn +2 -3
  93. data/bundler/lib/bundler/man/bundle-gem.1 +19 -49
  94. data/bundler/lib/bundler/man/bundle-gem.1.ronn +11 -0
  95. data/bundler/lib/bundler/man/bundle-help.1 +3 -7
  96. data/bundler/lib/bundler/man/bundle-info.1 +5 -11
  97. data/bundler/lib/bundler/man/bundle-info.1.ronn +3 -3
  98. data/bundler/lib/bundler/man/bundle-init.1 +3 -12
  99. data/bundler/lib/bundler/man/bundle-inject.1 +6 -19
  100. data/bundler/lib/bundler/man/bundle-install.1 +29 -127
  101. data/bundler/lib/bundler/man/bundle-install.1.ronn +3 -2
  102. data/bundler/lib/bundler/man/bundle-list.1 +4 -19
  103. data/bundler/lib/bundler/man/bundle-lock.1 +5 -29
  104. data/bundler/lib/bundler/man/bundle-open.1 +7 -27
  105. data/bundler/lib/bundler/man/bundle-outdated.1 +15 -63
  106. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +12 -8
  107. data/bundler/lib/bundler/man/bundle-platform.1 +5 -27
  108. data/bundler/lib/bundler/man/bundle-plugin.1 +24 -47
  109. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +12 -8
  110. data/bundler/lib/bundler/man/bundle-pristine.1 +5 -16
  111. data/bundler/lib/bundler/man/bundle-remove.1 +4 -14
  112. data/bundler/lib/bundler/man/bundle-show.1 +3 -10
  113. data/bundler/lib/bundler/man/bundle-update.1 +18 -137
  114. data/bundler/lib/bundler/man/bundle-version.1 +3 -16
  115. data/bundler/lib/bundler/man/bundle-viz.1 +4 -16
  116. data/bundler/lib/bundler/man/bundle.1 +5 -44
  117. data/bundler/lib/bundler/man/gemfile.5 +43 -294
  118. data/bundler/lib/bundler/man/gemfile.5.ronn +23 -3
  119. data/bundler/lib/bundler/match_metadata.rb +4 -0
  120. data/bundler/lib/bundler/match_platform.rb +1 -1
  121. data/bundler/lib/bundler/mirror.rb +3 -3
  122. data/bundler/lib/bundler/plugin/api/source.rb +7 -5
  123. data/bundler/lib/bundler/plugin/index.rb +9 -1
  124. data/bundler/lib/bundler/plugin/installer/path.rb +18 -0
  125. data/bundler/lib/bundler/plugin/installer.rb +37 -17
  126. data/bundler/lib/bundler/plugin/source_list.rb +4 -4
  127. data/bundler/lib/bundler/plugin.rb +13 -6
  128. data/bundler/lib/bundler/remote_specification.rb +4 -0
  129. data/bundler/lib/bundler/resolver/base.rb +12 -4
  130. data/bundler/lib/bundler/resolver/candidate.rb +5 -17
  131. data/bundler/lib/bundler/resolver/incompatibility.rb +1 -1
  132. data/bundler/lib/bundler/resolver/package.rb +19 -1
  133. data/bundler/lib/bundler/resolver/spec_group.rb +21 -6
  134. data/bundler/lib/bundler/resolver.rb +174 -64
  135. data/bundler/lib/bundler/retry.rb +2 -2
  136. data/bundler/lib/bundler/ruby_dsl.rb +42 -7
  137. data/bundler/lib/bundler/ruby_version.rb +18 -5
  138. data/bundler/lib/bundler/rubygems_ext.rb +173 -71
  139. data/bundler/lib/bundler/rubygems_gem_installer.rb +56 -57
  140. data/bundler/lib/bundler/rubygems_integration.rb +35 -112
  141. data/bundler/lib/bundler/runtime.rb +5 -10
  142. data/bundler/lib/bundler/safe_marshal.rb +31 -0
  143. data/bundler/lib/bundler/self_manager.rb +49 -11
  144. data/bundler/lib/bundler/settings.rb +136 -49
  145. data/bundler/lib/bundler/setup.rb +10 -1
  146. data/bundler/lib/bundler/shared_helpers.rb +56 -17
  147. data/bundler/lib/bundler/source/git/git_proxy.rb +91 -32
  148. data/bundler/lib/bundler/source/git.rb +108 -39
  149. data/bundler/lib/bundler/source/metadata.rb +17 -15
  150. data/bundler/lib/bundler/source/path.rb +10 -20
  151. data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
  152. data/bundler/lib/bundler/source/rubygems.rb +87 -92
  153. data/bundler/lib/bundler/source.rb +3 -1
  154. data/bundler/lib/bundler/source_list.rb +26 -6
  155. data/bundler/lib/bundler/spec_set.rb +112 -30
  156. data/bundler/lib/bundler/stub_specification.rb +26 -4
  157. data/bundler/lib/bundler/templates/Executable.bundler +1 -1
  158. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
  159. data/bundler/lib/bundler/templates/newgem/README.md.tt +7 -3
  160. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +8 -8
  161. data/bundler/lib/bundler/templates/newgem/bin/console.tt +0 -4
  162. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  163. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +5 -0
  164. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  165. data/bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +4 -4
  166. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +1 -1
  167. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +5 -3
  168. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
  169. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +1 -1
  170. data/bundler/lib/bundler/ui/rg_proxy.rb +1 -1
  171. data/bundler/lib/bundler/ui/shell.rb +25 -3
  172. data/bundler/lib/bundler/ui/silent.rb +12 -1
  173. data/bundler/lib/bundler/uri_credentials_filter.rb +2 -2
  174. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  175. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +53 -6
  176. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +9 -21
  177. data/bundler/lib/bundler/vendor/net-http-persistent/.document +1 -0
  178. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
  179. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
  180. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
  181. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +102 -64
  182. data/bundler/lib/bundler/vendor/pub_grub/.document +1 -0
  183. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +1 -0
  184. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +9 -4
  185. data/bundler/lib/bundler/vendor/securerandom/.document +1 -0
  186. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +373 -0
  187. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +96 -0
  188. data/bundler/lib/bundler/vendor/thor/.document +1 -0
  189. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  190. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  191. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  192. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +8 -10
  193. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +15 -4
  194. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +15 -15
  195. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  196. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  197. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +4 -0
  198. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +16 -25
  199. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  200. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  201. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  202. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
  203. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  204. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
  205. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +44 -6
  206. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  207. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  208. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +26 -150
  209. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
  210. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  211. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +0 -45
  212. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  213. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  214. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  215. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  216. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  217. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  218. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +155 -8
  219. data/bundler/lib/bundler/vendor/tsort/.document +1 -0
  220. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +3 -0
  221. data/bundler/lib/bundler/vendor/uri/.document +1 -0
  222. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +258 -132
  223. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1 -0
  224. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +2 -2
  225. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +96 -32
  226. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  227. data/bundler/lib/bundler/vendored_net_http.rb +23 -0
  228. data/bundler/lib/bundler/vendored_persistent.rb +0 -4
  229. data/bundler/lib/bundler/vendored_securerandom.rb +14 -0
  230. data/bundler/lib/bundler/vendored_timeout.rb +12 -0
  231. data/bundler/lib/bundler/vendored_uri.rb +18 -1
  232. data/bundler/lib/bundler/version.rb +1 -1
  233. data/bundler/lib/bundler/vlad.rb +1 -1
  234. data/bundler/lib/bundler/yaml_serializer.rb +22 -13
  235. data/bundler/lib/bundler.rb +108 -81
  236. data/{bin → exe}/gem +2 -0
  237. data/{bin → exe}/update_rubygems +8 -6
  238. data/lib/rubygems/available_set.rb +6 -5
  239. data/lib/rubygems/basic_specification.rb +81 -44
  240. data/lib/rubygems/bundler_version_finder.rb +6 -6
  241. data/lib/rubygems/ci_detector.rb +75 -0
  242. data/lib/rubygems/command.rb +32 -36
  243. data/lib/rubygems/command_manager.rb +13 -12
  244. data/lib/rubygems/commands/build_command.rb +5 -13
  245. data/lib/rubygems/commands/cert_command.rb +6 -6
  246. data/lib/rubygems/commands/check_command.rb +10 -5
  247. data/lib/rubygems/commands/cleanup_command.rb +15 -26
  248. data/lib/rubygems/commands/contents_command.rb +21 -13
  249. data/lib/rubygems/commands/dependency_command.rb +7 -8
  250. data/lib/rubygems/commands/environment_command.rb +4 -5
  251. data/lib/rubygems/commands/exec_command.rb +3 -7
  252. data/lib/rubygems/commands/fetch_command.rb +17 -2
  253. data/lib/rubygems/commands/generate_index_command.rb +40 -74
  254. data/lib/rubygems/commands/help_command.rb +9 -8
  255. data/lib/rubygems/commands/info_command.rb +2 -2
  256. data/lib/rubygems/commands/install_command.rb +9 -20
  257. data/lib/rubygems/commands/list_command.rb +3 -2
  258. data/lib/rubygems/commands/lock_command.rb +2 -1
  259. data/lib/rubygems/commands/mirror_command.rb +1 -0
  260. data/lib/rubygems/commands/open_command.rb +2 -3
  261. data/lib/rubygems/commands/outdated_command.rb +1 -0
  262. data/lib/rubygems/commands/owner_command.rb +11 -10
  263. data/lib/rubygems/commands/pristine_command.rb +41 -29
  264. data/lib/rubygems/commands/push_command.rb +3 -2
  265. data/lib/rubygems/commands/query_command.rb +5 -5
  266. data/lib/rubygems/commands/rdoc_command.rb +4 -10
  267. data/lib/rubygems/commands/rebuild_command.rb +264 -0
  268. data/lib/rubygems/commands/search_command.rb +3 -2
  269. data/lib/rubygems/commands/server_command.rb +1 -0
  270. data/lib/rubygems/commands/setup_command.rb +41 -39
  271. data/lib/rubygems/commands/signin_command.rb +1 -0
  272. data/lib/rubygems/commands/signout_command.rb +1 -0
  273. data/lib/rubygems/commands/sources_command.rb +15 -14
  274. data/lib/rubygems/commands/specification_command.rb +16 -11
  275. data/lib/rubygems/commands/stale_command.rb +3 -2
  276. data/lib/rubygems/commands/uninstall_command.rb +25 -21
  277. data/lib/rubygems/commands/unpack_command.rb +12 -13
  278. data/lib/rubygems/commands/update_command.rb +26 -30
  279. data/lib/rubygems/commands/which_command.rb +2 -1
  280. data/lib/rubygems/commands/yank_command.rb +3 -2
  281. data/lib/rubygems/compatibility.rb +5 -6
  282. data/lib/rubygems/config_file.rb +95 -30
  283. data/lib/rubygems/core_ext/kernel_gem.rb +2 -4
  284. data/lib/rubygems/core_ext/kernel_require.rb +31 -50
  285. data/lib/rubygems/core_ext/kernel_warn.rb +4 -5
  286. data/lib/rubygems/core_ext/tcpsocket_init.rb +3 -1
  287. data/lib/rubygems/defaults.rb +27 -10
  288. data/lib/rubygems/dependency.rb +25 -30
  289. data/lib/rubygems/dependency_installer.rb +39 -43
  290. data/lib/rubygems/dependency_list.rb +3 -2
  291. data/lib/rubygems/deprecate.rb +80 -75
  292. data/lib/rubygems/doctor.rb +8 -7
  293. data/lib/rubygems/errors.rb +6 -8
  294. data/lib/rubygems/exceptions.rb +15 -5
  295. data/lib/rubygems/ext/build_error.rb +1 -0
  296. data/lib/rubygems/ext/builder.rb +24 -18
  297. data/lib/rubygems/ext/cargo_builder.rb +10 -25
  298. data/lib/rubygems/ext/configure_builder.rb +1 -0
  299. data/lib/rubygems/ext/ext_conf_builder.rb +3 -4
  300. data/lib/rubygems/ext/rake_builder.rb +5 -3
  301. data/lib/rubygems/ext.rb +1 -0
  302. data/lib/rubygems/gem_runner.rb +10 -5
  303. data/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb +163 -0
  304. data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +105 -0
  305. data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +80 -0
  306. data/lib/rubygems/gemcutter_utilities.rb +105 -43
  307. data/lib/rubygems/gemspec_helpers.rb +19 -0
  308. data/lib/rubygems/install_default_message.rb +1 -0
  309. data/lib/rubygems/install_message.rb +1 -0
  310. data/lib/rubygems/install_update_options.rb +20 -20
  311. data/lib/rubygems/installer.rb +112 -85
  312. data/lib/rubygems/installer_uninstaller_utils.rb +0 -2
  313. data/lib/rubygems/local_remote_options.rb +15 -17
  314. data/lib/rubygems/name_tuple.rb +8 -9
  315. data/lib/rubygems/package/digest_io.rb +2 -1
  316. data/lib/rubygems/package/file_source.rb +1 -0
  317. data/lib/rubygems/package/io_source.rb +1 -0
  318. data/lib/rubygems/package/old.rb +3 -2
  319. data/lib/rubygems/package/source.rb +1 -0
  320. data/lib/rubygems/package/tar_header.rb +64 -41
  321. data/lib/rubygems/package/tar_reader/entry.rb +24 -24
  322. data/lib/rubygems/package/tar_reader.rb +15 -10
  323. data/lib/rubygems/package/tar_writer.rb +22 -19
  324. data/lib/rubygems/package.rb +69 -47
  325. data/lib/rubygems/package_task.rb +3 -2
  326. data/lib/rubygems/path_support.rb +11 -11
  327. data/lib/rubygems/platform.rb +73 -50
  328. data/lib/rubygems/psych_tree.rb +1 -0
  329. data/lib/rubygems/query_utils.rb +13 -15
  330. data/lib/rubygems/rdoc.rb +1 -0
  331. data/lib/rubygems/remote_fetcher.rb +30 -22
  332. data/lib/rubygems/request/connection_pools.rb +3 -3
  333. data/lib/rubygems/request/http_pool.rb +1 -0
  334. data/lib/rubygems/request/https_pool.rb +1 -0
  335. data/lib/rubygems/request.rb +29 -25
  336. data/lib/rubygems/request_set/gem_dependency_api.rb +122 -124
  337. data/lib/rubygems/request_set/lockfile/parser.rb +11 -10
  338. data/lib/rubygems/request_set/lockfile/tokenizer.rb +22 -12
  339. data/lib/rubygems/request_set/lockfile.rb +7 -11
  340. data/lib/rubygems/request_set.rb +11 -9
  341. data/lib/rubygems/requirement.rb +16 -10
  342. data/lib/rubygems/resolver/activation_request.rb +5 -8
  343. data/lib/rubygems/resolver/api_set/gem_parser.rb +7 -3
  344. data/lib/rubygems/resolver/api_set.rb +16 -9
  345. data/lib/rubygems/resolver/api_specification.rb +2 -1
  346. data/lib/rubygems/resolver/best_set.rb +1 -28
  347. data/lib/rubygems/resolver/composed_set.rb +2 -1
  348. data/lib/rubygems/resolver/conflict.rb +5 -12
  349. data/lib/rubygems/resolver/current_set.rb +1 -0
  350. data/lib/rubygems/resolver/dependency_request.rb +1 -0
  351. data/lib/rubygems/resolver/git_set.rb +1 -0
  352. data/lib/rubygems/resolver/git_specification.rb +1 -0
  353. data/lib/rubygems/resolver/index_set.rb +5 -4
  354. data/lib/rubygems/resolver/index_specification.rb +3 -2
  355. data/lib/rubygems/resolver/installed_specification.rb +2 -1
  356. data/lib/rubygems/resolver/installer_set.rb +9 -7
  357. data/lib/rubygems/resolver/local_specification.rb +2 -1
  358. data/lib/rubygems/resolver/lock_set.rb +2 -1
  359. data/lib/rubygems/resolver/lock_specification.rb +1 -0
  360. data/lib/rubygems/resolver/requirement_list.rb +1 -0
  361. data/lib/rubygems/resolver/set.rb +1 -0
  362. data/lib/rubygems/resolver/source_set.rb +2 -0
  363. data/lib/rubygems/resolver/spec_specification.rb +8 -0
  364. data/lib/rubygems/resolver/specification.rb +1 -0
  365. data/lib/rubygems/resolver/stats.rb +1 -0
  366. data/lib/rubygems/resolver/vendor_set.rb +1 -0
  367. data/lib/rubygems/resolver/vendor_specification.rb +1 -0
  368. data/lib/rubygems/resolver.rb +11 -17
  369. data/lib/rubygems/s3_uri_signer.rb +13 -11
  370. data/lib/rubygems/safe_marshal/elements.rb +146 -0
  371. data/lib/rubygems/safe_marshal/reader.rb +308 -0
  372. data/lib/rubygems/safe_marshal/visitors/stream_printer.rb +31 -0
  373. data/lib/rubygems/safe_marshal/visitors/to_ruby.rb +415 -0
  374. data/lib/rubygems/safe_marshal/visitors/visitor.rb +74 -0
  375. data/lib/rubygems/safe_marshal.rb +74 -0
  376. data/lib/rubygems/safe_yaml.rb +14 -26
  377. data/lib/rubygems/security/policies.rb +37 -38
  378. data/lib/rubygems/security/policy.rb +8 -11
  379. data/lib/rubygems/security/signer.rb +12 -3
  380. data/lib/rubygems/security/trust_dir.rb +10 -11
  381. data/lib/rubygems/security.rb +12 -25
  382. data/lib/rubygems/security_option.rb +2 -1
  383. data/lib/rubygems/shellwords.rb +3 -0
  384. data/lib/rubygems/source/git.rb +10 -10
  385. data/lib/rubygems/source/installed.rb +4 -3
  386. data/lib/rubygems/source/local.rb +48 -48
  387. data/lib/rubygems/source/lock.rb +2 -3
  388. data/lib/rubygems/source/specific_file.rb +6 -4
  389. data/lib/rubygems/source/vendor.rb +1 -2
  390. data/lib/rubygems/source.rb +28 -22
  391. data/lib/rubygems/source_list.rb +8 -8
  392. data/lib/rubygems/spec_fetcher.rb +46 -56
  393. data/lib/rubygems/specification.rb +252 -309
  394. data/lib/rubygems/specification_policy.rb +120 -67
  395. data/lib/rubygems/specification_record.rb +212 -0
  396. data/lib/rubygems/stub_specification.rb +48 -22
  397. data/lib/rubygems/text.rb +1 -2
  398. data/lib/rubygems/uninstaller.rb +52 -32
  399. data/lib/rubygems/update_suggestion.rb +6 -19
  400. data/lib/rubygems/uri.rb +6 -6
  401. data/lib/rubygems/uri_formatter.rb +1 -1
  402. data/lib/rubygems/user_interaction.rb +23 -27
  403. data/lib/rubygems/util/licenses.rb +297 -35
  404. data/lib/rubygems/util/list.rb +4 -1
  405. data/lib/rubygems/util.rb +9 -6
  406. data/lib/rubygems/validator.rb +11 -10
  407. data/lib/rubygems/vendor/molinillo/.document +1 -0
  408. data/lib/rubygems/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
  409. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/delegates/specification_provider.rb +11 -11
  410. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/action.rb +1 -1
  411. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  412. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  413. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  414. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  415. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/log.rb +1 -1
  416. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  417. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  418. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/vertex.rb +1 -1
  419. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  420. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/errors.rb +1 -1
  421. data/lib/rubygems/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
  422. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/specification_provider.rb +2 -2
  423. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/ui.rb +1 -1
  424. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolution.rb +4 -4
  425. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolver.rb +1 -1
  426. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/state.rb +1 -1
  427. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo.rb +2 -2
  428. data/lib/rubygems/vendor/net-http/.document +1 -0
  429. data/lib/rubygems/vendor/net-http/LICENSE.txt +22 -0
  430. data/lib/rubygems/vendor/net-http/lib/net/http/backward.rb +40 -0
  431. data/lib/rubygems/vendor/net-http/lib/net/http/exceptions.rb +34 -0
  432. data/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb +414 -0
  433. data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +981 -0
  434. data/lib/rubygems/vendor/net-http/lib/net/http/proxy_delta.rb +17 -0
  435. data/lib/rubygems/vendor/net-http/lib/net/http/request.rb +88 -0
  436. data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +425 -0
  437. data/lib/rubygems/vendor/net-http/lib/net/http/response.rb +738 -0
  438. data/lib/rubygems/vendor/net-http/lib/net/http/responses.rb +1174 -0
  439. data/lib/rubygems/vendor/net-http/lib/net/http/status.rb +84 -0
  440. data/lib/rubygems/vendor/net-http/lib/net/http.rb +2496 -0
  441. data/lib/rubygems/vendor/net-http/lib/net/https.rb +23 -0
  442. data/lib/rubygems/vendor/net-protocol/.document +1 -0
  443. data/lib/rubygems/vendor/net-protocol/LICENSE.txt +22 -0
  444. data/lib/rubygems/vendor/net-protocol/lib/net/protocol.rb +544 -0
  445. data/lib/rubygems/vendor/optparse/.document +1 -0
  446. data/lib/rubygems/vendor/optparse/lib/optparse/uri.rb +7 -0
  447. data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse.rb +49 -27
  448. data/lib/rubygems/vendor/resolv/.document +1 -0
  449. data/lib/rubygems/vendor/resolv/LICENSE.txt +22 -0
  450. data/lib/rubygems/vendor/resolv/lib/resolv.rb +3442 -0
  451. data/lib/rubygems/vendor/securerandom/.document +1 -0
  452. data/lib/rubygems/vendor/securerandom/LICENSE.txt +22 -0
  453. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +373 -0
  454. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +96 -0
  455. data/lib/rubygems/vendor/timeout/.document +1 -0
  456. data/lib/rubygems/vendor/timeout/LICENSE.txt +22 -0
  457. data/lib/rubygems/vendor/timeout/lib/timeout.rb +199 -0
  458. data/lib/rubygems/vendor/tsort/.document +1 -0
  459. data/lib/rubygems/vendor/tsort/LICENSE.txt +22 -0
  460. data/lib/rubygems/{tsort → vendor/tsort}/lib/tsort.rb +5 -2
  461. data/lib/rubygems/vendor/uri/.document +1 -0
  462. data/lib/rubygems/vendor/uri/LICENSE.txt +22 -0
  463. data/lib/rubygems/vendor/uri/lib/uri/common.rb +855 -0
  464. data/lib/rubygems/vendor/uri/lib/uri/file.rb +100 -0
  465. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +267 -0
  466. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +1588 -0
  467. data/lib/rubygems/vendor/uri/lib/uri/http.rb +125 -0
  468. data/lib/rubygems/vendor/uri/lib/uri/https.rb +23 -0
  469. data/lib/rubygems/vendor/uri/lib/uri/ldap.rb +261 -0
  470. data/lib/rubygems/vendor/uri/lib/uri/ldaps.rb +22 -0
  471. data/lib/rubygems/vendor/uri/lib/uri/mailto.rb +293 -0
  472. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
  473. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +183 -0
  474. data/lib/rubygems/vendor/uri/lib/uri/version.rb +6 -0
  475. data/lib/rubygems/vendor/uri/lib/uri/ws.rb +83 -0
  476. data/lib/rubygems/vendor/uri/lib/uri/wss.rb +23 -0
  477. data/lib/rubygems/vendor/uri/lib/uri.rb +104 -0
  478. data/lib/rubygems/vendored_molinillo.rb +3 -0
  479. data/lib/rubygems/vendored_net_http.rb +5 -0
  480. data/lib/rubygems/vendored_optparse.rb +3 -0
  481. data/lib/rubygems/vendored_securerandom.rb +4 -0
  482. data/lib/rubygems/vendored_timeout.rb +5 -0
  483. data/lib/rubygems/vendored_tsort.rb +3 -0
  484. data/lib/rubygems/version.rb +38 -31
  485. data/lib/rubygems/version_option.rb +3 -5
  486. data/lib/rubygems/yaml_serializer.rb +98 -0
  487. data/lib/rubygems.rb +99 -72
  488. data/rubygems-update.gemspec +15 -8
  489. data/setup.rb +4 -1
  490. metadata +169 -267
  491. data/lib/rubygems/indexer.rb +0 -427
  492. data/lib/rubygems/mock_gem_ui.rb +0 -85
  493. data/lib/rubygems/optparse/lib/optparse/uri.rb +0 -7
  494. data/lib/rubygems/optparse.rb +0 -3
  495. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  496. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  497. data/lib/rubygems/resolver/molinillo.rb +0 -2
  498. data/lib/rubygems/tsort.rb +0 -3
  499. data/test/rubygems/alternate_cert.pem +0 -19
  500. data/test/rubygems/alternate_cert_32.pem +0 -19
  501. data/test/rubygems/alternate_key.pem +0 -27
  502. data/test/rubygems/bad_rake.rb +0 -2
  503. data/test/rubygems/bundler_test_gem.rb +0 -419
  504. data/test/rubygems/ca_cert.pem +0 -77
  505. data/test/rubygems/child_cert.pem +0 -19
  506. data/test/rubygems/child_cert_32.pem +0 -19
  507. data/test/rubygems/child_key.pem +0 -27
  508. data/test/rubygems/client.pem +0 -107
  509. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  510. data/test/rubygems/data/gem-private_key.pem +0 -27
  511. data/test/rubygems/data/gem-public_cert.pem +0 -20
  512. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  513. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  514. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  515. data/test/rubygems/encrypted_private_key.pem +0 -30
  516. data/test/rubygems/expired_cert.pem +0 -19
  517. data/test/rubygems/fake_certlib/openssl.rb +0 -8
  518. data/test/rubygems/foo/discover.rb +0 -1
  519. data/test/rubygems/future_cert.pem +0 -19
  520. data/test/rubygems/future_cert_32.pem +0 -19
  521. data/test/rubygems/good_rake.rb +0 -2
  522. data/test/rubygems/grandchild_cert.pem +0 -19
  523. data/test/rubygems/grandchild_cert_32.pem +0 -19
  524. data/test/rubygems/grandchild_key.pem +0 -27
  525. data/test/rubygems/helper.rb +0 -1629
  526. data/test/rubygems/installer_test_case.rb +0 -247
  527. data/test/rubygems/invalid_client.pem +0 -49
  528. data/test/rubygems/invalid_issuer_cert.pem +0 -20
  529. data/test/rubygems/invalid_issuer_cert_32.pem +0 -20
  530. data/test/rubygems/invalid_key.pem +0 -27
  531. data/test/rubygems/invalid_signer_cert.pem +0 -19
  532. data/test/rubygems/invalid_signer_cert_32.pem +0 -19
  533. data/test/rubygems/invalidchild_cert.pem +0 -19
  534. data/test/rubygems/invalidchild_cert_32.pem +0 -19
  535. data/test/rubygems/invalidchild_key.pem +0 -27
  536. data/test/rubygems/package/tar_test_case.rb +0 -174
  537. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  538. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  539. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  540. data/test/rubygems/plugin/exception/rubygems_plugin.rb +0 -3
  541. data/test/rubygems/plugin/load/rubygems_plugin.rb +0 -4
  542. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +0 -3
  543. data/test/rubygems/private3072_key.pem +0 -40
  544. data/test/rubygems/private_ec_key.pem +0 -9
  545. data/test/rubygems/private_key.pem +0 -27
  546. data/test/rubygems/public3072_cert.pem +0 -25
  547. data/test/rubygems/public_cert.pem +0 -20
  548. data/test/rubygems/public_cert_32.pem +0 -19
  549. data/test/rubygems/public_key.pem +0 -9
  550. data/test/rubygems/rubygems/commands/crash_command.rb +0 -4
  551. data/test/rubygems/rubygems_plugin.rb +0 -23
  552. data/test/rubygems/sff/discover.rb +0 -1
  553. data/test/rubygems/simple_gem.rb +0 -67
  554. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -7
  555. data/test/rubygems/specifications/foo-0.0.1-x86-mswin32.gemspec +0 -0
  556. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +0 -12
  557. data/test/rubygems/ssl_cert.pem +0 -80
  558. data/test/rubygems/ssl_key.pem +0 -27
  559. data/test/rubygems/test_bundled_ca.rb +0 -60
  560. data/test/rubygems/test_config.rb +0 -27
  561. data/test/rubygems/test_deprecate.rb +0 -157
  562. data/test/rubygems/test_exit.rb +0 -17
  563. data/test/rubygems/test_gem.rb +0 -1766
  564. data/test/rubygems/test_gem_available_set.rb +0 -129
  565. data/test/rubygems/test_gem_bundler_version_finder.rb +0 -126
  566. data/test/rubygems/test_gem_command.rb +0 -400
  567. data/test/rubygems/test_gem_command_manager.rb +0 -399
  568. data/test/rubygems/test_gem_commands_build_command.rb +0 -737
  569. data/test/rubygems/test_gem_commands_cert_command.rb +0 -865
  570. data/test/rubygems/test_gem_commands_check_command.rb +0 -67
  571. data/test/rubygems/test_gem_commands_cleanup_command.rb +0 -291
  572. data/test/rubygems/test_gem_commands_contents_command.rb +0 -270
  573. data/test/rubygems/test_gem_commands_dependency_command.rb +0 -227
  574. data/test/rubygems/test_gem_commands_environment_command.rb +0 -167
  575. data/test/rubygems/test_gem_commands_exec_command.rb +0 -851
  576. data/test/rubygems/test_gem_commands_fetch_command.rb +0 -257
  577. data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -80
  578. data/test/rubygems/test_gem_commands_help_command.rb +0 -93
  579. data/test/rubygems/test_gem_commands_info_command.rb +0 -69
  580. data/test/rubygems/test_gem_commands_install_command.rb +0 -1572
  581. data/test/rubygems/test_gem_commands_list_command.rb +0 -32
  582. data/test/rubygems/test_gem_commands_lock_command.rb +0 -66
  583. data/test/rubygems/test_gem_commands_mirror.rb +0 -19
  584. data/test/rubygems/test_gem_commands_open_command.rb +0 -97
  585. data/test/rubygems/test_gem_commands_outdated_command.rb +0 -49
  586. data/test/rubygems/test_gem_commands_owner_command.rb +0 -407
  587. data/test/rubygems/test_gem_commands_pristine_command.rb +0 -707
  588. data/test/rubygems/test_gem_commands_push_command.rb +0 -498
  589. data/test/rubygems/test_gem_commands_query_command.rb +0 -857
  590. data/test/rubygems/test_gem_commands_search_command.rb +0 -15
  591. data/test/rubygems/test_gem_commands_server_command.rb +0 -19
  592. data/test/rubygems/test_gem_commands_setup_command.rb +0 -474
  593. data/test/rubygems/test_gem_commands_signin_command.rb +0 -258
  594. data/test/rubygems/test_gem_commands_signout_command.rb +0 -30
  595. data/test/rubygems/test_gem_commands_sources_command.rb +0 -533
  596. data/test/rubygems/test_gem_commands_specification_command.rb +0 -276
  597. data/test/rubygems/test_gem_commands_stale_command.rb +0 -42
  598. data/test/rubygems/test_gem_commands_uninstall_command.rb +0 -521
  599. data/test/rubygems/test_gem_commands_unpack_command.rb +0 -223
  600. data/test/rubygems/test_gem_commands_update_command.rb +0 -835
  601. data/test/rubygems/test_gem_commands_which_command.rb +0 -84
  602. data/test/rubygems/test_gem_commands_yank_command.rb +0 -180
  603. data/test/rubygems/test_gem_config_file.rb +0 -516
  604. data/test/rubygems/test_gem_dependency.rb +0 -397
  605. data/test/rubygems/test_gem_dependency_installer.rb +0 -1155
  606. data/test/rubygems/test_gem_dependency_list.rb +0 -264
  607. data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -26
  608. data/test/rubygems/test_gem_doctor.rb +0 -194
  609. data/test/rubygems/test_gem_ext_builder.rb +0 -336
  610. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +0 -1
  611. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +0 -8
  612. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +0 -233
  613. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +0 -10
  614. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +0 -27
  615. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +0 -1
  616. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +0 -1
  617. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +0 -247
  618. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +0 -10
  619. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +0 -8
  620. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +0 -51
  621. data/test/rubygems/test_gem_ext_cargo_builder.rb +0 -166
  622. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +0 -33
  623. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +0 -60
  624. data/test/rubygems/test_gem_ext_cmake_builder.rb +0 -83
  625. data/test/rubygems/test_gem_ext_configure_builder.rb +0 -79
  626. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +0 -229
  627. data/test/rubygems/test_gem_ext_rake_builder.rb +0 -112
  628. data/test/rubygems/test_gem_gem_runner.rb +0 -118
  629. data/test/rubygems/test_gem_gemcutter_utilities.rb +0 -276
  630. data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -59
  631. data/test/rubygems/test_gem_indexer.rb +0 -380
  632. data/test/rubygems/test_gem_install_update_options.rb +0 -207
  633. data/test/rubygems/test_gem_installer.rb +0 -2463
  634. data/test/rubygems/test_gem_local_remote_options.rb +0 -132
  635. data/test/rubygems/test_gem_name_tuple.rb +0 -42
  636. data/test/rubygems/test_gem_package.rb +0 -1190
  637. data/test/rubygems/test_gem_package_old.rb +0 -90
  638. data/test/rubygems/test_gem_package_tar_header.rb +0 -225
  639. data/test/rubygems/test_gem_package_tar_reader.rb +0 -134
  640. data/test/rubygems/test_gem_package_tar_reader_entry.rb +0 -297
  641. data/test/rubygems/test_gem_package_tar_writer.rb +0 -330
  642. data/test/rubygems/test_gem_package_task.rb +0 -117
  643. data/test/rubygems/test_gem_path_support.rb +0 -138
  644. data/test/rubygems/test_gem_platform.rb +0 -496
  645. data/test/rubygems/test_gem_rdoc.rb +0 -136
  646. data/test/rubygems/test_gem_remote_fetcher.rb +0 -1226
  647. data/test/rubygems/test_gem_request.rb +0 -541
  648. data/test/rubygems/test_gem_request_connection_pools.rb +0 -150
  649. data/test/rubygems/test_gem_request_set.rb +0 -671
  650. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +0 -845
  651. data/test/rubygems/test_gem_request_set_lockfile.rb +0 -468
  652. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +0 -543
  653. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +0 -306
  654. data/test/rubygems/test_gem_requirement.rb +0 -504
  655. data/test/rubygems/test_gem_resolver.rb +0 -858
  656. data/test/rubygems/test_gem_resolver_activation_request.rb +0 -42
  657. data/test/rubygems/test_gem_resolver_api_set.rb +0 -209
  658. data/test/rubygems/test_gem_resolver_api_specification.rb +0 -166
  659. data/test/rubygems/test_gem_resolver_best_set.rb +0 -158
  660. data/test/rubygems/test_gem_resolver_composed_set.rb +0 -43
  661. data/test/rubygems/test_gem_resolver_conflict.rb +0 -81
  662. data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -82
  663. data/test/rubygems/test_gem_resolver_git_set.rb +0 -187
  664. data/test/rubygems/test_gem_resolver_git_specification.rb +0 -113
  665. data/test/rubygems/test_gem_resolver_index_set.rb +0 -87
  666. data/test/rubygems/test_gem_resolver_index_specification.rb +0 -92
  667. data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -46
  668. data/test/rubygems/test_gem_resolver_installer_set.rb +0 -319
  669. data/test/rubygems/test_gem_resolver_local_specification.rb +0 -43
  670. data/test/rubygems/test_gem_resolver_lock_set.rb +0 -61
  671. data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -97
  672. data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -18
  673. data/test/rubygems/test_gem_resolver_specification.rb +0 -62
  674. data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -81
  675. data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -81
  676. data/test/rubygems/test_gem_security.rb +0 -340
  677. data/test/rubygems/test_gem_security_policy.rb +0 -535
  678. data/test/rubygems/test_gem_security_signer.rb +0 -217
  679. data/test/rubygems/test_gem_security_trust_dir.rb +0 -98
  680. data/test/rubygems/test_gem_silent_ui.rb +0 -122
  681. data/test/rubygems/test_gem_source.rb +0 -253
  682. data/test/rubygems/test_gem_source_fetch_problem.rb +0 -36
  683. data/test/rubygems/test_gem_source_git.rb +0 -309
  684. data/test/rubygems/test_gem_source_installed.rb +0 -34
  685. data/test/rubygems/test_gem_source_list.rb +0 -118
  686. data/test/rubygems/test_gem_source_local.rb +0 -106
  687. data/test/rubygems/test_gem_source_lock.rb +0 -112
  688. data/test/rubygems/test_gem_source_specific_file.rb +0 -75
  689. data/test/rubygems/test_gem_source_subpath_problem.rb +0 -49
  690. data/test/rubygems/test_gem_source_vendor.rb +0 -29
  691. data/test/rubygems/test_gem_spec_fetcher.rb +0 -337
  692. data/test/rubygems/test_gem_specification.rb +0 -3811
  693. data/test/rubygems/test_gem_stream_ui.rb +0 -224
  694. data/test/rubygems/test_gem_stub_specification.rb +0 -277
  695. data/test/rubygems/test_gem_text.rb +0 -102
  696. data/test/rubygems/test_gem_uninstaller.rb +0 -674
  697. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -30
  698. data/test/rubygems/test_gem_update_suggestion.rb +0 -208
  699. data/test/rubygems/test_gem_uri.rb +0 -39
  700. data/test/rubygems/test_gem_uri_formatter.rb +0 -26
  701. data/test/rubygems/test_gem_util.rb +0 -90
  702. data/test/rubygems/test_gem_validator.rb +0 -42
  703. data/test/rubygems/test_gem_version.rb +0 -302
  704. data/test/rubygems/test_gem_version_option.rb +0 -164
  705. data/test/rubygems/test_kernel.rb +0 -123
  706. data/test/rubygems/test_project_sanity.rb +0 -20
  707. data/test/rubygems/test_remote_fetch_error.rb +0 -19
  708. data/test/rubygems/test_require.rb +0 -733
  709. data/test/rubygems/test_rubygems.rb +0 -74
  710. data/test/rubygems/utilities.rb +0 -393
  711. data/test/rubygems/wrong_key_cert.pem +0 -19
  712. data/test/rubygems/wrong_key_cert_32.pem +0 -19
  713. data/test/test_changelog_generator.rb +0 -17
  714. /data/{lib/rubygems/optparse → bundler/lib/bundler/vendor/connection_pool}/.document +0 -0
  715. /data/{lib/rubygems/tsort → bundler/lib/bundler/vendor/fileutils}/.document +0 -0
  716. /data/{lib/rubygems/tsort → bundler/lib/bundler/vendor/securerandom}/LICENSE.txt +0 -0
  717. /data/lib/rubygems/{resolver → vendor}/molinillo/LICENSE +0 -0
  718. /data/lib/rubygems/{optparse → vendor/optparse}/COPYING +0 -0
  719. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optionparser.rb +0 -0
  720. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/ac.rb +0 -0
  721. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/date.rb +0 -0
  722. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/kwargs.rb +0 -0
  723. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/shellwords.rb +0 -0
  724. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/time.rb +0 -0
  725. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/version.rb +0 -0
@@ -1,1629 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubygems"
4
-
5
- begin
6
- gem "test-unit", "~> 3.0"
7
- rescue Gem::LoadError
8
- end
9
-
10
- require "test/unit"
11
-
12
- ENV["JARS_SKIP"] = "true" if Gem.java_platform? # avoid unnecessary and noisy `jar-dependencies` post install hook
13
-
14
- require "rubygems/deprecate"
15
-
16
- require "fileutils"
17
- require "pathname"
18
- require "pp"
19
- require "rubygems/package"
20
- require "shellwords"
21
- require "tmpdir"
22
- require "uri"
23
- require "zlib"
24
- require "benchmark" # stdlib
25
- require "rubygems/mock_gem_ui"
26
-
27
- module Gem
28
-
29
- ##
30
- # Allows setting the gem path searcher.
31
-
32
- def self.searcher=(searcher)
33
- @searcher = searcher
34
- end
35
-
36
- ##
37
- # Allows toggling Windows behavior.
38
-
39
- def self.win_platform=(val)
40
- @@win_platform = val
41
- end
42
-
43
- ##
44
- # Allows setting path to Ruby.
45
-
46
- def self.ruby=(ruby)
47
- @ruby = ruby
48
- end
49
-
50
- ##
51
- # Sets the default user interaction to a MockGemUi.
52
-
53
- module DefaultUserInteraction
54
- @ui = Gem::MockGemUi.new
55
- end
56
- end
57
-
58
- require "rubygems/command"
59
-
60
- class Gem::Command
61
- ##
62
- # Allows resetting the hash of specific args per command.
63
-
64
- def self.specific_extra_args_hash=(value)
65
- @specific_extra_args_hash = value
66
- end
67
- end
68
-
69
- ##
70
- # RubyGemTestCase provides a variety of methods for testing rubygems and
71
- # gem-related behavior in a sandbox. Through RubyGemTestCase you can install
72
- # and uninstall gems, fetch remote gems through a stub fetcher and be assured
73
- # your normal set of gems is not affected.
74
-
75
- class Gem::TestCase < Test::Unit::TestCase
76
- extend Gem::Deprecate
77
-
78
- attr_accessor :fetcher # :nodoc:
79
-
80
- attr_accessor :gem_repo # :nodoc:
81
-
82
- attr_accessor :uri # :nodoc:
83
-
84
- def assert_activate(expected, *specs)
85
- specs.each do |spec|
86
- case spec
87
- when String then
88
- Gem::Specification.find_by_name(spec).activate
89
- when Gem::Specification then
90
- spec.activate
91
- else
92
- flunk spec.inspect
93
- end
94
- end
95
-
96
- loaded = Gem.loaded_specs.values.map(&:full_name)
97
-
98
- assert_equal expected.sort, loaded.sort if expected
99
- end
100
-
101
- def assert_directory_exists(path, msg = nil)
102
- msg = build_message(msg, "Expected path '#{path}' to be a directory")
103
- assert_path_exist path
104
- assert File.directory?(path), msg
105
- end
106
-
107
- def refute_directory_exists(path, msg = nil)
108
- msg = build_message(msg, "Expected path '#{path}' not to be a directory")
109
- assert_path_not_exist path
110
- refute File.directory?(path), msg
111
- end
112
-
113
- # https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L188
114
- def _synchronize
115
- yield
116
- end
117
-
118
- # https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L546
119
- def capture_subprocess_io
120
- _synchronize do
121
- begin
122
- require "tempfile"
123
-
124
- captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
125
-
126
- orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
127
- $stdout.reopen captured_stdout
128
- $stderr.reopen captured_stderr
129
-
130
- yield
131
-
132
- $stdout.rewind
133
- $stderr.rewind
134
-
135
- return captured_stdout.read, captured_stderr.read
136
- ensure
137
- $stdout.reopen orig_stdout
138
- $stderr.reopen orig_stderr
139
-
140
- orig_stdout.close
141
- orig_stderr.close
142
- captured_stdout.close!
143
- captured_stderr.close!
144
- end
145
- end
146
- end
147
-
148
- ##
149
- # Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
150
- # the original value when the block ends
151
-
152
- def enable_shared(value)
153
- enable_shared = RbConfig::CONFIG["ENABLE_SHARED"]
154
- RbConfig::CONFIG["ENABLE_SHARED"] = value
155
-
156
- yield
157
- ensure
158
- if enable_shared
159
- RbConfig::CONFIG["ENABLE_SHARED"] = enable_shared
160
- else
161
- RbConfig::CONFIG.delete "ENABLE_SHARED"
162
- end
163
- end
164
-
165
- ##
166
- # Sets the vendordir entry in RbConfig::CONFIG to +value+ and restores the
167
- # original value when the block ends
168
- #
169
- def vendordir(value)
170
- vendordir = RbConfig::CONFIG["vendordir"]
171
-
172
- if value
173
- RbConfig::CONFIG["vendordir"] = value
174
- else
175
- RbConfig::CONFIG.delete "vendordir"
176
- end
177
-
178
- yield
179
- ensure
180
- if vendordir
181
- RbConfig::CONFIG["vendordir"] = vendordir
182
- else
183
- RbConfig::CONFIG.delete "vendordir"
184
- end
185
- end
186
-
187
- ##
188
- # Sets the bindir entry in RbConfig::CONFIG to +value+ and restores the
189
- # original value when the block ends
190
- #
191
- def bindir(value)
192
- with_clean_path_to_ruby do
193
- bindir = RbConfig::CONFIG["bindir"]
194
-
195
- if value
196
- RbConfig::CONFIG["bindir"] = value
197
- else
198
- RbConfig::CONFIG.delete "bindir"
199
- end
200
-
201
- begin
202
- yield
203
- ensure
204
- if bindir
205
- RbConfig::CONFIG["bindir"] = bindir
206
- else
207
- RbConfig::CONFIG.delete "bindir"
208
- end
209
- end
210
- end
211
- end
212
-
213
- ##
214
- # Sets the EXEEXT entry in RbConfig::CONFIG to +value+ and restores the
215
- # original value when the block ends
216
- #
217
- def exeext(value)
218
- exeext = RbConfig::CONFIG["EXEEXT"]
219
-
220
- if value
221
- RbConfig::CONFIG["EXEEXT"] = value
222
- else
223
- RbConfig::CONFIG.delete "EXEEXT"
224
- end
225
-
226
- yield
227
- ensure
228
- if exeext
229
- RbConfig::CONFIG["EXEEXT"] = exeext
230
- else
231
- RbConfig::CONFIG.delete "EXEEXT"
232
- end
233
- end
234
-
235
- def scan_make_command_lines(output)
236
- output.scan(/^#{Regexp.escape make_command}(?:[[:blank:]].*)?$/)
237
- end
238
-
239
- def parse_make_command_line_targets(line)
240
- args = line.sub(/^#{Regexp.escape make_command}/, "").shellsplit
241
-
242
- targets = []
243
-
244
- args.each do |arg|
245
- case arg
246
- when /\A(\w+)=/
247
- else
248
- targets << arg
249
- end
250
- end
251
-
252
- targets << "" if targets.empty?
253
-
254
- targets
255
- end
256
-
257
- def assert_contains_make_command(target, output, msg = nil)
258
- if output.include?("\n")
259
- msg = build_message(msg,
260
- "Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_OUTPUT" % [
261
- ("%s %s" % [make_command, target]).rstrip,
262
- output,
263
- ]
264
- )
265
- else
266
- msg = build_message(msg,
267
- 'Expected make command "%s", but was "%s"' % [
268
- ("%s %s" % [make_command, target]).rstrip,
269
- output,
270
- ]
271
- )
272
- end
273
-
274
- assert scan_make_command_lines(output).any? {|line|
275
- targets = parse_make_command_line_targets(line)
276
-
277
- if targets.include?(target)
278
- true
279
- else
280
- false
281
- end
282
- }, msg
283
- end
284
-
285
- include Gem::DefaultUserInteraction
286
-
287
- ##
288
- # #setup prepares a sandboxed location to install gems. All installs are
289
- # directed to a temporary directory. All install plugins are removed.
290
- #
291
- # If the +RUBY+ environment variable is set the given path is used for
292
- # Gem::ruby. The local platform is set to <tt>i386-mswin32</tt> for Windows
293
- # or <tt>i686-darwin8.10.1</tt> otherwise.
294
-
295
- def setup
296
- @orig_hooks = {}
297
- @orig_env = ENV.to_hash
298
- @tmp = File.expand_path("tmp")
299
-
300
- FileUtils.mkdir_p @tmp
301
-
302
- @tempdir = Dir.mktmpdir("test_rubygems_", @tmp)
303
- @tempdir.tap(&Gem::UNTAINT)
304
-
305
- ENV["GEM_VENDOR"] = nil
306
- ENV["GEMRC"] = nil
307
- ENV["XDG_CACHE_HOME"] = nil
308
- ENV["XDG_CONFIG_HOME"] = nil
309
- ENV["XDG_DATA_HOME"] = nil
310
- ENV["XDG_STATE_HOME"] = nil
311
- ENV["SOURCE_DATE_EPOCH"] = nil
312
- ENV["BUNDLER_VERSION"] = nil
313
- ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "true"
314
-
315
- @current_dir = Dir.pwd
316
- @fetcher = nil
317
-
318
- @back_ui = Gem::DefaultUserInteraction.ui
319
- @ui = Gem::MockGemUi.new
320
- # This needs to be a new instance since we call use_ui(@ui) when we want to
321
- # capture output
322
- Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new
323
-
324
- @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
325
- Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
326
- Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
327
- File.join(@tempdir, "system-gemrc")
328
-
329
- @gemhome = File.join @tempdir, "gemhome"
330
- @userhome = File.join @tempdir, "userhome"
331
- @statehome = File.join @tempdir, "statehome"
332
- ENV["GEM_SPEC_CACHE"] = File.join @tempdir, "spec_cache"
333
-
334
- @orig_ruby = if ENV["RUBY"]
335
- ruby = Gem.ruby
336
- Gem.ruby = ENV["RUBY"]
337
- ruby
338
- end
339
-
340
- @git = ENV["GIT"] || "git#{RbConfig::CONFIG['EXEEXT']}"
341
-
342
- Gem.ensure_gem_subdirectories @gemhome
343
- Gem.ensure_default_gem_subdirectories @gemhome
344
-
345
- @orig_LOAD_PATH = $LOAD_PATH.dup
346
- $LOAD_PATH.map! do |s|
347
- expand_path = File.realpath(s) rescue File.expand_path(s)
348
- if expand_path != s
349
- expand_path.tap(&Gem::UNTAINT)
350
- if s.instance_variable_defined?(:@gem_prelude_index)
351
- expand_path.instance_variable_set(:@gem_prelude_index, expand_path)
352
- end
353
- expand_path.freeze if s.frozen?
354
- s = expand_path
355
- end
356
- s
357
- end
358
-
359
- Dir.chdir @tempdir
360
-
361
- ENV["HOME"] = @userhome
362
- Gem.instance_variable_set :@config_file, nil
363
- Gem.instance_variable_set :@user_home, nil
364
- Gem.instance_variable_set :@config_home, nil
365
- Gem.instance_variable_set :@data_home, nil
366
- Gem.instance_variable_set :@state_home, @statehome
367
- Gem.instance_variable_set :@gemdeps, nil
368
- Gem.instance_variable_set :@env_requirements_by_name, nil
369
- Gem.send :remove_instance_variable, :@ruby_version if
370
- Gem.instance_variables.include? :@ruby_version
371
-
372
- FileUtils.mkdir_p @userhome
373
-
374
- ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = PRIVATE_KEY_PASSPHRASE
375
-
376
- Gem.instance_variable_set(:@default_specifications_dir, nil)
377
- if Gem.java_platform?
378
- @orig_default_gem_home = RbConfig::CONFIG["default_gem_home"]
379
- RbConfig::CONFIG["default_gem_home"] = @gemhome
380
- else
381
- Gem.instance_variable_set(:@default_dir, @gemhome)
382
- end
383
-
384
- @orig_bindir = RbConfig::CONFIG["bindir"]
385
- RbConfig::CONFIG["bindir"] = File.join @gemhome, "bin"
386
-
387
- @orig_sitelibdir = RbConfig::CONFIG["sitelibdir"]
388
- new_sitelibdir = @orig_sitelibdir.sub(RbConfig::CONFIG["prefix"], @gemhome)
389
- $LOAD_PATH.insert(Gem.load_path_insert_index, new_sitelibdir)
390
- RbConfig::CONFIG["sitelibdir"] = new_sitelibdir
391
-
392
- @orig_mandir = RbConfig::CONFIG["mandir"]
393
- RbConfig::CONFIG["mandir"] = File.join @gemhome, "share", "man"
394
-
395
- Gem::Specification.unresolved_deps.clear
396
- Gem.use_paths(@gemhome)
397
-
398
- Gem.loaded_specs.clear
399
- Gem.instance_variable_set(:@activated_gem_paths, 0)
400
- Gem.clear_default_specs
401
-
402
- Gem.configuration.verbose = true
403
- Gem.configuration.update_sources = true
404
-
405
- Gem::RemoteFetcher.fetcher = Gem::FakeFetcher.new
406
-
407
- @gem_repo = "http://gems.example.com/"
408
- @uri = URI.parse @gem_repo
409
- Gem.sources.replace [@gem_repo]
410
-
411
- Gem.searcher = nil
412
- Gem::SpecFetcher.fetcher = nil
413
-
414
- @orig_arch = RbConfig::CONFIG["arch"]
415
-
416
- if win_platform?
417
- util_set_arch "i386-mswin32"
418
- else
419
- util_set_arch "i686-darwin8.10.1"
420
- end
421
-
422
- %w[post_install_hooks done_installing_hooks post_uninstall_hooks pre_uninstall_hooks pre_install_hooks pre_reset_hooks post_reset_hooks post_build_hooks].each do |name|
423
- @orig_hooks[name] = Gem.send(name).dup
424
- end
425
-
426
- @marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
427
- @orig_LOADED_FEATURES = $LOADED_FEATURES.dup
428
- end
429
-
430
- ##
431
- # #teardown restores the process to its original state and removes the
432
- # tempdir
433
-
434
- def teardown
435
- $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
436
- if @orig_LOADED_FEATURES
437
- if @orig_LOAD_PATH
438
- ($LOADED_FEATURES - @orig_LOADED_FEATURES).each do |feat|
439
- $LOADED_FEATURES.delete(feat) if feat.start_with?(@tmp)
440
- end
441
- else
442
- $LOADED_FEATURES.replace @orig_LOADED_FEATURES
443
- end
444
- end
445
-
446
- RbConfig::CONFIG["arch"] = @orig_arch
447
-
448
- if defined? Gem::RemoteFetcher
449
- Gem::RemoteFetcher.fetcher = nil
450
- end
451
-
452
- Dir.chdir @current_dir
453
-
454
- FileUtils.rm_rf @tempdir
455
-
456
- restore_env
457
-
458
- Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
459
- Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE,
460
- @orig_SYSTEM_WIDE_CONFIG_FILE
461
-
462
- Gem.ruby = @orig_ruby if @orig_ruby
463
-
464
- RbConfig::CONFIG["mandir"] = @orig_mandir
465
- RbConfig::CONFIG["sitelibdir"] = @orig_sitelibdir
466
- RbConfig::CONFIG["bindir"] = @orig_bindir
467
-
468
- Gem.instance_variable_set :@default_specifications_dir, nil
469
- if Gem.java_platform?
470
- RbConfig::CONFIG["default_gem_home"] = @orig_default_gem_home
471
- else
472
- Gem.instance_variable_set :@default_dir, nil
473
- end
474
-
475
- Gem::Specification.unresolved_deps.clear
476
- Gem::refresh
477
-
478
- @orig_hooks.each do |name, hooks|
479
- Gem.send(name).replace hooks
480
- end
481
-
482
- @back_ui.close
483
- end
484
-
485
- def credential_setup
486
- @temp_cred = File.join(@userhome, ".gem", "credentials")
487
- FileUtils.mkdir_p File.dirname(@temp_cred)
488
- File.write @temp_cred, ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
489
- File.chmod 0600, @temp_cred
490
- end
491
-
492
- def credential_teardown
493
- FileUtils.rm_rf @temp_cred
494
- end
495
-
496
- def common_installer_setup
497
- common_installer_teardown
498
-
499
- Gem.post_build do |installer|
500
- @post_build_hook_arg = installer
501
- true
502
- end
503
-
504
- Gem.post_install do |installer|
505
- @post_install_hook_arg = installer
506
- end
507
-
508
- Gem.post_uninstall do |uninstaller|
509
- @post_uninstall_hook_arg = uninstaller
510
- end
511
-
512
- Gem.pre_install do |installer|
513
- @pre_install_hook_arg = installer
514
- true
515
- end
516
-
517
- Gem.pre_uninstall do |uninstaller|
518
- @pre_uninstall_hook_arg = uninstaller
519
- end
520
- end
521
-
522
- def common_installer_teardown
523
- Gem.post_build_hooks.clear
524
- Gem.post_install_hooks.clear
525
- Gem.done_installing_hooks.clear
526
- Gem.post_reset_hooks.clear
527
- Gem.post_uninstall_hooks.clear
528
- Gem.pre_install_hooks.clear
529
- Gem.pre_reset_hooks.clear
530
- Gem.pre_uninstall_hooks.clear
531
- end
532
-
533
- def without_any_upwards_gemfiles
534
- ENV["BUNDLE_GEMFILE"] = File.join(@tempdir, "Gemfile")
535
- end
536
-
537
- ##
538
- # A git_gem is used with a gem dependencies file. The gem created here
539
- # has no files, just a gem specification for the given +name+ and +version+.
540
- #
541
- # Yields the +specification+ to the block, if given
542
-
543
- def git_gem(name = "a", version = 1)
544
- have_git?
545
-
546
- directory = File.join "git", name
547
- directory = File.expand_path directory
548
-
549
- git_spec = Gem::Specification.new name, version do |specification|
550
- yield specification if block_given?
551
- end
552
-
553
- FileUtils.mkdir_p directory
554
-
555
- gemspec = "#{name}.gemspec"
556
-
557
- File.open File.join(directory, gemspec), "w" do |io|
558
- io.write git_spec.to_ruby
559
- end
560
-
561
- head = nil
562
-
563
- Dir.chdir directory do
564
- unless File.exist? ".git"
565
- system @git, "init", "--quiet"
566
- system @git, "config", "user.name", "RubyGems Tests"
567
- system @git, "config", "user.email", "rubygems@example"
568
- end
569
-
570
- system @git, "add", gemspec
571
- system @git, "commit", "-a", "-m", "a non-empty commit message", "--quiet"
572
- head = Gem::Util.popen(@git, "rev-parse", "HEAD").strip
573
- end
574
-
575
- return name, git_spec.version, directory, head
576
- end
577
-
578
- ##
579
- # Skips this test unless you have a git executable
580
-
581
- def have_git?
582
- return if in_path? @git
583
-
584
- pend "cannot find git executable, use GIT environment variable to set"
585
- end
586
-
587
- def in_path?(executable) # :nodoc:
588
- return true if %r{\A([A-Z]:|/)} =~ executable && File.exist?(executable)
589
-
590
- ENV["PATH"].split(File::PATH_SEPARATOR).any? do |directory|
591
- File.exist? File.join directory, executable
592
- end
593
- end
594
-
595
- ##
596
- # Builds and installs the Gem::Specification +spec+
597
-
598
- def install_gem(spec, options = {})
599
- require "rubygems/installer"
600
-
601
- gem = spec.cache_file
602
-
603
- unless File.exist? gem
604
- use_ui Gem::MockGemUi.new do
605
- Dir.chdir @tempdir do
606
- Gem::Package.build spec
607
- end
608
- end
609
-
610
- gem = File.join(@tempdir, File.basename(gem)).tap(&Gem::UNTAINT)
611
- end
612
-
613
- Gem::Installer.at(gem, options.merge({ :wrappers => true })).install
614
- end
615
-
616
- ##
617
- # Builds and installs the Gem::Specification +spec+ into the user dir
618
-
619
- def install_gem_user(spec)
620
- install_gem spec, :user_install => true
621
- end
622
-
623
- ##
624
- # Uninstalls the Gem::Specification +spec+
625
- def uninstall_gem(spec)
626
- require "rubygems/uninstaller"
627
-
628
- Class.new(Gem::Uninstaller) do
629
- def ask_if_ok(spec)
630
- true
631
- end
632
- end.new(spec.name, :executables => true, :user_install => true).uninstall
633
- end
634
-
635
- ##
636
- # Enables pretty-print for all tests
637
-
638
- def mu_pp(obj)
639
- s = String.new
640
- s = PP.pp obj, s
641
- s = s.force_encoding(Encoding.default_external)
642
- s.chomp
643
- end
644
-
645
- ##
646
- # Reads a Marshal file at +path+
647
-
648
- def read_cache(path)
649
- File.open path.dup.tap(&Gem::UNTAINT), "rb" do |io|
650
- Marshal.load io.read
651
- end
652
- end
653
-
654
- ##
655
- # Reads a binary file at +path+
656
-
657
- def read_binary(path)
658
- Gem.read_binary path
659
- end
660
-
661
- ##
662
- # Writes a binary file to +path+ which is relative to +@gemhome+
663
-
664
- def write_file(path)
665
- path = File.join @gemhome, path unless Pathname.new(path).absolute?
666
- dir = File.dirname path
667
- FileUtils.mkdir_p dir unless File.directory? dir
668
-
669
- File.open path, "wb" do |io|
670
- yield io if block_given?
671
- end
672
-
673
- path
674
- end
675
-
676
- ##
677
- # Load a YAML string, the psych 3 way
678
-
679
- def load_yaml(yaml)
680
- if Psych.respond_to?(:unsafe_load)
681
- Psych.unsafe_load(yaml)
682
- else
683
- Psych.load(yaml)
684
- end
685
- end
686
-
687
- ##
688
- # Load a YAML file, the psych 3 way
689
-
690
- def load_yaml_file(file)
691
- if Psych.respond_to?(:unsafe_load_file)
692
- Psych.unsafe_load_file(file)
693
- else
694
- Psych.load_file(file)
695
- end
696
- end
697
-
698
- def all_spec_names
699
- Gem::Specification.map(&:full_name)
700
- end
701
-
702
- ##
703
- # Creates a Gem::Specification with a minimum of extra work. +name+ and
704
- # +version+ are the gem's name and version, platform, author, email,
705
- # homepage, summary and description are defaulted. The specification is
706
- # yielded for customization.
707
- #
708
- # The gem is added to the installed gems in +@gemhome+ and the runtime.
709
- #
710
- # Use this with #write_file to build an installed gem.
711
-
712
- def quick_gem(name, version="2")
713
- require "rubygems/specification"
714
-
715
- spec = Gem::Specification.new do |s|
716
- s.platform = Gem::Platform::RUBY
717
- s.name = name
718
- s.version = version
719
- s.author = "A User"
720
- s.email = "example@example.com"
721
- s.homepage = "http://example.com"
722
- s.summary = "this is a summary"
723
- s.description = "This is a test description"
724
-
725
- yield(s) if block_given?
726
- end
727
-
728
- written_path = write_file spec.spec_file do |io|
729
- io.write spec.to_ruby_for_cache
730
- end
731
-
732
- spec.loaded_from = written_path
733
-
734
- Gem::Specification.reset
735
-
736
- return spec
737
- end
738
-
739
- ##
740
- # Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
741
- # 'cache'</tt>. Automatically creates files based on +spec.files+
742
-
743
- def util_build_gem(spec)
744
- dir = spec.gem_dir
745
- FileUtils.mkdir_p dir
746
-
747
- Dir.chdir dir do
748
- spec.files.each do |file|
749
- next if File.exist? file
750
- FileUtils.mkdir_p File.dirname(file)
751
-
752
- File.open file, "w" do |fp|
753
- fp.puts "# #{file}"
754
- end
755
- end
756
-
757
- use_ui Gem::MockGemUi.new do
758
- Gem::Package.build spec
759
- end
760
-
761
- cache = spec.cache_file
762
- FileUtils.mv File.basename(cache), cache
763
- end
764
- end
765
-
766
- def util_remove_gem(spec)
767
- FileUtils.rm_rf spec.cache_file
768
- FileUtils.rm_rf spec.spec_file
769
- end
770
-
771
- ##
772
- # Removes all installed gems from +@gemhome+.
773
-
774
- def util_clear_gems
775
- FileUtils.rm_rf File.join(@gemhome, "gems")
776
- FileUtils.mkdir File.join(@gemhome, "gems")
777
- FileUtils.rm_rf File.join(@gemhome, "specifications")
778
- FileUtils.mkdir File.join(@gemhome, "specifications")
779
- Gem::Specification.reset
780
- end
781
-
782
- ##
783
- # Install the provided specs
784
-
785
- def install_specs(*specs)
786
- specs.each do |spec|
787
- Gem::Installer.for_spec(spec, :force => true).install
788
- end
789
-
790
- Gem.searcher = nil
791
- end
792
-
793
- ##
794
- # Installs the provided default specs including writing the spec file
795
-
796
- def install_default_gems(*specs)
797
- specs.each do |spec|
798
- installer = Gem::Installer.for_spec(spec, :install_as_default => true)
799
- installer.install
800
- Gem.register_default_spec(spec)
801
- end
802
- end
803
-
804
- def loaded_spec_names
805
- Gem.loaded_specs.values.map(&:full_name).sort
806
- end
807
-
808
- def unresolved_names
809
- Gem::Specification.unresolved_deps.values.map(&:to_s).sort
810
- end
811
-
812
- def new_default_spec(name, version, deps = nil, *files)
813
- spec = util_spec name, version, deps
814
-
815
- spec.loaded_from = File.join(@gemhome, "specifications", "default", spec.spec_name)
816
- spec.files = files
817
-
818
- lib_dir = File.join(@tempdir, "default_gems", "lib")
819
- lib_dir.instance_variable_set(:@gem_prelude_index, lib_dir)
820
- Gem.instance_variable_set(:@default_gem_load_paths, [*Gem.send(:default_gem_load_paths), lib_dir])
821
- $LOAD_PATH.unshift(lib_dir)
822
- files.each do |file|
823
- rb_path = File.join(lib_dir, file)
824
- FileUtils.mkdir_p(File.dirname(rb_path))
825
- File.open(rb_path, "w") do |rb|
826
- rb << "# #{file}"
827
- end
828
- end
829
-
830
- spec
831
- end
832
-
833
- ##
834
- # Creates a spec with +name+, +version+. +deps+ can specify the dependency
835
- # or a +block+ can be given for full customization of the specification.
836
-
837
- def util_spec(name, version = 2, deps = nil, *files) # :yields: specification
838
- raise "deps or block, not both" if deps && block_given?
839
-
840
- spec = Gem::Specification.new do |s|
841
- s.platform = Gem::Platform::RUBY
842
- s.name = name
843
- s.version = version
844
- s.author = "A User"
845
- s.email = "example@example.com"
846
- s.homepage = "http://example.com"
847
- s.summary = "this is a summary"
848
- s.description = "This is a test description"
849
-
850
- s.files.push(*files) unless files.empty?
851
-
852
- yield s if block_given?
853
- end
854
-
855
- if deps
856
- deps.keys.each do |n|
857
- spec.add_dependency n, (deps[n] || ">= 0")
858
- end
859
- end
860
-
861
- unless files.empty?
862
- write_file spec.spec_file do |io|
863
- io.write spec.to_ruby_for_cache
864
- end
865
-
866
- util_build_gem spec
867
-
868
- FileUtils.rm spec.spec_file
869
- end
870
-
871
- return spec
872
- end
873
-
874
- ##
875
- # Creates a gem with +name+, +version+ and +deps+. The specification will
876
- # be yielded before gem creation for customization. The gem will be placed
877
- # in <tt>File.join @tempdir, 'gems'</tt>. The specification and .gem file
878
- # location are returned.
879
-
880
- def util_gem(name, version, deps = nil, &block)
881
- if deps
882
- block = proc do |s|
883
- deps.keys.each do |n|
884
- s.add_dependency n, (deps[n] || ">= 0")
885
- end
886
- end
887
- end
888
-
889
- spec = quick_gem(name, version, &block)
890
-
891
- util_build_gem spec
892
-
893
- cache_file = File.join @tempdir, "gems", "#{spec.original_name}.gem"
894
- FileUtils.mkdir_p File.dirname cache_file
895
- FileUtils.mv spec.cache_file, cache_file
896
- FileUtils.rm spec.spec_file
897
-
898
- spec.loaded_from = nil
899
-
900
- [spec, cache_file]
901
- end
902
-
903
- ##
904
- # Gzips +data+.
905
-
906
- def util_gzip(data)
907
- out = StringIO.new
908
-
909
- Zlib::GzipWriter.wrap out do |io|
910
- io.write data
911
- end
912
-
913
- out.string
914
- end
915
-
916
- ##
917
- # Creates several default gems which all have a lib/code.rb file. The gems
918
- # are not installed but are available in the cache dir.
919
- #
920
- # +@a1+:: gem a version 1, this is the best-described gem.
921
- # +@a2+:: gem a version 2
922
- # +@a3a:: gem a version 3.a
923
- # +@a_evil9+:: gem a_evil version 9, use this to ensure similarly-named gems
924
- # don't collide with a.
925
- # +@b2+:: gem b version 2
926
- # +@c1_2+:: gem c version 1.2
927
- # +@pl1+:: gem pl version 1, this gem has a legacy platform of i386-linux.
928
- #
929
- # Additional +prerelease+ gems may also be created:
930
- #
931
- # +@a2_pre+:: gem a version 2.a
932
- # TODO: nuke this and fix tests. this should speed up a lot
933
-
934
- def util_make_gems(prerelease = false)
935
- @a1 = quick_gem "a", "1" do |s|
936
- s.files = %w[lib/code.rb]
937
- s.require_paths = %w[lib]
938
- s.date = Gem::Specification::TODAY - 86400
939
- s.homepage = "http://a.example.com"
940
- s.email = %w[example@example.com example2@example.com]
941
- s.authors = %w[Example Example2]
942
- s.description = <<-DESC
943
- This line is really, really long. So long, in fact, that it is more than eighty characters long! The purpose of this line is for testing wrapping behavior because sometimes people don't wrap their text to eighty characters. Without the wrapping, the text might not look good in the RSS feed.
944
-
945
- Also, a list:
946
- * An entry that\'s actually kind of sort
947
- * an entry that\'s really long, which will probably get wrapped funny. That's ok, somebody wasn't thinking straight when they made it more than eighty characters.
948
- DESC
949
- end
950
-
951
- init = proc do |s|
952
- s.files = %w[lib/code.rb]
953
- s.require_paths = %w[lib]
954
- end
955
-
956
- @a2 = quick_gem("a", "2", &init)
957
- @a3a = quick_gem("a", "3.a", &init)
958
- @a_evil9 = quick_gem("a_evil", "9", &init)
959
- @b2 = quick_gem("b", "2", &init)
960
- @c1_2 = quick_gem("c", "1.2", &init)
961
- @x = quick_gem("x", "1", &init)
962
- @dep_x = quick_gem("dep_x", "1") do |s|
963
- s.files = %w[lib/code.rb]
964
- s.require_paths = %w[lib]
965
- s.add_dependency "x", ">= 1"
966
- end
967
-
968
- @pl1 = quick_gem "pl", "1" do |s| # l for legacy
969
- s.files = %w[lib/code.rb]
970
- s.require_paths = %w[lib]
971
- s.platform = Gem::Platform.new "i386-linux"
972
- s.instance_variable_set :@original_platform, "i386-linux"
973
- end
974
-
975
- if prerelease
976
- @a2_pre = quick_gem("a", "2.a", &init)
977
- write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb])
978
- util_build_gem @a2_pre
979
- end
980
-
981
- write_file File.join(*%W[gems #{@a1.original_name} lib code.rb])
982
- write_file File.join(*%W[gems #{@a2.original_name} lib code.rb])
983
- write_file File.join(*%W[gems #{@a3a.original_name} lib code.rb])
984
- write_file File.join(*%W[gems #{@a_evil9.original_name} lib code.rb])
985
- write_file File.join(*%W[gems #{@b2.original_name} lib code.rb])
986
- write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb])
987
- write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb])
988
- write_file File.join(*%W[gems #{@x.original_name} lib code.rb])
989
- write_file File.join(*%W[gems #{@dep_x.original_name} lib code.rb])
990
-
991
- [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2, @pl1, @x, @dep_x].each do |spec|
992
- util_build_gem spec
993
- end
994
-
995
- FileUtils.rm_r File.join(@gemhome, "gems", @pl1.original_name)
996
- end
997
-
998
- ##
999
- # Set the platform to +arch+
1000
-
1001
- def util_set_arch(arch)
1002
- RbConfig::CONFIG["arch"] = arch
1003
- platform = Gem::Platform.new arch
1004
-
1005
- Gem.instance_variable_set :@platforms, nil
1006
- Gem::Platform.instance_variable_set :@local, nil
1007
-
1008
- yield if block_given?
1009
-
1010
- platform
1011
- end
1012
-
1013
- ##
1014
- # Add +spec+ to +@fetcher+ serving the data in the file +path+.
1015
- # +repo+ indicates which repo to make +spec+ appear to be in.
1016
-
1017
- def add_to_fetcher(spec, path=nil, repo=@gem_repo)
1018
- path ||= spec.cache_file
1019
- @fetcher.data["#{@gem_repo}gems/#{spec.file_name}"] = read_binary(path)
1020
- end
1021
-
1022
- ##
1023
- # Sets up Gem::SpecFetcher to return information from the gems in +specs+.
1024
-
1025
- def util_setup_spec_fetcher(*specs)
1026
- all_specs = Gem::Specification.to_a + specs
1027
- Gem::Specification._resort! all_specs
1028
-
1029
- spec_fetcher = Gem::SpecFetcher.fetcher
1030
-
1031
- prerelease, all = all_specs.partition {|spec| spec.version.prerelease? }
1032
- latest = Gem::Specification._latest_specs all_specs
1033
-
1034
- spec_fetcher.specs[@uri] = []
1035
- all.each do |spec|
1036
- spec_fetcher.specs[@uri] << spec.name_tuple
1037
- end
1038
-
1039
- spec_fetcher.latest_specs[@uri] = []
1040
- latest.each do |spec|
1041
- spec_fetcher.latest_specs[@uri] << spec.name_tuple
1042
- end
1043
-
1044
- spec_fetcher.prerelease_specs[@uri] = []
1045
- prerelease.each do |spec|
1046
- spec_fetcher.prerelease_specs[@uri] << spec.name_tuple
1047
- end
1048
-
1049
- # HACK for test_download_to_cache
1050
- unless Gem::RemoteFetcher === @fetcher
1051
- v = Gem.marshal_version
1052
-
1053
- specs = all.map {|spec| spec.name_tuple }
1054
- s_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic specs
1055
-
1056
- latest_specs = latest.map do |spec|
1057
- spec.name_tuple
1058
- end
1059
-
1060
- l_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic latest_specs
1061
-
1062
- prerelease_specs = prerelease.map {|spec| spec.name_tuple }
1063
- p_zip = util_gzip Marshal.dump Gem::NameTuple.to_basic prerelease_specs
1064
-
1065
- @fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip
1066
- @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip
1067
- @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
1068
-
1069
- write_marshalled_gemspecs(*all_specs)
1070
- end
1071
-
1072
- nil # force errors
1073
- end
1074
-
1075
- def write_marshalled_gemspecs(*all_specs)
1076
- v = Gem.marshal_version
1077
-
1078
- all_specs.each do |spec|
1079
- path = "#{@gem_repo}quick/Marshal.#{v}/#{spec.original_name}.gemspec.rz"
1080
- data = Marshal.dump spec
1081
- data_deflate = Zlib::Deflate.deflate data
1082
- @fetcher.data[path] = data_deflate
1083
- end
1084
- end
1085
-
1086
- ##
1087
- # Deflates +data+
1088
-
1089
- def util_zip(data)
1090
- Zlib::Deflate.deflate data
1091
- end
1092
-
1093
- def util_set_RUBY_VERSION(version, patchlevel, revision, description, engine = "ruby", engine_version = nil)
1094
- if Gem.instance_variables.include? :@ruby_version
1095
- Gem.send :remove_instance_variable, :@ruby_version
1096
- end
1097
-
1098
- @RUBY_VERSION = RUBY_VERSION
1099
- @RUBY_PATCHLEVEL = RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
1100
- @RUBY_REVISION = RUBY_REVISION if defined?(RUBY_REVISION)
1101
- @RUBY_DESCRIPTION = RUBY_DESCRIPTION
1102
- @RUBY_ENGINE = RUBY_ENGINE
1103
- @RUBY_ENGINE_VERSION = RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
1104
-
1105
- util_clear_RUBY_VERSION
1106
-
1107
- Object.const_set :RUBY_VERSION, version
1108
- Object.const_set :RUBY_PATCHLEVEL, patchlevel
1109
- Object.const_set :RUBY_REVISION, revision
1110
- Object.const_set :RUBY_DESCRIPTION, description
1111
- Object.const_set :RUBY_ENGINE, engine
1112
- Object.const_set :RUBY_ENGINE_VERSION, engine_version if engine_version
1113
- end
1114
-
1115
- def util_restore_RUBY_VERSION
1116
- util_clear_RUBY_VERSION
1117
-
1118
- Object.const_set :RUBY_VERSION, @RUBY_VERSION
1119
- Object.const_set :RUBY_PATCHLEVEL, @RUBY_PATCHLEVEL if
1120
- defined?(@RUBY_PATCHLEVEL)
1121
- Object.const_set :RUBY_REVISION, @RUBY_REVISION if
1122
- defined?(@RUBY_REVISION)
1123
- Object.const_set :RUBY_DESCRIPTION, @RUBY_DESCRIPTION
1124
- Object.const_set :RUBY_ENGINE, @RUBY_ENGINE
1125
- Object.const_set :RUBY_ENGINE_VERSION, @RUBY_ENGINE_VERSION if
1126
- defined?(@RUBY_ENGINE_VERSION)
1127
- end
1128
-
1129
- def util_clear_RUBY_VERSION
1130
- Object.send :remove_const, :RUBY_VERSION
1131
- Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
1132
- Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
1133
- Object.send :remove_const, :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
1134
- Object.send :remove_const, :RUBY_ENGINE
1135
- Object.send :remove_const, :RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
1136
- end
1137
-
1138
- ##
1139
- # Is this test being run on a Windows platform?
1140
-
1141
- def self.win_platform?
1142
- Gem.win_platform?
1143
- end
1144
-
1145
- ##
1146
- # Is this test being run on a Windows platform?
1147
-
1148
- def win_platform?
1149
- Gem.win_platform?
1150
- end
1151
-
1152
- ##
1153
- # Is this test being run on a Java platform?
1154
-
1155
- def self.java_platform?
1156
- Gem.java_platform?
1157
- end
1158
-
1159
- ##
1160
- # Is this test being run on a Java platform?
1161
-
1162
- def java_platform?
1163
- Gem.java_platform?
1164
- end
1165
-
1166
- ##
1167
- # Returns whether or not we're on a version of Ruby built with VC++ (or
1168
- # Borland) versus Cygwin, Mingw, etc.
1169
-
1170
- def self.vc_windows?
1171
- RUBY_PLATFORM.match("mswin")
1172
- end
1173
-
1174
- ##
1175
- # Returns whether or not we're on a version of Ruby built with VC++ (or
1176
- # Borland) versus Cygwin, Mingw, etc.
1177
-
1178
- def vc_windows?
1179
- RUBY_PLATFORM.match("mswin")
1180
- end
1181
-
1182
- ##
1183
- # Is this test being run on a ruby/ruby repository?
1184
- #
1185
-
1186
- def ruby_repo?
1187
- !ENV["GEM_COMMAND"].nil?
1188
- end
1189
-
1190
- ##
1191
- # Returns the make command for the current platform. For versions of Ruby
1192
- # built on MS Windows with VC++ or Borland it will return 'nmake'. On all
1193
- # other platforms, including Cygwin, it will return 'make'.
1194
-
1195
- def self.make_command
1196
- ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make")
1197
- end
1198
-
1199
- ##
1200
- # Returns the make command for the current platform. For versions of Ruby
1201
- # built on MS Windows with VC++ or Borland it will return 'nmake'. On all
1202
- # other platforms, including Cygwin, it will return 'make'.
1203
-
1204
- def make_command
1205
- ENV["make"] || ENV["MAKE"] || (vc_windows? ? "nmake" : "make")
1206
- end
1207
-
1208
- ##
1209
- # Returns whether or not the nmake command could be found.
1210
-
1211
- def nmake_found?
1212
- system("nmake /? 1>NUL 2>&1")
1213
- end
1214
-
1215
- # In case we're building docs in a background process, this method waits for
1216
- # that process to exit (or if it's already been reaped, or never happened,
1217
- # swallows the Errno::ECHILD error).
1218
- def wait_for_child_process_to_exit
1219
- Process.wait if Process.respond_to?(:fork)
1220
- rescue Errno::ECHILD
1221
- end
1222
-
1223
- ##
1224
- # Allows tests to use a random (but controlled) port number instead of
1225
- # a hardcoded one. This helps CI tools when running parallels builds on
1226
- # the same builder slave.
1227
-
1228
- def self.process_based_port
1229
- @@process_based_port ||= 8000 + $$ % 1000
1230
- end
1231
-
1232
- ##
1233
- # See ::process_based_port
1234
-
1235
- def process_based_port
1236
- self.class.process_based_port
1237
- end
1238
-
1239
- ##
1240
- # Allows the proper version of +rake+ to be used for the test.
1241
-
1242
- def build_rake_in(good=true)
1243
- gem_ruby = Gem.ruby
1244
- Gem.ruby = self.class.rubybin
1245
- env_rake = ENV["rake"]
1246
- rake = (good ? @@good_rake : @@bad_rake)
1247
- ENV["rake"] = rake
1248
- yield rake
1249
- ensure
1250
- Gem.ruby = gem_ruby
1251
- if env_rake
1252
- ENV["rake"] = env_rake
1253
- else
1254
- ENV.delete("rake")
1255
- end
1256
- end
1257
-
1258
- ##
1259
- # Finds the path to the Ruby executable
1260
-
1261
- def self.rubybin
1262
- ruby = ENV["RUBY"]
1263
- return ruby if ruby
1264
- ruby = "ruby"
1265
- rubyexe = "#{ruby}#{RbConfig::CONFIG['EXEEXT']}"
1266
-
1267
- 3.times do
1268
- if File.exist?(ruby) && File.executable?(ruby) && !File.directory?(ruby)
1269
- return File.expand_path(ruby)
1270
- end
1271
- if File.exist?(rubyexe) && File.executable?(rubyexe)
1272
- return File.expand_path(rubyexe)
1273
- end
1274
- ruby = File.join("..", ruby)
1275
- end
1276
-
1277
- begin
1278
- Gem.ruby
1279
- rescue LoadError
1280
- "ruby"
1281
- end
1282
- end
1283
-
1284
- def ruby_with_rubygems_in_load_path
1285
- [Gem.ruby, "-I", rubygems_path]
1286
- end
1287
-
1288
- def rubygems_path
1289
- $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }
1290
- end
1291
-
1292
- def bundler_path
1293
- $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/bundler.rb") }) }
1294
- end
1295
-
1296
- def with_clean_path_to_ruby
1297
- orig_ruby = Gem.ruby
1298
-
1299
- Gem.instance_variable_set :@ruby, nil
1300
-
1301
- yield
1302
- ensure
1303
- Gem.instance_variable_set :@ruby, orig_ruby
1304
- end
1305
-
1306
- def with_internal_encoding(encoding)
1307
- int_enc = Encoding.default_internal
1308
- silence_warnings { Encoding.default_internal = encoding }
1309
-
1310
- yield
1311
- ensure
1312
- silence_warnings { Encoding.default_internal = int_enc }
1313
- end
1314
-
1315
- def silence_warnings
1316
- old_verbose, $VERBOSE = $VERBOSE, false
1317
- yield
1318
- ensure
1319
- $VERBOSE = old_verbose
1320
- end
1321
-
1322
- class << self
1323
- # :nodoc:
1324
- ##
1325
- # Return the join path, with escaping backticks, dollars, and
1326
- # double-quotes. Unlike `shellescape`, equal-sign is not escaped.
1327
-
1328
- private
1329
-
1330
- def escape_path(*path)
1331
- path = File.join(*path)
1332
- if %r{\A[-+:/=@,.\w]+\z} =~ path
1333
- path
1334
- else
1335
- "\"#{path.gsub(/[`$"]/, '\\&')}\""
1336
- end
1337
- end
1338
- end
1339
-
1340
- @@good_rake = "#{rubybin} #{escape_path(__dir__, 'good_rake.rb')}"
1341
- @@bad_rake = "#{rubybin} #{escape_path(__dir__, 'bad_rake.rb')}"
1342
-
1343
- ##
1344
- # Construct a new Gem::Dependency.
1345
-
1346
- def dep(name, *requirements)
1347
- Gem::Dependency.new name, *requirements
1348
- end
1349
-
1350
- ##
1351
- # Constructs a Gem::Resolver::DependencyRequest from a
1352
- # Gem::Dependency +dep+, a +from_name+ and +from_version+ requesting the
1353
- # dependency and a +parent+ DependencyRequest
1354
-
1355
- def dependency_request(dep, from_name, from_version, parent = nil)
1356
- remote = Gem::Source.new @uri
1357
-
1358
- unless parent
1359
- parent_dep = dep from_name, from_version
1360
- parent = Gem::Resolver::DependencyRequest.new parent_dep, nil
1361
- end
1362
-
1363
- spec = Gem::Resolver::IndexSpecification.new \
1364
- nil, from_name, from_version, remote, Gem::Platform::RUBY
1365
- activation = Gem::Resolver::ActivationRequest.new spec, parent
1366
-
1367
- Gem::Resolver::DependencyRequest.new dep, activation
1368
- end
1369
-
1370
- ##
1371
- # Constructs a new Gem::Requirement.
1372
-
1373
- def req(*requirements)
1374
- return requirements.first if Gem::Requirement === requirements.first
1375
- Gem::Requirement.create requirements
1376
- end
1377
-
1378
- ##
1379
- # Constructs a new Gem::Specification.
1380
-
1381
- def spec(name, version, &block)
1382
- Gem::Specification.new name, v(version), &block
1383
- end
1384
-
1385
- ##
1386
- # Creates a SpecFetcher pre-filled with the gems or specs defined in the
1387
- # block.
1388
- #
1389
- # Yields a +fetcher+ object that responds to +spec+ and +gem+. +spec+ adds
1390
- # a specification to the SpecFetcher while +gem+ adds both a specification
1391
- # and the gem data to the RemoteFetcher so the built gem can be downloaded.
1392
- #
1393
- # If only the a-3 gem is supposed to be downloaded you can save setup
1394
- # time by creating only specs for the other versions:
1395
- #
1396
- # spec_fetcher do |fetcher|
1397
- # fetcher.spec 'a', 1
1398
- # fetcher.spec 'a', 2, 'b' => 3 # dependency on b = 3
1399
- # fetcher.gem 'a', 3 do |spec|
1400
- # # spec is a Gem::Specification
1401
- # # ...
1402
- # end
1403
- # end
1404
-
1405
- def spec_fetcher(repository = @gem_repo)
1406
- Gem::TestCase::SpecFetcherSetup.declare self, repository do |spec_fetcher_setup|
1407
- yield spec_fetcher_setup if block_given?
1408
- end
1409
- end
1410
-
1411
- ##
1412
- # Construct a new Gem::Version.
1413
-
1414
- def v(string)
1415
- Gem::Version.create string
1416
- end
1417
-
1418
- ##
1419
- # A vendor_gem is used with a gem dependencies file. The gem created here
1420
- # has no files, just a gem specification for the given +name+ and +version+.
1421
- #
1422
- # Yields the +specification+ to the block, if given
1423
-
1424
- def vendor_gem(name = "a", version = 1)
1425
- directory = File.join "vendor", name
1426
-
1427
- FileUtils.mkdir_p directory
1428
-
1429
- save_gemspec name, version, directory
1430
- end
1431
-
1432
- ##
1433
- # create_gemspec creates gem specification in given +directory+ or '.'
1434
- # for the given +name+ and +version+.
1435
- #
1436
- # Yields the +specification+ to the block, if given
1437
-
1438
- def save_gemspec(name = "a", version = 1, directory = ".")
1439
- vendor_spec = Gem::Specification.new name, version do |specification|
1440
- yield specification if block_given?
1441
- end
1442
-
1443
- File.open File.join(directory, "#{name}.gemspec"), "w" do |io|
1444
- io.write vendor_spec.to_ruby
1445
- end
1446
-
1447
- return name, vendor_spec.version, directory
1448
- end
1449
-
1450
- ##
1451
- # The StaticSet is a static set of gem specifications used for testing only.
1452
- # It is available by requiring Gem::TestCase.
1453
-
1454
- class StaticSet < Gem::Resolver::Set
1455
- ##
1456
- # A StaticSet ignores remote because it has a fixed set of gems.
1457
-
1458
- attr_accessor :remote
1459
-
1460
- ##
1461
- # Creates a new StaticSet for the given +specs+
1462
-
1463
- def initialize(specs)
1464
- super()
1465
-
1466
- @specs = specs
1467
-
1468
- @remote = true
1469
- end
1470
-
1471
- ##
1472
- # Adds +spec+ to this set.
1473
-
1474
- def add(spec)
1475
- @specs << spec
1476
- end
1477
-
1478
- ##
1479
- # Finds +dep+ in this set.
1480
-
1481
- def find_spec(dep)
1482
- @specs.reverse_each do |s|
1483
- return s if dep.matches_spec? s
1484
- end
1485
- end
1486
-
1487
- ##
1488
- # Finds all gems matching +dep+ in this set.
1489
-
1490
- def find_all(dep)
1491
- @specs.find_all {|s| dep.match? s, @prerelease }
1492
- end
1493
-
1494
- ##
1495
- # Loads a Gem::Specification from this set which has the given +name+,
1496
- # version +ver+, +platform+. The +source+ is ignored.
1497
-
1498
- def load_spec(name, ver, platform, source)
1499
- dep = Gem::Dependency.new name, ver
1500
- spec = find_spec dep
1501
-
1502
- Gem::Specification.new spec.name, spec.version do |s|
1503
- s.platform = spec.platform
1504
- end
1505
- end
1506
-
1507
- def prefetch(reqs) # :nodoc:
1508
- end
1509
- end
1510
-
1511
- ##
1512
- # Loads certificate named +cert_name+ from <tt>test/rubygems/</tt>.
1513
-
1514
- def self.load_cert(cert_name)
1515
- cert_file = cert_path cert_name
1516
-
1517
- cert = File.read cert_file
1518
-
1519
- OpenSSL::X509::Certificate.new cert
1520
- end
1521
-
1522
- ##
1523
- # Returns the path to the certificate named +cert_name+ from
1524
- # <tt>test/rubygems/</tt>.
1525
-
1526
- def self.cert_path(cert_name)
1527
- if 32 == (Time.at(2**32) rescue 32)
1528
- cert_file = "#{__dir__}/#{cert_name}_cert_32.pem"
1529
-
1530
- return cert_file if File.exist? cert_file
1531
- end
1532
-
1533
- "#{__dir__}/#{cert_name}_cert.pem"
1534
- end
1535
-
1536
- ##
1537
- # Loads a private key named +key_name+ with +passphrase+ in <tt>test/rubygems/</tt>
1538
-
1539
- def self.load_key(key_name, passphrase = nil)
1540
- key_file = key_path key_name
1541
-
1542
- key = File.read key_file
1543
-
1544
- OpenSSL::PKey.read key, passphrase
1545
- end
1546
-
1547
- ##
1548
- # Returns the path to the key named +key_name+ from <tt>test/rubygems</tt>
1549
-
1550
- def self.key_path(key_name)
1551
- "#{__dir__}/#{key_name}_key.pem"
1552
- end
1553
-
1554
- # :stopdoc:
1555
- # only available in RubyGems tests
1556
-
1557
- PRIVATE_KEY_PASSPHRASE = "Foo bar"
1558
-
1559
- begin
1560
- PRIVATE_KEY = load_key "private"
1561
- PRIVATE_KEY_PATH = key_path "private"
1562
-
1563
- # ENCRYPTED_PRIVATE_KEY is PRIVATE_KEY encrypted with PRIVATE_KEY_PASSPHRASE
1564
- ENCRYPTED_PRIVATE_KEY = load_key "encrypted_private", PRIVATE_KEY_PASSPHRASE
1565
- ENCRYPTED_PRIVATE_KEY_PATH = key_path "encrypted_private"
1566
-
1567
- PUBLIC_KEY = PRIVATE_KEY.public_key
1568
-
1569
- PUBLIC_CERT = load_cert "public"
1570
- PUBLIC_CERT_PATH = cert_path "public"
1571
- rescue Errno::ENOENT
1572
- PRIVATE_KEY = nil
1573
- PUBLIC_KEY = nil
1574
- PUBLIC_CERT = nil
1575
- end if Gem::HAVE_OPENSSL
1576
-
1577
- private
1578
-
1579
- def restore_env
1580
- unless Gem.win_platform?
1581
- ENV.replace(@orig_env)
1582
- return
1583
- end
1584
-
1585
- # Fallback logic for Windows below to workaround
1586
- # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
1587
- # supported rubies include the fix for that.
1588
-
1589
- ENV.clear
1590
-
1591
- @orig_env.each {|k, v| ENV[k] = v }
1592
- end
1593
- end
1594
-
1595
- # https://github.com/seattlerb/minitest/blob/13c48a03d84a2a87855a4de0c959f96800100357/lib/minitest/mock.rb#L192
1596
- class Object
1597
- def stub(name, val_or_callable, *block_args)
1598
- new_name = "__minitest_stub__#{name}"
1599
-
1600
- metaclass = class << self; self; end
1601
-
1602
- if respond_to?(name) && !methods.map(&:to_s).include?(name.to_s)
1603
- metaclass.send :define_method, name do |*args|
1604
- super(*args)
1605
- end
1606
- end
1607
-
1608
- metaclass.send :alias_method, new_name, name
1609
-
1610
- metaclass.send :define_method, name do |*args, &blk|
1611
- if val_or_callable.respond_to? :call
1612
- val_or_callable.call(*args, &blk)
1613
- else
1614
- blk.call(*block_args) if blk
1615
- val_or_callable
1616
- end
1617
- end
1618
-
1619
- metaclass.send(:ruby2_keywords, name) if metaclass.respond_to?(:ruby2_keywords, true)
1620
-
1621
- yield self
1622
- ensure
1623
- metaclass.send :undef_method, name
1624
- metaclass.send :alias_method, name, new_name
1625
- metaclass.send :undef_method, new_name
1626
- end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition
1627
- end
1628
-
1629
- require_relative "utilities"