rubygems-update 2.6.0 → 3.4.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (804) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +5802 -0
  3. data/CODE_OF_CONDUCT.md +76 -35
  4. data/CONTRIBUTING.md +231 -0
  5. data/MAINTAINERS.txt +8 -0
  6. data/Manifest.txt +441 -42
  7. data/POLICIES.md +135 -0
  8. data/README.md +114 -0
  9. data/UPGRADING.md +15 -0
  10. data/bundler/CHANGELOG.md +4666 -0
  11. data/bundler/LICENSE.md +22 -0
  12. data/bundler/README.md +58 -0
  13. data/bundler/UPGRADING.md +222 -0
  14. data/bundler/bundler.gemspec +44 -0
  15. data/bundler/exe/bundle +38 -0
  16. data/bundler/exe/bundler +4 -0
  17. data/bundler/lib/bundler/.document +1 -0
  18. data/bundler/lib/bundler/build_metadata.rb +45 -0
  19. data/bundler/lib/bundler/capistrano.rb +22 -0
  20. data/bundler/lib/bundler/cli/add.rb +47 -0
  21. data/bundler/lib/bundler/cli/binstubs.rb +57 -0
  22. data/bundler/lib/bundler/cli/cache.rb +43 -0
  23. data/bundler/lib/bundler/cli/check.rb +40 -0
  24. data/bundler/lib/bundler/cli/clean.rb +25 -0
  25. data/bundler/lib/bundler/cli/common.rb +130 -0
  26. data/bundler/lib/bundler/cli/config.rb +203 -0
  27. data/bundler/lib/bundler/cli/console.rb +43 -0
  28. data/bundler/lib/bundler/cli/doctor.rb +157 -0
  29. data/bundler/lib/bundler/cli/exec.rb +88 -0
  30. data/bundler/lib/bundler/cli/fund.rb +36 -0
  31. data/bundler/lib/bundler/cli/gem.rb +466 -0
  32. data/bundler/lib/bundler/cli/info.rb +94 -0
  33. data/bundler/lib/bundler/cli/init.rb +51 -0
  34. data/bundler/lib/bundler/cli/inject.rb +60 -0
  35. data/bundler/lib/bundler/cli/install.rb +189 -0
  36. data/bundler/lib/bundler/cli/issue.rb +41 -0
  37. data/bundler/lib/bundler/cli/list.rb +66 -0
  38. data/bundler/lib/bundler/cli/lock.rb +73 -0
  39. data/bundler/lib/bundler/cli/open.rb +29 -0
  40. data/bundler/lib/bundler/cli/outdated.rb +297 -0
  41. data/bundler/lib/bundler/cli/platform.rb +48 -0
  42. data/bundler/lib/bundler/cli/plugin.rb +41 -0
  43. data/bundler/lib/bundler/cli/pristine.rb +52 -0
  44. data/bundler/lib/bundler/cli/remove.rb +17 -0
  45. data/bundler/lib/bundler/cli/show.rb +75 -0
  46. data/bundler/lib/bundler/cli/update.rb +123 -0
  47. data/bundler/lib/bundler/cli/viz.rb +31 -0
  48. data/bundler/lib/bundler/cli.rb +894 -0
  49. data/bundler/lib/bundler/compact_index_client/cache.rb +101 -0
  50. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  51. data/bundler/lib/bundler/compact_index_client/updater.rb +117 -0
  52. data/bundler/lib/bundler/compact_index_client.rb +119 -0
  53. data/bundler/lib/bundler/constants.rb +7 -0
  54. data/bundler/lib/bundler/current_ruby.rb +108 -0
  55. data/bundler/lib/bundler/definition.rb +978 -0
  56. data/bundler/lib/bundler/dependency.rb +97 -0
  57. data/bundler/lib/bundler/deployment.rb +69 -0
  58. data/bundler/lib/bundler/deprecate.rb +44 -0
  59. data/bundler/lib/bundler/digest.rb +71 -0
  60. data/bundler/lib/bundler/dsl.rb +583 -0
  61. data/bundler/lib/bundler/endpoint_specification.rb +143 -0
  62. data/bundler/lib/bundler/env.rb +150 -0
  63. data/bundler/lib/bundler/environment_preserver.rb +86 -0
  64. data/bundler/lib/bundler/errors.rb +190 -0
  65. data/bundler/lib/bundler/feature_flag.rb +53 -0
  66. data/bundler/lib/bundler/fetcher/base.rb +50 -0
  67. data/bundler/lib/bundler/fetcher/compact_index.rb +129 -0
  68. data/bundler/lib/bundler/fetcher/dependency.rb +78 -0
  69. data/bundler/lib/bundler/fetcher/downloader.rb +89 -0
  70. data/bundler/lib/bundler/fetcher/index.rb +25 -0
  71. data/bundler/lib/bundler/fetcher.rb +321 -0
  72. data/bundler/lib/bundler/force_platform.rb +18 -0
  73. data/bundler/lib/bundler/friendly_errors.rb +126 -0
  74. data/bundler/lib/bundler/gem_helper.rb +237 -0
  75. data/bundler/lib/bundler/gem_helpers.rb +124 -0
  76. data/bundler/lib/bundler/gem_tasks.rb +7 -0
  77. data/bundler/lib/bundler/gem_version_promoter.rb +145 -0
  78. data/bundler/lib/bundler/graph.rb +152 -0
  79. data/bundler/lib/bundler/index.rb +206 -0
  80. data/bundler/lib/bundler/injector.rb +287 -0
  81. data/bundler/lib/bundler/inline.rb +73 -0
  82. data/bundler/lib/bundler/installer/gem_installer.rb +84 -0
  83. data/bundler/lib/bundler/installer/parallel_installer.rb +194 -0
  84. data/bundler/lib/bundler/installer/standalone.rb +117 -0
  85. data/bundler/lib/bundler/installer.rb +267 -0
  86. data/bundler/lib/bundler/lazy_specification.rb +163 -0
  87. data/bundler/lib/bundler/lockfile_generator.rb +95 -0
  88. data/bundler/lib/bundler/lockfile_parser.rb +218 -0
  89. data/bundler/lib/bundler/man/.document +1 -0
  90. data/bundler/lib/bundler/man/bundle-add.1 +82 -0
  91. data/bundler/lib/bundler/man/bundle-add.1.ronn +58 -0
  92. data/bundler/lib/bundler/man/bundle-binstubs.1 +42 -0
  93. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +41 -0
  94. data/bundler/lib/bundler/man/bundle-cache.1 +61 -0
  95. data/bundler/lib/bundler/man/bundle-cache.1.ronn +79 -0
  96. data/bundler/lib/bundler/man/bundle-check.1 +31 -0
  97. data/bundler/lib/bundler/man/bundle-check.1.ronn +26 -0
  98. data/bundler/lib/bundler/man/bundle-clean.1 +24 -0
  99. data/bundler/lib/bundler/man/bundle-clean.1.ronn +18 -0
  100. data/bundler/lib/bundler/man/bundle-config.1 +512 -0
  101. data/bundler/lib/bundler/man/bundle-config.1.ronn +405 -0
  102. data/bundler/lib/bundler/man/bundle-console.1 +53 -0
  103. data/bundler/lib/bundler/man/bundle-console.1.ronn +44 -0
  104. data/bundler/lib/bundler/man/bundle-doctor.1 +44 -0
  105. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +33 -0
  106. data/bundler/lib/bundler/man/bundle-exec.1 +165 -0
  107. data/bundler/lib/bundler/man/bundle-exec.1.ronn +151 -0
  108. data/bundler/lib/bundler/man/bundle-gem.1 +105 -0
  109. data/bundler/lib/bundler/man/bundle-gem.1.ronn +117 -0
  110. data/bundler/lib/bundler/man/bundle-help.1 +13 -0
  111. data/bundler/lib/bundler/man/bundle-help.1.ronn +12 -0
  112. data/bundler/lib/bundler/man/bundle-info.1 +20 -0
  113. data/bundler/lib/bundler/man/bundle-info.1.ronn +17 -0
  114. data/bundler/lib/bundler/man/bundle-init.1 +29 -0
  115. data/bundler/lib/bundler/man/bundle-init.1.ronn +31 -0
  116. data/bundler/lib/bundler/man/bundle-inject.1 +36 -0
  117. data/bundler/lib/bundler/man/bundle-inject.1.ronn +24 -0
  118. data/bundler/lib/bundler/man/bundle-install.1 +313 -0
  119. data/bundler/lib/bundler/man/bundle-install.1.ronn +382 -0
  120. data/bundler/lib/bundler/man/bundle-list.1 +50 -0
  121. data/bundler/lib/bundler/man/bundle-list.1.ronn +33 -0
  122. data/bundler/lib/bundler/man/bundle-lock.1 +84 -0
  123. data/bundler/lib/bundler/man/bundle-lock.1.ronn +94 -0
  124. data/bundler/lib/bundler/man/bundle-open.1 +52 -0
  125. data/bundler/lib/bundler/man/bundle-open.1.ronn +27 -0
  126. data/bundler/lib/bundler/man/bundle-outdated.1 +152 -0
  127. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +105 -0
  128. data/bundler/lib/bundler/man/bundle-platform.1 +71 -0
  129. data/bundler/lib/bundler/man/bundle-platform.1.ronn +49 -0
  130. data/bundler/lib/bundler/man/bundle-plugin.1 +81 -0
  131. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  132. data/bundler/lib/bundler/man/bundle-pristine.1 +34 -0
  133. data/bundler/lib/bundler/man/bundle-pristine.1.ronn +34 -0
  134. data/bundler/lib/bundler/man/bundle-remove.1 +31 -0
  135. data/bundler/lib/bundler/man/bundle-remove.1.ronn +23 -0
  136. data/bundler/lib/bundler/man/bundle-show.1 +23 -0
  137. data/bundler/lib/bundler/man/bundle-show.1.ronn +21 -0
  138. data/bundler/lib/bundler/man/bundle-update.1 +394 -0
  139. data/bundler/lib/bundler/man/bundle-update.1.ronn +351 -0
  140. data/bundler/lib/bundler/man/bundle-version.1 +35 -0
  141. data/bundler/lib/bundler/man/bundle-version.1.ronn +24 -0
  142. data/bundler/lib/bundler/man/bundle-viz.1 +42 -0
  143. data/bundler/lib/bundler/man/bundle-viz.1.ronn +32 -0
  144. data/bundler/lib/bundler/man/bundle.1 +141 -0
  145. data/bundler/lib/bundler/man/bundle.1.ronn +116 -0
  146. data/bundler/lib/bundler/man/gemfile.5 +747 -0
  147. data/bundler/lib/bundler/man/gemfile.5.ronn +548 -0
  148. data/bundler/lib/bundler/man/index.txt +29 -0
  149. data/bundler/lib/bundler/match_metadata.rb +13 -0
  150. data/bundler/lib/bundler/match_platform.rb +23 -0
  151. data/bundler/lib/bundler/match_remote_metadata.rb +29 -0
  152. data/bundler/lib/bundler/mirror.rb +221 -0
  153. data/bundler/lib/bundler/plugin/api/source.rb +320 -0
  154. data/bundler/lib/bundler/plugin/api.rb +81 -0
  155. data/bundler/lib/bundler/plugin/dsl.rb +53 -0
  156. data/bundler/lib/bundler/plugin/events.rb +61 -0
  157. data/bundler/lib/bundler/plugin/index.rb +193 -0
  158. data/bundler/lib/bundler/plugin/installer/git.rb +34 -0
  159. data/bundler/lib/bundler/plugin/installer/rubygems.rb +19 -0
  160. data/bundler/lib/bundler/plugin/installer.rb +112 -0
  161. data/bundler/lib/bundler/plugin/source_list.rb +31 -0
  162. data/bundler/lib/bundler/plugin.rb +359 -0
  163. data/bundler/lib/bundler/process_lock.rb +24 -0
  164. data/bundler/lib/bundler/remote_specification.rb +117 -0
  165. data/bundler/lib/bundler/resolver/base.rb +107 -0
  166. data/bundler/lib/bundler/resolver/candidate.rb +94 -0
  167. data/bundler/lib/bundler/resolver/incompatibility.rb +15 -0
  168. data/bundler/lib/bundler/resolver/package.rb +77 -0
  169. data/bundler/lib/bundler/resolver/root.rb +25 -0
  170. data/bundler/lib/bundler/resolver/spec_group.rb +82 -0
  171. data/bundler/lib/bundler/resolver.rb +462 -0
  172. data/bundler/lib/bundler/retry.rb +66 -0
  173. data/bundler/lib/bundler/ruby_dsl.rb +45 -0
  174. data/bundler/lib/bundler/ruby_version.rb +131 -0
  175. data/bundler/lib/bundler/rubygems_ext.rb +354 -0
  176. data/bundler/lib/bundler/rubygems_gem_installer.rb +187 -0
  177. data/bundler/lib/bundler/rubygems_integration.rb +562 -0
  178. data/bundler/lib/bundler/runtime.rb +307 -0
  179. data/bundler/lib/bundler/safe_marshal.rb +31 -0
  180. data/bundler/lib/bundler/self_manager.rb +170 -0
  181. data/bundler/lib/bundler/settings/validator.rb +102 -0
  182. data/bundler/lib/bundler/settings.rb +568 -0
  183. data/bundler/lib/bundler/setup.rb +30 -0
  184. data/bundler/lib/bundler/shared_helpers.rb +358 -0
  185. data/bundler/lib/bundler/similarity_detector.rb +63 -0
  186. data/bundler/lib/bundler/source/gemspec.rb +18 -0
  187. data/bundler/lib/bundler/source/git/git_proxy.rb +455 -0
  188. data/bundler/lib/bundler/source/git.rb +379 -0
  189. data/bundler/lib/bundler/source/metadata.rb +62 -0
  190. data/bundler/lib/bundler/source/path/installer.rb +53 -0
  191. data/bundler/lib/bundler/source/path.rb +260 -0
  192. data/bundler/lib/bundler/source/rubygems/remote.rb +68 -0
  193. data/bundler/lib/bundler/source/rubygems.rb +509 -0
  194. data/bundler/lib/bundler/source/rubygems_aggregate.rb +68 -0
  195. data/bundler/lib/bundler/source.rb +114 -0
  196. data/bundler/lib/bundler/source_list.rb +227 -0
  197. data/bundler/lib/bundler/source_map.rb +71 -0
  198. data/bundler/lib/bundler/spec_set.rb +219 -0
  199. data/bundler/lib/bundler/stub_specification.rb +118 -0
  200. data/bundler/lib/bundler/templates/.document +1 -0
  201. data/bundler/lib/bundler/templates/Executable +27 -0
  202. data/bundler/lib/bundler/templates/Executable.bundler +109 -0
  203. data/bundler/lib/bundler/templates/Executable.standalone +14 -0
  204. data/bundler/lib/bundler/templates/Gemfile +5 -0
  205. data/bundler/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  206. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +84 -0
  207. data/bundler/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  208. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +26 -0
  209. data/bundler/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
  210. data/bundler/lib/bundler/templates/newgem/README.md.tt +45 -0
  211. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +71 -0
  212. data/bundler/lib/bundler/templates/newgem/bin/console.tt +11 -0
  213. data/bundler/lib/bundler/templates/newgem/bin/setup.tt +8 -0
  214. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  215. data/bundler/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  216. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  217. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  218. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  219. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  220. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  221. data/bundler/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  222. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  223. data/bundler/lib/bundler/templates/newgem/gitignore.tt +23 -0
  224. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  225. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +9 -0
  226. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +15 -0
  227. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +51 -0
  228. data/bundler/lib/bundler/templates/newgem/rspec.tt +3 -0
  229. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  230. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  231. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
  232. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +15 -0
  233. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  234. data/bundler/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  235. data/bundler/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt +13 -0
  236. data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  237. data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  238. data/bundler/lib/bundler/ui/rg_proxy.rb +19 -0
  239. data/bundler/lib/bundler/ui/shell.rb +165 -0
  240. data/bundler/lib/bundler/ui/silent.rb +85 -0
  241. data/bundler/lib/bundler/ui.rb +9 -0
  242. data/bundler/lib/bundler/uri_credentials_filter.rb +43 -0
  243. data/bundler/lib/bundler/uri_normalizer.rb +23 -0
  244. data/bundler/lib/bundler/vendor/.document +1 -0
  245. data/bundler/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  246. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  247. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  248. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  249. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +128 -0
  250. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  251. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +2706 -0
  252. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  253. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
  254. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
  255. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  256. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1073 -0
  257. data/bundler/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  258. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  259. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  260. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  261. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  262. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  263. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  264. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  265. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  266. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  267. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  268. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  269. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  270. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  271. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  272. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  273. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  274. data/bundler/lib/bundler/vendor/thor/LICENSE.md +20 -0
  275. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +105 -0
  276. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +61 -0
  277. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +108 -0
  278. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
  279. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +373 -0
  280. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +130 -0
  281. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +340 -0
  282. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +825 -0
  283. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +151 -0
  284. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +107 -0
  285. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +106 -0
  286. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
  287. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
  288. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
  289. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  290. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
  291. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  292. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +89 -0
  293. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +195 -0
  294. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +178 -0
  295. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +293 -0
  296. data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  297. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +72 -0
  298. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +335 -0
  299. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +388 -0
  300. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +115 -0
  301. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  302. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +84 -0
  303. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/lcs_diff.rb +49 -0
  304. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  305. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  306. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  307. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
  308. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +285 -0
  309. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
  310. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +663 -0
  311. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  312. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  313. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  314. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +729 -0
  315. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  316. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  317. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1587 -0
  318. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  319. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  320. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  321. data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  322. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  323. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
  324. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +119 -0
  325. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  326. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  327. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  328. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  329. data/bundler/lib/bundler/vendored_fileutils.rb +4 -0
  330. data/bundler/lib/bundler/vendored_persistent.rb +15 -0
  331. data/bundler/lib/bundler/vendored_pub_grub.rb +4 -0
  332. data/bundler/lib/bundler/vendored_thor.rb +8 -0
  333. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  334. data/bundler/lib/bundler/vendored_uri.rb +4 -0
  335. data/bundler/lib/bundler/version.rb +13 -0
  336. data/bundler/lib/bundler/vlad.rb +17 -0
  337. data/bundler/lib/bundler/worker.rb +117 -0
  338. data/bundler/lib/bundler/yaml_serializer.rb +93 -0
  339. data/bundler/lib/bundler.rb +654 -0
  340. data/{test/rubygems/bogussources.rb → exe/gem} +5 -2
  341. data/exe/update_rubygems +38 -0
  342. data/hide_lib_for_update/note.txt +0 -4
  343. data/lib/rubygems/available_set.rb +9 -9
  344. data/lib/rubygems/basic_specification.rb +56 -37
  345. data/lib/rubygems/bundler_version_finder.rb +77 -0
  346. data/lib/rubygems/command.rb +142 -67
  347. data/lib/rubygems/command_manager.rb +61 -25
  348. data/lib/rubygems/commands/build_command.rb +88 -17
  349. data/lib/rubygems/commands/cert_command.rb +131 -82
  350. data/lib/rubygems/commands/check_command.rb +27 -24
  351. data/lib/rubygems/commands/cleanup_command.rb +56 -37
  352. data/lib/rubygems/commands/contents_command.rb +33 -35
  353. data/lib/rubygems/commands/dependency_command.rb +52 -63
  354. data/lib/rubygems/commands/environment_command.rb +31 -13
  355. data/lib/rubygems/commands/exec_command.rb +249 -0
  356. data/lib/rubygems/commands/fetch_command.rb +36 -19
  357. data/lib/rubygems/commands/generate_index_command.rb +21 -20
  358. data/lib/rubygems/commands/help_command.rb +21 -21
  359. data/lib/rubygems/commands/info_command.rb +38 -0
  360. data/lib/rubygems/commands/install_command.rb +65 -133
  361. data/lib/rubygems/commands/list_command.rb +10 -9
  362. data/lib/rubygems/commands/lock_command.rb +11 -13
  363. data/lib/rubygems/commands/mirror_command.rb +4 -4
  364. data/lib/rubygems/commands/open_command.rb +28 -26
  365. data/lib/rubygems/commands/outdated_command.rb +6 -6
  366. data/lib/rubygems/commands/owner_command.rb +50 -26
  367. data/lib/rubygems/commands/pristine_command.rb +96 -66
  368. data/lib/rubygems/commands/push_command.rb +52 -45
  369. data/lib/rubygems/commands/query_command.rb +22 -328
  370. data/lib/rubygems/commands/rdoc_command.rb +31 -31
  371. data/lib/rubygems/commands/search_command.rb +9 -9
  372. data/lib/rubygems/commands/server_command.rb +15 -76
  373. data/lib/rubygems/commands/setup_command.rb +375 -188
  374. data/lib/rubygems/commands/signin_command.rb +34 -0
  375. data/lib/rubygems/commands/signout_command.rb +32 -0
  376. data/lib/rubygems/commands/sources_command.rb +51 -35
  377. data/lib/rubygems/commands/specification_command.rb +39 -29
  378. data/lib/rubygems/commands/stale_command.rb +5 -4
  379. data/lib/rubygems/commands/uninstall_command.rb +94 -59
  380. data/lib/rubygems/commands/unpack_command.rb +43 -52
  381. data/lib/rubygems/commands/update_command.rb +154 -96
  382. data/lib/rubygems/commands/which_command.rb +13 -16
  383. data/lib/rubygems/commands/yank_command.rb +27 -31
  384. data/lib/rubygems/compatibility.rb +8 -26
  385. data/lib/rubygems/config_file.rb +214 -119
  386. data/lib/rubygems/core_ext/kernel_gem.rb +10 -14
  387. data/lib/rubygems/core_ext/kernel_require.rb +119 -88
  388. data/lib/rubygems/core_ext/kernel_warn.rb +49 -0
  389. data/lib/rubygems/core_ext/tcpsocket_init.rb +54 -0
  390. data/lib/rubygems/defaults.rb +174 -56
  391. data/lib/rubygems/dependency.rb +66 -51
  392. data/lib/rubygems/dependency_installer.rb +70 -225
  393. data/lib/rubygems/dependency_list.rb +32 -33
  394. data/lib/rubygems/deprecate.rb +112 -17
  395. data/lib/rubygems/doctor.rb +30 -30
  396. data/lib/rubygems/errors.rb +51 -9
  397. data/lib/rubygems/exceptions.rb +64 -35
  398. data/lib/rubygems/ext/build_error.rb +3 -1
  399. data/lib/rubygems/ext/builder.rb +96 -75
  400. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +27 -0
  401. data/lib/rubygems/ext/cargo_builder.rb +360 -0
  402. data/lib/rubygems/ext/cmake_builder.rb +6 -7
  403. data/lib/rubygems/ext/configure_builder.rb +6 -9
  404. data/lib/rubygems/ext/ext_conf_builder.rb +41 -60
  405. data/lib/rubygems/ext/rake_builder.rb +18 -21
  406. data/lib/rubygems/ext.rb +8 -7
  407. data/lib/rubygems/gem_runner.rb +22 -24
  408. data/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb +163 -0
  409. data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +105 -0
  410. data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +78 -0
  411. data/lib/rubygems/gemcutter_utilities.rb +244 -40
  412. data/lib/rubygems/indexer.rb +49 -55
  413. data/lib/rubygems/install_default_message.rb +3 -3
  414. data/lib/rubygems/install_message.rb +3 -3
  415. data/lib/rubygems/install_update_options.rb +103 -96
  416. data/lib/rubygems/installer.rb +370 -214
  417. data/lib/rubygems/installer_uninstaller_utils.rb +29 -0
  418. data/lib/rubygems/local_remote_options.rb +27 -27
  419. data/lib/rubygems/mock_gem_ui.rb +6 -9
  420. data/lib/rubygems/name_tuple.rb +16 -19
  421. data/lib/rubygems/openssl.rb +7 -0
  422. data/lib/rubygems/optparse/.document +1 -0
  423. data/lib/rubygems/optparse/COPYING +56 -0
  424. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  425. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  426. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  427. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  428. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  429. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  430. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  431. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  432. data/lib/rubygems/optparse/lib/optparse.rb +2308 -0
  433. data/lib/rubygems/optparse.rb +3 -0
  434. data/lib/rubygems/package/digest_io.rb +5 -7
  435. data/lib/rubygems/package/file_source.rb +6 -8
  436. data/lib/rubygems/package/io_source.rb +6 -4
  437. data/lib/rubygems/package/old.rb +18 -27
  438. data/lib/rubygems/package/source.rb +1 -1
  439. data/lib/rubygems/package/tar_header.rb +86 -71
  440. data/lib/rubygems/package/tar_reader/entry.rb +113 -20
  441. data/lib/rubygems/package/tar_reader.rb +13 -37
  442. data/lib/rubygems/package/tar_writer.rb +28 -44
  443. data/lib/rubygems/package.rb +234 -135
  444. data/lib/rubygems/package_task.rb +6 -12
  445. data/lib/rubygems/path_support.rb +18 -12
  446. data/lib/rubygems/platform.rb +123 -77
  447. data/lib/rubygems/psych_tree.rb +3 -2
  448. data/lib/rubygems/query_utils.rb +351 -0
  449. data/lib/rubygems/rdoc.rb +4 -326
  450. data/lib/rubygems/remote_fetcher.rb +89 -171
  451. data/lib/rubygems/request/connection_pools.rb +30 -23
  452. data/lib/rubygems/request/http_pool.rb +6 -7
  453. data/lib/rubygems/request/https_pool.rb +2 -3
  454. data/lib/rubygems/request.rb +88 -41
  455. data/lib/rubygems/request_set/gem_dependency_api.rb +171 -176
  456. data/lib/rubygems/request_set/lockfile/parser.rb +39 -49
  457. data/lib/rubygems/request_set/lockfile/tokenizer.rb +15 -13
  458. data/lib/rubygems/request_set/lockfile.rb +34 -32
  459. data/lib/rubygems/request_set.rb +115 -71
  460. data/lib/rubygems/requirement.rb +72 -63
  461. data/lib/rubygems/resolver/activation_request.rb +35 -60
  462. data/lib/rubygems/resolver/api_set/gem_parser.rb +20 -0
  463. data/lib/rubygems/resolver/api_set.rb +40 -32
  464. data/lib/rubygems/resolver/api_specification.rb +37 -18
  465. data/lib/rubygems/resolver/best_set.rb +15 -17
  466. data/lib/rubygems/resolver/composed_set.rb +9 -11
  467. data/lib/rubygems/resolver/conflict.rb +18 -24
  468. data/lib/rubygems/resolver/current_set.rb +2 -4
  469. data/lib/rubygems/resolver/dependency_request.rb +8 -9
  470. data/lib/rubygems/resolver/git_set.rb +8 -10
  471. data/lib/rubygems/resolver/git_specification.rb +11 -13
  472. data/lib/rubygems/resolver/index_set.rb +10 -12
  473. data/lib/rubygems/resolver/index_specification.rb +42 -11
  474. data/lib/rubygems/resolver/installed_specification.rb +9 -11
  475. data/lib/rubygems/resolver/installer_set.rb +93 -46
  476. data/lib/rubygems/resolver/local_specification.rb +5 -7
  477. data/lib/rubygems/resolver/lock_set.rb +13 -15
  478. data/lib/rubygems/resolver/lock_specification.rb +13 -15
  479. data/lib/rubygems/resolver/molinillo/LICENSE +9 -0
  480. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
  481. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +88 -0
  482. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
  483. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
  484. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
  485. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
  486. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
  487. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
  488. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
  489. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
  490. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +164 -0
  491. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +110 -146
  492. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +83 -9
  493. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  494. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +13 -1
  495. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +3 -1
  496. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +552 -172
  497. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +3 -2
  498. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +12 -6
  499. data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +6 -5
  500. data/lib/rubygems/resolver/molinillo.rb +2 -1
  501. data/lib/rubygems/resolver/requirement_list.rb +2 -2
  502. data/lib/rubygems/resolver/set.rb +3 -5
  503. data/lib/rubygems/resolver/source_set.rb +6 -7
  504. data/lib/rubygems/resolver/spec_specification.rb +16 -4
  505. data/lib/rubygems/resolver/specification.rb +25 -10
  506. data/lib/rubygems/resolver/stats.rb +1 -0
  507. data/lib/rubygems/resolver/vendor_set.rb +6 -8
  508. data/lib/rubygems/resolver/vendor_specification.rb +6 -8
  509. data/lib/rubygems/resolver.rb +120 -64
  510. data/lib/rubygems/s3_uri_signer.rb +177 -0
  511. data/lib/rubygems/safe_yaml.rb +59 -0
  512. data/lib/rubygems/security/policies.rb +49 -49
  513. data/lib/rubygems/security/policy.rb +44 -47
  514. data/lib/rubygems/security/signer.rb +86 -29
  515. data/lib/rubygems/security/trust_dir.rb +21 -23
  516. data/lib/rubygems/security.rb +111 -78
  517. data/lib/rubygems/security_option.rb +43 -0
  518. data/lib/rubygems/shellwords.rb +3 -0
  519. data/lib/rubygems/source/git.rb +40 -40
  520. data/lib/rubygems/source/installed.rb +5 -7
  521. data/lib/rubygems/source/local.rb +30 -30
  522. data/lib/rubygems/source/lock.rb +9 -7
  523. data/lib/rubygems/source/specific_file.rb +7 -8
  524. data/lib/rubygems/source/vendor.rb +3 -5
  525. data/lib/rubygems/source.rb +73 -63
  526. data/lib/rubygems/source_list.rb +14 -18
  527. data/lib/rubygems/spec_fetcher.rb +66 -78
  528. data/lib/rubygems/specification.rb +823 -1092
  529. data/lib/rubygems/specification_policy.rb +508 -0
  530. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem +21 -0
  531. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
  532. data/lib/rubygems/stub_specification.rb +52 -53
  533. data/lib/rubygems/text.rb +40 -27
  534. data/lib/rubygems/tsort/.document +1 -0
  535. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  536. data/lib/rubygems/tsort/lib/tsort.rb +452 -0
  537. data/lib/rubygems/tsort.rb +3 -0
  538. data/lib/rubygems/uninstaller.rb +149 -84
  539. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  540. data/lib/rubygems/update_suggestion.rb +69 -0
  541. data/lib/rubygems/uri.rb +126 -0
  542. data/lib/rubygems/uri_formatter.rb +3 -6
  543. data/lib/rubygems/user_interaction.rb +95 -143
  544. data/lib/rubygems/util/licenses.rb +679 -314
  545. data/lib/rubygems/util/list.rb +2 -1
  546. data/lib/rubygems/util.rb +58 -73
  547. data/lib/rubygems/validator.rb +23 -47
  548. data/lib/rubygems/version.rb +92 -48
  549. data/lib/rubygems/version_option.rb +20 -9
  550. data/lib/rubygems/yaml_serializer.rb +93 -0
  551. data/lib/rubygems.rb +434 -346
  552. data/rubygems-update.gemspec +38 -0
  553. data/setup.rb +13 -27
  554. data/test/rubygems/alternate_cert.pem +15 -14
  555. data/test/rubygems/alternate_cert_32.pem +16 -15
  556. data/test/rubygems/alternate_key.pem +25 -25
  557. data/test/rubygems/bad_rake.rb +1 -0
  558. data/test/rubygems/bundler_test_gem.rb +424 -0
  559. data/test/rubygems/ca_cert.pem +74 -65
  560. data/test/rubygems/child_cert.pem +16 -15
  561. data/test/rubygems/child_cert_32.pem +16 -15
  562. data/test/rubygems/child_key.pem +25 -25
  563. data/test/rubygems/client.pem +103 -45
  564. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  565. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  566. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  567. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  568. data/test/rubygems/encrypted_private_key.pem +26 -26
  569. data/test/rubygems/expired_cert.pem +15 -14
  570. data/test/rubygems/fake_certlib/openssl.rb +1 -0
  571. data/test/rubygems/future_cert.pem +15 -14
  572. data/test/rubygems/future_cert_32.pem +15 -14
  573. data/test/rubygems/good_rake.rb +1 -0
  574. data/test/rubygems/grandchild_cert.pem +16 -15
  575. data/test/rubygems/grandchild_cert_32.pem +16 -15
  576. data/test/rubygems/grandchild_key.pem +25 -25
  577. data/{lib/rubygems/test_case.rb → test/rubygems/helper.rb} +643 -490
  578. data/{lib → test}/rubygems/installer_test_case.rb +118 -64
  579. data/test/rubygems/invalid_issuer_cert.pem +17 -15
  580. data/test/rubygems/invalid_issuer_cert_32.pem +17 -15
  581. data/test/rubygems/invalid_key.pem +25 -25
  582. data/test/rubygems/invalid_signer_cert.pem +16 -15
  583. data/test/rubygems/invalid_signer_cert_32.pem +16 -15
  584. data/test/rubygems/invalidchild_cert.pem +16 -15
  585. data/test/rubygems/invalidchild_cert_32.pem +16 -15
  586. data/test/rubygems/invalidchild_key.pem +25 -25
  587. data/test/rubygems/multifactor_auth_utilities.rb +111 -0
  588. data/{lib → test}/rubygems/package/tar_test_case.rb +54 -26
  589. data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
  590. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  591. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  592. data/test/rubygems/plugin/exception/rubygems_plugin.rb +2 -1
  593. data/test/rubygems/plugin/load/rubygems_plugin.rb +1 -0
  594. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +2 -1
  595. data/test/rubygems/private3072_key.pem +40 -0
  596. data/test/rubygems/private_ec_key.pem +9 -0
  597. data/test/rubygems/private_key.pem +25 -25
  598. data/test/rubygems/public3072_cert.pem +25 -0
  599. data/test/rubygems/public_cert.pem +17 -15
  600. data/test/rubygems/public_cert_32.pem +16 -15
  601. data/test/rubygems/public_key.pem +7 -7
  602. data/test/rubygems/rubygems/commands/crash_command.rb +1 -2
  603. data/test/rubygems/rubygems_plugin.rb +7 -5
  604. data/test/rubygems/simple_gem.rb +1 -0
  605. data/test/rubygems/specifications/bar-0.0.2.gemspec +1 -1
  606. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +14 -0
  607. data/test/rubygems/ssl_cert.pem +78 -17
  608. data/test/rubygems/ssl_key.pem +25 -13
  609. data/test/rubygems/test_bundled_ca.rb +45 -43
  610. data/test/rubygems/test_config.rb +13 -9
  611. data/test/rubygems/test_deprecate.rb +91 -10
  612. data/test/rubygems/test_exit.rb +17 -0
  613. data/test/rubygems/test_gem.rb +917 -797
  614. data/test/rubygems/test_gem_available_set.rb +25 -25
  615. data/test/rubygems/test_gem_bundler_version_finder.rb +127 -0
  616. data/test/rubygems/test_gem_command.rb +195 -40
  617. data/test/rubygems/test_gem_command_manager.rb +182 -46
  618. data/test/rubygems/test_gem_commands_build_command.rb +646 -28
  619. data/test/rubygems/test_gem_commands_cert_command.rb +321 -126
  620. data/test/rubygems/test_gem_commands_check_command.rb +11 -12
  621. data/test/rubygems/test_gem_commands_cleanup_command.rb +147 -52
  622. data/test/rubygems/test_gem_commands_contents_command.rb +75 -44
  623. data/test/rubygems/test_gem_commands_dependency_command.rb +61 -63
  624. data/test/rubygems/test_gem_commands_environment_command.rb +62 -47
  625. data/test/rubygems/test_gem_commands_exec_command.rb +857 -0
  626. data/test/rubygems/test_gem_commands_fetch_command.rb +164 -33
  627. data/test/rubygems/test_gem_commands_generate_index_command.rb +39 -9
  628. data/test/rubygems/test_gem_commands_help_command.rb +36 -17
  629. data/test/rubygems/test_gem_commands_info_command.rb +70 -0
  630. data/test/rubygems/test_gem_commands_install_command.rb +736 -150
  631. data/test/rubygems/test_gem_commands_list_command.rb +6 -7
  632. data/test/rubygems/test_gem_commands_lock_command.rb +12 -14
  633. data/test/rubygems/test_gem_commands_mirror.rb +4 -4
  634. data/test/rubygems/test_gem_commands_open_command.rb +47 -16
  635. data/test/rubygems/test_gem_commands_outdated_command.rb +25 -8
  636. data/test/rubygems/test_gem_commands_owner_command.rb +368 -70
  637. data/test/rubygems/test_gem_commands_pristine_command.rb +318 -101
  638. data/test/rubygems/test_gem_commands_push_command.rb +331 -58
  639. data/test/rubygems/test_gem_commands_query_command.rb +329 -128
  640. data/test/rubygems/test_gem_commands_search_command.rb +3 -5
  641. data/test/rubygems/test_gem_commands_server_command.rb +7 -47
  642. data/test/rubygems/test_gem_commands_setup_command.rb +404 -66
  643. data/test/rubygems/test_gem_commands_signin_command.rb +259 -0
  644. data/test/rubygems/test_gem_commands_signout_command.rb +30 -0
  645. data/test/rubygems/test_gem_commands_sources_command.rb +316 -31
  646. data/test/rubygems/test_gem_commands_specification_command.rb +82 -56
  647. data/test/rubygems/test_gem_commands_stale_command.rb +9 -9
  648. data/test/rubygems/test_gem_commands_uninstall_command.rb +347 -88
  649. data/test/rubygems/test_gem_commands_unpack_command.rb +49 -34
  650. data/test/rubygems/test_gem_commands_update_command.rb +429 -107
  651. data/test/rubygems/test_gem_commands_which_command.rb +13 -15
  652. data/test/rubygems/test_gem_commands_yank_command.rb +227 -28
  653. data/test/rubygems/test_gem_config_file.rb +168 -108
  654. data/test/rubygems/test_gem_dependency.rb +112 -76
  655. data/test/rubygems/test_gem_dependency_installer.rb +346 -391
  656. data/test/rubygems/test_gem_dependency_list.rb +68 -63
  657. data/test/rubygems/test_gem_dependency_resolution_error.rb +6 -8
  658. data/test/rubygems/test_gem_doctor.rb +75 -49
  659. data/test/rubygems/test_gem_ext_builder.rb +121 -125
  660. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +1 -0
  661. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +10 -0
  662. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +249 -0
  663. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +10 -0
  664. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +27 -0
  665. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +3 -0
  666. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +1 -0
  667. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +249 -0
  668. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +10 -0
  669. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +10 -0
  670. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +51 -0
  671. data/test/rubygems/test_gem_ext_cargo_builder.rb +167 -0
  672. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +34 -0
  673. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +60 -0
  674. data/test/rubygems/test_gem_ext_cmake_builder.rb +33 -36
  675. data/test/rubygems/test_gem_ext_configure_builder.rb +25 -32
  676. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +94 -76
  677. data/test/rubygems/test_gem_ext_rake_builder.rb +79 -31
  678. data/test/rubygems/test_gem_gem_runner.rb +59 -9
  679. data/test/rubygems/test_gem_gemcutter_utilities.rb +210 -84
  680. data/test/rubygems/test_gem_impossible_dependencies_error.rb +5 -7
  681. data/test/rubygems/test_gem_indexer.rb +121 -107
  682. data/test/rubygems/test_gem_install_update_options.rb +65 -54
  683. data/test/rubygems/test_gem_installer.rb +1517 -557
  684. data/test/rubygems/test_gem_local_remote_options.rb +14 -15
  685. data/test/rubygems/test_gem_name_tuple.rb +5 -7
  686. data/test/rubygems/test_gem_package.rb +673 -243
  687. data/test/rubygems/test_gem_package_old.rb +58 -57
  688. data/test/rubygems/test_gem_package_tar_header.rb +129 -50
  689. data/test/rubygems/test_gem_package_tar_reader.rb +71 -11
  690. data/test/rubygems/test_gem_package_tar_reader_entry.rb +229 -21
  691. data/test/rubygems/test_gem_package_tar_writer.rb +168 -101
  692. data/test/rubygems/test_gem_package_task.rb +59 -25
  693. data/test/rubygems/test_gem_path_support.rb +49 -31
  694. data/test/rubygems/test_gem_platform.rb +393 -204
  695. data/test/rubygems/test_gem_rdoc.rb +23 -156
  696. data/test/rubygems/test_gem_remote_fetcher.rb +580 -404
  697. data/test/rubygems/test_gem_request.rb +270 -86
  698. data/test/rubygems/test_gem_request_connection_pools.rb +57 -35
  699. data/test/rubygems/test_gem_request_set.rb +192 -115
  700. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +300 -278
  701. data/test/rubygems/test_gem_request_set_lockfile.rb +95 -96
  702. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +73 -78
  703. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +138 -137
  704. data/test/rubygems/test_gem_requirement.rb +175 -57
  705. data/test/rubygems/test_gem_resolver.rb +257 -113
  706. data/test/rubygems/test_gem_resolver_activation_request.rb +10 -41
  707. data/test/rubygems/test_gem_resolver_api_set.rb +80 -79
  708. data/test/rubygems/test_gem_resolver_api_specification.rb +64 -42
  709. data/test/rubygems/test_gem_resolver_best_set.rb +44 -23
  710. data/test/rubygems/test_gem_resolver_composed_set.rb +2 -4
  711. data/test/rubygems/test_gem_resolver_conflict.rb +13 -19
  712. data/test/rubygems/test_gem_resolver_dependency_request.rb +16 -18
  713. data/test/rubygems/test_gem_resolver_git_set.rb +23 -25
  714. data/test/rubygems/test_gem_resolver_git_specification.rb +23 -23
  715. data/test/rubygems/test_gem_resolver_index_set.rb +15 -17
  716. data/test/rubygems/test_gem_resolver_index_specification.rb +22 -19
  717. data/test/rubygems/test_gem_resolver_installed_specification.rb +6 -9
  718. data/test/rubygems/test_gem_resolver_installer_set.rb +110 -48
  719. data/test/rubygems/test_gem_resolver_local_specification.rb +8 -10
  720. data/test/rubygems/test_gem_resolver_lock_set.rb +16 -18
  721. data/test/rubygems/test_gem_resolver_lock_specification.rb +18 -20
  722. data/test/rubygems/test_gem_resolver_requirement_list.rb +2 -4
  723. data/test/rubygems/test_gem_resolver_specification.rb +10 -12
  724. data/test/rubygems/test_gem_resolver_vendor_set.rb +10 -12
  725. data/test/rubygems/test_gem_resolver_vendor_specification.rb +11 -13
  726. data/test/rubygems/test_gem_security.rb +116 -82
  727. data/test/rubygems/test_gem_security_policy.rb +128 -134
  728. data/test/rubygems/test_gem_security_signer.rb +58 -49
  729. data/test/rubygems/test_gem_security_trust_dir.rb +19 -21
  730. data/test/rubygems/test_gem_silent_ui.rb +48 -42
  731. data/test/rubygems/test_gem_source.rb +73 -61
  732. data/test/rubygems/test_gem_source_fetch_problem.rb +23 -6
  733. data/test/rubygems/test_gem_source_git.rb +79 -78
  734. data/test/rubygems/test_gem_source_installed.rb +17 -19
  735. data/test/rubygems/test_gem_source_list.rb +6 -5
  736. data/test/rubygems/test_gem_source_local.rb +16 -16
  737. data/test/rubygems/test_gem_source_lock.rb +32 -34
  738. data/test/rubygems/test_gem_source_specific_file.rb +19 -19
  739. data/test/rubygems/test_gem_source_subpath_problem.rb +50 -0
  740. data/test/rubygems/test_gem_source_vendor.rb +14 -16
  741. data/test/rubygems/test_gem_spec_fetcher.rb +89 -62
  742. data/test/rubygems/test_gem_specification.rb +1441 -1104
  743. data/test/rubygems/test_gem_stream_ui.rb +71 -55
  744. data/test/rubygems/test_gem_stub_specification.rb +102 -41
  745. data/test/rubygems/test_gem_text.rb +27 -1
  746. data/test/rubygems/test_gem_uninstaller.rb +289 -99
  747. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +4 -6
  748. data/test/rubygems/test_gem_update_suggestion.rb +209 -0
  749. data/test/rubygems/test_gem_uri.rb +41 -0
  750. data/test/rubygems/test_gem_uri_formatter.rb +15 -17
  751. data/test/rubygems/test_gem_util.rb +68 -17
  752. data/test/rubygems/test_gem_validator.rb +12 -16
  753. data/test/rubygems/test_gem_version.rb +123 -40
  754. data/test/rubygems/test_gem_version_option.rb +30 -17
  755. data/test/rubygems/test_kernel.rb +75 -37
  756. data/test/rubygems/test_project_sanity.rb +49 -0
  757. data/test/rubygems/test_remote_fetch_error.rb +20 -0
  758. data/test/rubygems/test_require.rb +527 -117
  759. data/test/rubygems/test_rubygems.rb +76 -0
  760. data/test/rubygems/test_webauthn_listener.rb +143 -0
  761. data/test/rubygems/test_webauthn_listener_response.rb +93 -0
  762. data/test/rubygems/test_webauthn_poller.rb +124 -0
  763. data/{lib/rubygems/test_utilities.rb → test/rubygems/utilities.rb} +135 -83
  764. data/test/rubygems/wrong_key_cert.pem +16 -15
  765. data/test/rubygems/wrong_key_cert_32.pem +16 -15
  766. data/test/test_changelog_generator.rb +17 -0
  767. metadata +513 -189
  768. data/.autotest +0 -71
  769. data/.document +0 -5
  770. data/.travis.yml +0 -46
  771. data/CONTRIBUTING.rdoc +0 -129
  772. data/CVE-2013-4287.txt +0 -35
  773. data/CVE-2013-4363.txt +0 -45
  774. data/CVE-2015-3900.txt +0 -40
  775. data/History.txt +0 -3094
  776. data/MAINTAINERS.md +0 -5
  777. data/POLICIES.rdoc +0 -61
  778. data/README.rdoc +0 -54
  779. data/Rakefile +0 -449
  780. data/UPGRADING.rdoc +0 -92
  781. data/appveyor.yml +0 -36
  782. data/bin/gem +0 -25
  783. data/bin/update_rubygems +0 -37
  784. data/lib/gauntlet_rubygems.rb +0 -51
  785. data/lib/rubygems/psych_additions.rb +0 -10
  786. data/lib/rubygems/server.rb +0 -869
  787. data/lib/rubygems/source_local.rb +0 -6
  788. data/lib/rubygems/source_specific_file.rb +0 -5
  789. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  790. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +0 -32
  791. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  792. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  793. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  794. data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  795. data/lib/rubygems/syck_hack.rb +0 -77
  796. data/lib/ubygems.rb +0 -11
  797. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  798. data/test/rubygems/fix_openssl_warnings.rb +0 -13
  799. data/test/rubygems/test_gem_server.rb +0 -409
  800. data/util/CL2notes +0 -56
  801. data/util/create_certs.rb +0 -157
  802. data/util/create_encrypted_key.rb +0 -17
  803. data/util/generate_spdx_license_list.rb +0 -51
  804. data/util/update_bundled_ca_certificates.rb +0 -118
@@ -1,23 +1,20 @@
1
- # -*- coding: utf-8 -*-
2
1
  # frozen_string_literal: true
2
+
3
+ #
3
4
  #--
4
5
  # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
5
6
  # All rights reserved.
6
7
  # See LICENSE.txt for permissions.
7
8
  #++
8
9
 
9
-
10
- require 'rubygems/version'
11
- require 'rubygems/requirement'
12
- require 'rubygems/platform'
13
- require 'rubygems/deprecate'
14
- require 'rubygems/basic_specification'
15
- require 'rubygems/stub_specification'
16
- require 'rubygems/util/list'
17
- require 'stringio'
10
+ require_relative "deprecate"
11
+ require_relative "basic_specification"
12
+ require_relative "stub_specification"
13
+ require_relative "platform"
14
+ require_relative "util/list"
18
15
 
19
16
  ##
20
- # The Specification class contains the information for a Gem. Typically
17
+ # The Specification class contains the information for a gem. Typically
21
18
  # defined in a .gemspec file or a Rakefile, and looks like this:
22
19
  #
23
20
  # Gem::Specification.new do |s|
@@ -30,6 +27,7 @@ require 'stringio'
30
27
  # s.email = 'rubycoder@example.com'
31
28
  # s.files = ["lib/example.rb"]
32
29
  # s.homepage = 'https://rubygems.org/gems/example'
30
+ # s.metadata = { "source_code_uri" => "https://github.com/example/example" }
33
31
  # end
34
32
  #
35
33
  # Starting in RubyGems 2.0, a Specification can hold arbitrary
@@ -37,6 +35,7 @@ require 'stringio'
37
35
  # items you may add to a specification.
38
36
 
39
37
  class Gem::Specification < Gem::BasicSpecification
38
+ extend Gem::Deprecate
40
39
 
41
40
  # REFACTOR: Consider breaking out this version stuff into a separate
42
41
  # module. There's enough special stuff around it that it may justify
@@ -76,37 +75,38 @@ class Gem::Specification < Gem::BasicSpecification
76
75
  # key should be equal to the CURRENT_SPECIFICATION_VERSION.
77
76
 
78
77
  SPECIFICATION_VERSION_HISTORY = { # :nodoc:
79
- -1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'],
80
- 1 => [
78
+ -1 => ["(RubyGems versions up to and including 0.7 did not have versioned specifications)"],
79
+ 1 => [
81
80
  'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"',
82
- '"test_file=x" is a shortcut for "test_files=[x]"'
81
+ '"test_file=x" is a shortcut for "test_files=[x]"',
83
82
  ],
84
- 2 => [
83
+ 2 => [
85
84
  'Added "required_rubygems_version"',
86
- 'Now forward-compatible with future versions',
85
+ "Now forward-compatible with future versions",
87
86
  ],
88
87
  3 => [
89
- 'Added Fixnum validation to the specification_version'
88
+ "Added Fixnum validation to the specification_version",
90
89
  ],
91
90
  4 => [
92
- 'Added sandboxed freeform metadata to the specification version.'
93
- ]
94
- }
91
+ "Added sandboxed freeform metadata to the specification version.",
92
+ ],
93
+ }.freeze
95
94
 
96
95
  MARSHAL_FIELDS = { # :nodoc:
97
96
  -1 => 16,
98
- 1 => 16,
99
- 2 => 16,
100
- 3 => 17,
101
- 4 => 18,
102
- }
97
+ 1 => 16,
98
+ 2 => 16,
99
+ 3 => 17,
100
+ 4 => 18,
101
+ }.freeze
103
102
 
104
103
  today = Time.now.utc
105
104
  TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
106
105
 
107
- LOAD_CACHE = {} # :nodoc:
106
+ @load_cache = {} # :nodoc:
107
+ @load_cache_mutex = Thread::Mutex.new
108
108
 
109
- private_constant :LOAD_CACHE if defined? private_constant
109
+ VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
110
110
 
111
111
  # :startdoc:
112
112
 
@@ -125,61 +125,79 @@ class Gem::Specification < Gem::BasicSpecification
125
125
  # Map of attribute names to default values.
126
126
 
127
127
  @@default_value = {
128
- :authors => [],
129
- :autorequire => nil,
130
- :bindir => 'bin',
131
- :cert_chain => [],
132
- :date => TODAY,
133
- :dependencies => [],
134
- :description => nil,
135
- :email => nil,
136
- :executables => [],
137
- :extensions => [],
138
- :extra_rdoc_files => [],
139
- :files => [],
140
- :homepage => nil,
141
- :licenses => [],
142
- :metadata => {},
143
- :name => nil,
144
- :platform => Gem::Platform::RUBY,
145
- :post_install_message => nil,
146
- :rdoc_options => [],
147
- :require_paths => ['lib'],
148
- :required_ruby_version => Gem::Requirement.default,
128
+ :authors => [],
129
+ :autorequire => nil,
130
+ :bindir => "bin",
131
+ :cert_chain => [],
132
+ :date => nil,
133
+ :dependencies => [],
134
+ :description => nil,
135
+ :email => nil,
136
+ :executables => [],
137
+ :extensions => [],
138
+ :extra_rdoc_files => [],
139
+ :files => [],
140
+ :homepage => nil,
141
+ :licenses => [],
142
+ :metadata => {},
143
+ :name => nil,
144
+ :platform => Gem::Platform::RUBY,
145
+ :post_install_message => nil,
146
+ :rdoc_options => [],
147
+ :require_paths => ["lib"],
148
+ :required_ruby_version => Gem::Requirement.default,
149
149
  :required_rubygems_version => Gem::Requirement.default,
150
- :requirements => [],
151
- :rubyforge_project => nil,
152
- :rubygems_version => Gem::VERSION,
153
- :signing_key => nil,
154
- :specification_version => CURRENT_SPECIFICATION_VERSION,
155
- :summary => nil,
156
- :test_files => [],
157
- :version => nil,
158
- }
159
-
160
- Dupable = { } # :nodoc:
150
+ :requirements => [],
151
+ :rubygems_version => Gem::VERSION,
152
+ :signing_key => nil,
153
+ :specification_version => CURRENT_SPECIFICATION_VERSION,
154
+ :summary => nil,
155
+ :test_files => [],
156
+ :version => nil,
157
+ }.freeze
158
+
159
+ # rubocop:disable Style/MutableConstant
160
+ INITIALIZE_CODE_FOR_DEFAULTS = {} # :nodoc:
161
+ # rubocop:enable Style/MutableConstant
161
162
 
162
163
  @@default_value.each do |k,v|
163
- case v
164
- when Time, Numeric, Symbol, true, false, nil
165
- Dupable[k] = false
164
+ INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
165
+ when [], {}, true, false, nil, Numeric, Symbol
166
+ v.inspect
167
+ when String
168
+ v.dump
169
+ when Numeric
170
+ "default_value(:#{k})"
166
171
  else
167
- Dupable[k] = true
172
+ "default_value(:#{k}).dup"
168
173
  end
169
174
  end
170
175
 
171
- @@attributes = @@default_value.keys.sort_by { |s| s.to_s }
172
- @@array_attributes = @@default_value.reject { |k,v| v != [] }.keys
173
- @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition { |k|
176
+ @@attributes = @@default_value.keys.sort_by {|s| s.to_s }
177
+ @@array_attributes = @@default_value.reject {|k,v| v != [] }.keys
178
+ @@nil_attributes, @@non_nil_attributes = @@default_value.keys.partition do |k|
174
179
  @@default_value[k].nil?
175
- }
180
+ end
181
+
182
+ def self.clear_specs # :nodoc:
183
+ @@all = nil
184
+ @@stubs = nil
185
+ @@stubs_by_name = {}
186
+ @@spec_with_requirable_file = {}
187
+ @@active_stub_with_requirable_file = {}
188
+ end
189
+ private_class_method :clear_specs
176
190
 
177
- @@stubs_by_name = {}
191
+ clear_specs
178
192
 
179
193
  # Sentinel object to represent "not found" stubs
180
194
  NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc:
181
- @@spec_with_requirable_file = {}
182
- @@active_stub_with_requirable_file = {}
195
+
196
+ # Tracking removed method calls to warn users during build time.
197
+ REMOVED_METHODS = [:rubyforge_project=].freeze # :nodoc:
198
+ def removed_method_calls
199
+ @removed_method_calls ||= []
200
+ end
183
201
 
184
202
  ######################################################################
185
203
  # :section: Required gemspec attributes
@@ -207,35 +225,7 @@ class Gem::Specification < Gem::BasicSpecification
207
225
  attr_reader :version
208
226
 
209
227
  ##
210
- # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
211
- # activated.
212
- #
213
- # See also #require_paths
214
- #
215
- # If you have an extension you do not need to add <code>"ext"</code> to the
216
- # require path, the extension build process will copy the extension files
217
- # into "lib" for you.
218
- #
219
- # The default value is <code>"lib"</code>
220
- #
221
- # Usage:
222
- #
223
- # # If all library files are in the root directory...
224
- # spec.require_paths = ['.']
225
-
226
- def require_paths=(val)
227
- @require_paths = Array(val)
228
- end
229
-
230
- ##
231
- # The version of RubyGems used to create this gem.
232
- #
233
- # Do not set this, it is set automatically when the gem is packaged.
234
-
235
- attr_accessor :rubygems_version
236
-
237
- ##
238
- # A short summary of this gem's description. Displayed in `gem list -d`.
228
+ # A short summary of this gem's description. Displayed in <tt>gem list -d</tt>.
239
229
  #
240
230
  # The #description should be more detailed than the summary.
241
231
  #
@@ -245,85 +235,6 @@ class Gem::Specification < Gem::BasicSpecification
245
235
 
246
236
  attr_reader :summary
247
237
 
248
- ##
249
- # Singular writer for #authors
250
- #
251
- # Usage:
252
- #
253
- # spec.author = 'John Jones'
254
-
255
- def author= o
256
- self.authors = [o]
257
- end
258
-
259
- ##
260
- # Sets the list of authors, ensuring it is an array.
261
- #
262
- # Usage:
263
- #
264
- # spec.authors = ['John Jones', 'Mary Smith']
265
-
266
- def authors= value
267
- @authors = Array(value).flatten.grep(String)
268
- end
269
-
270
- ##
271
- # The platform this gem runs on.
272
- #
273
- # This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT.
274
- #
275
- # Most gems contain pure Ruby code; they should simply leave the default
276
- # value in place. Some gems contain C (or other) code to be compiled into a
277
- # Ruby "extension". The gem should leave the default value in place unless
278
- # the code will only compile on a certain type of system. Some gems consist
279
- # of pre-compiled code ("binary gems"). It's especially important that they
280
- # set the platform attribute appropriately. A shortcut is to set the
281
- # platform to Gem::Platform::CURRENT, which will cause the gem builder to set
282
- # the platform to the appropriate value for the system on which the build is
283
- # being performed.
284
- #
285
- # If this attribute is set to a non-default value, it will be included in
286
- # the filename of the gem when it is built such as:
287
- # nokogiri-1.6.0-x86-mingw32.gem
288
- #
289
- # Usage:
290
- #
291
- # spec.platform = Gem::Platform.local
292
-
293
- def platform= platform
294
- if @original_platform.nil? or
295
- @original_platform == Gem::Platform::RUBY then
296
- @original_platform = platform
297
- end
298
-
299
- case platform
300
- when Gem::Platform::CURRENT then
301
- @new_platform = Gem::Platform.local
302
- @original_platform = @new_platform.to_s
303
-
304
- when Gem::Platform then
305
- @new_platform = platform
306
-
307
- # legacy constants
308
- when nil, Gem::Platform::RUBY then
309
- @new_platform = Gem::Platform::RUBY
310
- when 'mswin32' then # was Gem::Platform::WIN32
311
- @new_platform = Gem::Platform.new 'x86-mswin32'
312
- when 'i586-linux' then # was Gem::Platform::LINUX_586
313
- @new_platform = Gem::Platform.new 'x86-linux'
314
- when 'powerpc-darwin' then # was Gem::Platform::DARWIN
315
- @new_platform = Gem::Platform.new 'ppc-darwin'
316
- else
317
- @new_platform = Gem::Platform.new platform
318
- end
319
-
320
- @platform = @new_platform.to_s
321
-
322
- invalidate_memoized_attributes
323
-
324
- @new_platform
325
- end
326
-
327
238
  ##
328
239
  # Files included in this gem. You cannot append to this accessor, you must
329
240
  # assign to it.
@@ -338,12 +249,11 @@ class Gem::Specification < Gem::BasicSpecification
338
249
  # require 'rake'
339
250
  # spec.files = FileList['lib/**/*.rb',
340
251
  # 'bin/*',
341
- # '[A-Z]*',
342
- # 'test/**/*'].to_a
252
+ # '[A-Z]*'].to_a
343
253
  #
344
254
  # # or without Rake...
345
255
  # spec.files = Dir['lib/**/*.rb'] + Dir['bin/*']
346
- # spec.files += Dir['[A-Z]*'] + Dir['test/**/*']
256
+ # spec.files += Dir['[A-Z]*']
347
257
  # spec.files.reject! { |fn| fn.include? "CVS" }
348
258
 
349
259
  def files
@@ -357,23 +267,31 @@ class Gem::Specification < Gem::BasicSpecification
357
267
  ].flatten.compact.uniq.sort
358
268
  end
359
269
 
360
- ######################################################################
361
- # :section: Optional gemspec attributes
362
-
363
270
  ##
364
- # The path in the gem for executable scripts. Usually 'bin'
271
+ # A list of authors for this gem.
272
+ #
273
+ # Alternatively, a single author can be specified by assigning a string to
274
+ # +spec.author+
365
275
  #
366
276
  # Usage:
367
277
  #
368
- # spec.bindir = 'bin'
278
+ # spec.authors = ['John Jones', 'Mary Smith']
369
279
 
370
- attr_accessor :bindir
280
+ def authors=(value)
281
+ @authors = Array(value).flatten.grep(String)
282
+ end
283
+
284
+ ######################################################################
285
+ # :section: Recommended gemspec attributes
371
286
 
372
287
  ##
373
- # The certificate chain used to sign this gem. See Gem::Security for
374
- # details.
288
+ # The version of Ruby required by this gem
289
+ #
290
+ # Usage:
291
+ #
292
+ # spec.required_ruby_version = '>= 2.7.0'
375
293
 
376
- attr_accessor :cert_chain
294
+ attr_reader :required_ruby_version
377
295
 
378
296
  ##
379
297
  # A long description of this gem
@@ -392,8 +310,6 @@ class Gem::Specification < Gem::BasicSpecification
392
310
  attr_reader :description
393
311
 
394
312
  ##
395
- # :category: Recommended gemspec attributes
396
- #
397
313
  # A contact email address (or addresses) for this gem
398
314
  #
399
315
  # Usage:
@@ -404,8 +320,6 @@ class Gem::Specification < Gem::BasicSpecification
404
320
  attr_accessor :email
405
321
 
406
322
  ##
407
- # :category: Recommended gemspec attributes
408
- #
409
323
  # The URL of this gem's home page
410
324
  #
411
325
  # Usage:
@@ -415,35 +329,59 @@ class Gem::Specification < Gem::BasicSpecification
415
329
  attr_accessor :homepage
416
330
 
417
331
  ##
418
- # A message that gets displayed after the gem is installed.
332
+ # The license for this gem.
419
333
  #
420
- # Usage:
334
+ # The license must be no more than 64 characters.
421
335
  #
422
- # spec.post_install_message = "Thanks for installing!"
423
-
424
- attr_accessor :post_install_message
425
-
426
- ##
427
- # The version of Ruby required by this gem
428
-
429
- attr_reader :required_ruby_version
430
-
431
- ##
432
- # The RubyGems version required by this gem
336
+ # This should just be the name of your license. The full text of the license
337
+ # should be inside of the gem (at the top level) when you build it.
338
+ #
339
+ # The simplest way is to specify the standard SPDX ID
340
+ # https://spdx.org/licenses/ for the license.
341
+ # Ideally, you should pick one that is OSI (Open Source Initiative)
342
+ # https://opensource.org/licenses/ approved.
343
+ #
344
+ # The most commonly used OSI-approved licenses are MIT and Apache-2.0.
345
+ # GitHub also provides a license picker at http://choosealicense.com/.
346
+ #
347
+ # You can also use a custom license file along with your gemspec and specify
348
+ # a LicenseRef-<idstring>, where idstring is the name of the file containing
349
+ # the license text.
350
+ #
351
+ # You should specify a license for your gem so that people know how they are
352
+ # permitted to use it and any restrictions you're placing on it. Not
353
+ # specifying a license means all rights are reserved; others have no right
354
+ # to use the code for any purpose.
355
+ #
356
+ # You can set multiple licenses with #licenses=
357
+ #
358
+ # Usage:
359
+ # spec.license = 'MIT'
433
360
 
434
- attr_reader :required_rubygems_version
361
+ def license=(o)
362
+ self.licenses = [o]
363
+ end
435
364
 
436
365
  ##
437
- # The key used to sign this gem. See Gem::Security for details.
366
+ # The license(s) for the library.
367
+ #
368
+ # Each license must be a short name, no more than 64 characters.
369
+ #
370
+ # This should just be the name of your license. The full
371
+ # text of the license should be inside of the gem when you build it.
372
+ #
373
+ # See #license= for more discussion
374
+ #
375
+ # Usage:
376
+ # spec.licenses = ['MIT', 'GPL-2.0']
438
377
 
439
- attr_accessor :signing_key
378
+ def licenses=(licenses)
379
+ @licenses = Array licenses
380
+ end
440
381
 
441
382
  ##
442
- # :attr_accessor: metadata
443
- #
444
383
  # The metadata holds extra data for this gem that may be useful to other
445
- # consumers and is settable by gem authors without requiring an update to
446
- # the rubygems software.
384
+ # consumers and is settable by gem authors.
447
385
  #
448
386
  # Metadata items have the following restrictions:
449
387
  #
@@ -453,12 +391,153 @@ class Gem::Specification < Gem::BasicSpecification
453
391
  # bytes
454
392
  # * All strings must be UTF-8, no binary data is allowed
455
393
  #
456
- # To add metadata for the location of a issue tracker:
394
+ # You can use metadata to specify links to your gem's homepage, codebase,
395
+ # documentation, wiki, mailing list, issue tracker and changelog.
396
+ #
397
+ # s.metadata = {
398
+ # "bug_tracker_uri" => "https://example.com/user/bestgemever/issues",
399
+ # "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md",
400
+ # "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1",
401
+ # "homepage_uri" => "https://bestgemever.example.io",
402
+ # "mailing_list_uri" => "https://groups.example.com/bestgemever",
403
+ # "source_code_uri" => "https://example.com/user/bestgemever",
404
+ # "wiki_uri" => "https://example.com/user/bestgemever/wiki"
405
+ # "funding_uri" => "https://example.com/donate"
406
+ # }
457
407
  #
458
- # s.metadata = { "issue_tracker" => "https://example/issues" }
408
+ # These links will be used on your gem's page on rubygems.org and must pass
409
+ # validation against following regex.
410
+ #
411
+ # %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z}
459
412
 
460
413
  attr_accessor :metadata
461
414
 
415
+ ######################################################################
416
+ # :section: Optional gemspec attributes
417
+
418
+ ##
419
+ # Singular (alternative) writer for #authors
420
+ #
421
+ # Usage:
422
+ #
423
+ # spec.author = 'John Jones'
424
+
425
+ def author=(o)
426
+ self.authors = [o]
427
+ end
428
+
429
+ ##
430
+ # The path in the gem for executable scripts. Usually 'exe'
431
+ #
432
+ # Usage:
433
+ #
434
+ # spec.bindir = 'exe'
435
+
436
+ attr_accessor :bindir
437
+
438
+ ##
439
+ # The certificate chain used to sign this gem. See Gem::Security for
440
+ # details.
441
+
442
+ attr_accessor :cert_chain
443
+
444
+ ##
445
+ # A message that gets displayed after the gem is installed.
446
+ #
447
+ # Usage:
448
+ #
449
+ # spec.post_install_message = "Thanks for installing!"
450
+
451
+ attr_accessor :post_install_message
452
+
453
+ ##
454
+ # The platform this gem runs on.
455
+ #
456
+ # This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT.
457
+ #
458
+ # Most gems contain pure Ruby code; they should simply leave the default
459
+ # value in place. Some gems contain C (or other) code to be compiled into a
460
+ # Ruby "extension". The gem should leave the default value in place unless
461
+ # the code will only compile on a certain type of system. Some gems consist
462
+ # of pre-compiled code ("binary gems"). It's especially important that they
463
+ # set the platform attribute appropriately. A shortcut is to set the
464
+ # platform to Gem::Platform::CURRENT, which will cause the gem builder to set
465
+ # the platform to the appropriate value for the system on which the build is
466
+ # being performed.
467
+ #
468
+ # If this attribute is set to a non-default value, it will be included in
469
+ # the filename of the gem when it is built such as:
470
+ # nokogiri-1.6.0-x86-mingw32.gem
471
+ #
472
+ # Usage:
473
+ #
474
+ # spec.platform = Gem::Platform.local
475
+
476
+ def platform=(platform)
477
+ if @original_platform.nil? ||
478
+ @original_platform == Gem::Platform::RUBY
479
+ @original_platform = platform
480
+ end
481
+
482
+ case platform
483
+ when Gem::Platform::CURRENT then
484
+ @new_platform = Gem::Platform.local
485
+ @original_platform = @new_platform.to_s
486
+
487
+ when Gem::Platform then
488
+ @new_platform = platform
489
+
490
+ # legacy constants
491
+ when nil, Gem::Platform::RUBY then
492
+ @new_platform = Gem::Platform::RUBY
493
+ when "mswin32" then # was Gem::Platform::WIN32
494
+ @new_platform = Gem::Platform.new "x86-mswin32"
495
+ when "i586-linux" then # was Gem::Platform::LINUX_586
496
+ @new_platform = Gem::Platform.new "x86-linux"
497
+ when "powerpc-darwin" then # was Gem::Platform::DARWIN
498
+ @new_platform = Gem::Platform.new "ppc-darwin"
499
+ else
500
+ @new_platform = Gem::Platform.new platform
501
+ end
502
+
503
+ @platform = @new_platform.to_s
504
+
505
+ invalidate_memoized_attributes
506
+
507
+ @new_platform
508
+ end
509
+
510
+ ##
511
+ # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
512
+ # activated.
513
+ #--
514
+ # See also #require_paths
515
+ #++
516
+ # If you have an extension you do not need to add <code>"ext"</code> to the
517
+ # require path, the extension build process will copy the extension files
518
+ # into "lib" for you.
519
+ #
520
+ # The default value is <code>"lib"</code>
521
+ #
522
+ # Usage:
523
+ #
524
+ # # If all library files are in the root directory...
525
+ # spec.require_paths = ['.']
526
+
527
+ def require_paths=(val)
528
+ @require_paths = Array(val)
529
+ end
530
+
531
+ ##
532
+ # The RubyGems version required by this gem
533
+
534
+ attr_reader :required_rubygems_version
535
+
536
+ ##
537
+ # The key used to sign this gem. See Gem::Security for details.
538
+
539
+ attr_accessor :signing_key
540
+
462
541
  ##
463
542
  # Adds a development dependency named +gem+ with +requirements+ to this
464
543
  # gem.
@@ -471,7 +550,7 @@ class Gem::Specification < Gem::BasicSpecification
471
550
  # activated when a gem is required.
472
551
 
473
552
  def add_development_dependency(gem, *requirements)
474
- add_dependency_with_type(gem, :development, *requirements)
553
+ add_dependency_with_type(gem, :development, requirements)
475
554
  end
476
555
 
477
556
  ##
@@ -482,7 +561,11 @@ class Gem::Specification < Gem::BasicSpecification
482
561
  # spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4'
483
562
 
484
563
  def add_runtime_dependency(gem, *requirements)
485
- add_dependency_with_type(gem, :runtime, *requirements)
564
+ if requirements.uniq.size != requirements.size
565
+ warn "WARNING: duplicated #{gem} dependency #{requirements}"
566
+ end
567
+
568
+ add_dependency_with_type(gem, :runtime, requirements)
486
569
  end
487
570
 
488
571
  ##
@@ -550,60 +633,10 @@ class Gem::Specification < Gem::BasicSpecification
550
633
  # Sets the version of RubyGems that installed this gem. See also
551
634
  # #installed_by_version.
552
635
 
553
- def installed_by_version= version # :nodoc:
636
+ def installed_by_version=(version) # :nodoc:
554
637
  @installed_by_version = Gem::Version.new version
555
638
  end
556
639
 
557
- ##
558
- # :category: Recommended gemspec attributes
559
- #
560
- # The license for this gem.
561
- #
562
- # The license must be no more than 64 characters.
563
- #
564
- # This should just be the name of your license. The full text of the license
565
- # should be inside of the gem (at the top level) when you build it.
566
- #
567
- # The simplest way, is to specify the standard SPDX ID
568
- # https://spdx.org/licenses/ for the license.
569
- # Ideally you should pick one that is OSI (Open Source Initiative)
570
- # http://opensource.org/licenses/alphabetical approved.
571
- #
572
- # The most commonly used OSI approved licenses are MIT and Apache-2.0.
573
- # GitHub also provides a license picker at http://choosealicense.com/.
574
- #
575
- # You should specify a license for your gem so that people know how they are
576
- # permitted to use it, and any restrictions you're placing on it. Not
577
- # specifying a license means all rights are reserved; others have no rights
578
- # to use the code for any purpose.
579
- #
580
- # You can set multiple licenses with #licenses=
581
- #
582
- # Usage:
583
- # spec.license = 'MIT'
584
-
585
- def license=o
586
- self.licenses = [o]
587
- end
588
-
589
- ##
590
- # :category: Recommended gemspec attributes
591
- # The license(s) for the library.
592
- #
593
- # Each license must be a short name, no more than 64 characters.
594
- #
595
- # This should just be the name of your license. The full
596
- # text of the license should be inside of the gem when you build it.
597
- #
598
- # See #license= for more discussion
599
- #
600
- # Usage:
601
- # spec.licenses = ['MIT', 'GPL-2.0']
602
-
603
- def licenses= licenses
604
- @licenses = Array licenses
605
- end
606
-
607
640
  ##
608
641
  # Specifies the rdoc options to be used when generating API documentation.
609
642
  #
@@ -617,6 +650,8 @@ class Gem::Specification < Gem::BasicSpecification
617
650
  @rdoc_options ||= []
618
651
  end
619
652
 
653
+ LATEST_RUBY_WITHOUT_PATCH_VERSIONS = Gem::Version.new("2.1")
654
+
620
655
  ##
621
656
  # The version of Ruby required by this gem. The ruby version can be
622
657
  # specified to the patch-level:
@@ -625,29 +660,38 @@ class Gem::Specification < Gem::BasicSpecification
625
660
  # ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
626
661
  # #<Gem::Version "2.0.0.247">
627
662
  #
628
- # Because patch-level is taken into account, be very careful specifying using
629
- # `<=`: `<= 2.2.2` will not match any patch-level of 2.2.2 after the `p0`
630
- # release. It is much safer to specify `< 2.2.3` instead
663
+ # Prereleases can also be specified.
631
664
  #
632
665
  # Usage:
633
666
  #
634
667
  # # This gem will work with 1.8.6 or greater...
635
668
  # spec.required_ruby_version = '>= 1.8.6'
636
669
  #
637
- # # Only with ruby 2.0.x
638
- # spec.required_ruby_version = '~> 2.0'
670
+ # # Only with final releases of major version 2 where minor version is at least 3
671
+ # spec.required_ruby_version = '~> 2.3'
639
672
  #
640
- # # Only with ruby between 2.2.0 and 2.2.2
641
- # spec.required_ruby_version = ['>= 2.2.0', '< 2.2.3']
673
+ # # Only prereleases or final releases after 2.6.0.preview2
674
+ # spec.required_ruby_version = '> 2.6.0.preview2'
675
+ #
676
+ # # This gem will work with 2.3.0 or greater, including major version 3, but lesser than 4.0.0
677
+ # spec.required_ruby_version = '>= 2.3', '< 4'
642
678
 
643
- def required_ruby_version= req
679
+ def required_ruby_version=(req)
644
680
  @required_ruby_version = Gem::Requirement.create req
681
+
682
+ @required_ruby_version.requirements.map! do |op, v|
683
+ if v >= LATEST_RUBY_WITHOUT_PATCH_VERSIONS && v.release.segments.size == 4
684
+ [op == "~>" ? "=" : op, Gem::Version.new(v.segments.tap {|s| s.delete_at(3) }.join("."))]
685
+ else
686
+ [op, v]
687
+ end
688
+ end
645
689
  end
646
690
 
647
691
  ##
648
692
  # The RubyGems version required by this gem
649
693
 
650
- def required_rubygems_version= req
694
+ def required_rubygems_version=(req)
651
695
  @required_rubygems_version = Gem::Requirement.create req
652
696
  end
653
697
 
@@ -672,10 +716,25 @@ class Gem::Specification < Gem::BasicSpecification
672
716
  # spec.test_files = Dir.glob('test/tc_*.rb')
673
717
  # spec.test_files = ['tests/test-suite.rb']
674
718
 
675
- def test_files= files # :nodoc:
719
+ def test_files=(files) # :nodoc:
676
720
  @test_files = Array files
677
721
  end
678
722
 
723
+ ######################################################################
724
+ # :section: Read-only attributes
725
+
726
+ ##
727
+ # The version of RubyGems used to create this gem.
728
+
729
+ attr_accessor :rubygems_version
730
+
731
+ ##
732
+ # The path where this gem installs its extensions.
733
+
734
+ def extensions_dir
735
+ @extensions_dir ||= super
736
+ end
737
+
679
738
  ######################################################################
680
739
  # :section: Specification internals
681
740
 
@@ -699,20 +758,13 @@ class Gem::Specification < Gem::BasicSpecification
699
758
  # Deprecated: You must now specify the executable name to Gem.bin_path.
700
759
 
701
760
  attr_writer :default_executable
761
+ rubygems_deprecate :default_executable=
702
762
 
703
763
  ##
704
764
  # Allows deinstallation of gems with legacy platforms.
705
765
 
706
766
  attr_writer :original_platform # :nodoc:
707
767
 
708
- ##
709
- # The rubyforge project this gem lives under. i.e. RubyGems'
710
- # rubyforge_project is "rubygems".
711
- #
712
- # This option is deprecated.
713
-
714
- attr_accessor :rubyforge_project
715
-
716
768
  ##
717
769
  # The Gem::Specification version of this gemspec.
718
770
  #
@@ -721,100 +773,45 @@ class Gem::Specification < Gem::BasicSpecification
721
773
  attr_accessor :specification_version
722
774
 
723
775
  def self._all # :nodoc:
724
- unless defined?(@@all) && @@all then
725
- @@all = stubs.map(&:to_spec)
726
-
727
- # After a reset, make sure already loaded specs
728
- # are still marked as activated.
729
- specs = {}
730
- Gem.loaded_specs.each_value{|s| specs[s] = true}
731
- @@all.each{|s| s.activated = true if specs[s]}
732
- end
733
- @@all
776
+ @@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec)
734
777
  end
735
778
 
736
- def self._clear_load_cache # :nodoc:
737
- LOAD_CACHE.clear
779
+ def self.clear_load_cache # :nodoc:
780
+ @load_cache_mutex.synchronize do
781
+ @load_cache.clear
782
+ end
738
783
  end
784
+ private_class_method :clear_load_cache
739
785
 
740
786
  def self.each_gemspec(dirs) # :nodoc:
741
787
  dirs.each do |dir|
742
- Dir[File.join(dir, "*.gemspec")].each do |path|
743
- yield path.untaint
788
+ Gem::Util.glob_files_in_dir("*.gemspec", dir).each do |path|
789
+ yield path.tap(&Gem::UNTAINT)
744
790
  end
745
791
  end
746
792
  end
747
793
 
748
- def self.gemspec_stubs_in dir, pattern
749
- Dir[File.join(dir, pattern)].map { |path| yield path }.select(&:valid?)
794
+ def self.gemspec_stubs_in(dir, pattern)
795
+ Gem::Util.glob_files_in_dir(pattern, dir).map {|path| yield path }.select(&:valid?)
750
796
  end
751
797
  private_class_method :gemspec_stubs_in
752
798
 
753
- def self.default_stubs pattern
754
- base_dir = Gem.default_dir
755
- gems_dir = File.join base_dir, "gems"
756
- gemspec_stubs_in(default_specifications_dir, pattern) do |path|
757
- Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir)
758
- end
759
- end
760
- private_class_method :default_stubs
761
-
762
- def self.installed_stubs dirs, pattern
799
+ def self.installed_stubs(dirs, pattern)
763
800
  map_stubs(dirs, pattern) do |path, base_dir, gems_dir|
764
801
  Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir)
765
802
  end
766
803
  end
767
804
  private_class_method :installed_stubs
768
805
 
769
- if [].respond_to? :flat_map
770
- def self.map_stubs(dirs, pattern) # :nodoc:
771
- dirs.flat_map { |dir|
772
- base_dir = File.dirname dir
773
- gems_dir = File.join base_dir, "gems"
774
- gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
775
- }
776
- end
777
- else # FIXME: remove when 1.8 is dropped
778
- def self.map_stubs(dirs, pattern) # :nodoc:
779
- dirs.map { |dir|
780
- base_dir = File.dirname dir
781
- gems_dir = File.join base_dir, "gems"
782
- gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
783
- }.flatten 1
806
+ def self.map_stubs(dirs, pattern) # :nodoc:
807
+ dirs.flat_map do |dir|
808
+ base_dir = File.dirname dir
809
+ gems_dir = File.join base_dir, "gems"
810
+ gemspec_stubs_in(dir, pattern) {|path| yield path, base_dir, gems_dir }
784
811
  end
785
812
  end
786
813
  private_class_method :map_stubs
787
814
 
788
- uniq_takes_a_block = false
789
- [1,2].uniq { uniq_takes_a_block = true }
790
-
791
- if uniq_takes_a_block
792
- def self.uniq_by(list, &block) # :nodoc:
793
- list.uniq(&block)
794
- end
795
- else # FIXME: remove when 1.8 is dropped
796
- def self.uniq_by(list) # :nodoc:
797
- values = {}
798
- list.each { |item|
799
- value = yield item
800
- values[value] ||= item
801
- }
802
- values.values
803
- end
804
- end
805
- private_class_method :uniq_by
806
-
807
- if [].respond_to? :sort_by!
808
- def self.sort_by! list, &block
809
- list.sort_by!(&block)
810
- end
811
- else # FIXME: remove when 1.8 is dropped
812
- def self.sort_by! list, &block
813
- list.replace list.sort_by(&block)
814
- end
815
- end
816
- private_class_method :sort_by!
817
-
818
815
  def self.each_spec(dirs) # :nodoc:
819
816
  each_gemspec(dirs) do |path|
820
817
  spec = self.load path
@@ -828,47 +825,66 @@ class Gem::Specification < Gem::BasicSpecification
828
825
  def self.stubs
829
826
  @@stubs ||= begin
830
827
  pattern = "*.gemspec"
831
- stubs = default_stubs(pattern).concat installed_stubs(dirs, pattern)
832
- stubs = uniq_by(stubs) { |stub| stub.full_name }
828
+ stubs = stubs_for_pattern(pattern, false)
829
+
830
+ @@stubs_by_name = stubs.select {|s| Gem::Platform.match_spec? s }.group_by(&:name)
831
+ stubs
832
+ end
833
+ end
834
+
835
+ ##
836
+ # Returns a Gem::StubSpecification for default gems
833
837
 
834
- _resort!(stubs)
835
- @@stubs_by_name = stubs.group_by(&:name)
836
- stubs
838
+ def self.default_stubs(pattern = "*.gemspec")
839
+ base_dir = Gem.default_dir
840
+ gems_dir = File.join base_dir, "gems"
841
+ gemspec_stubs_in(Gem.default_specifications_dir, pattern) do |path|
842
+ Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir)
837
843
  end
838
844
  end
839
845
 
840
- EMPTY = [].freeze # :nodoc:
841
-
842
846
  ##
843
847
  # Returns a Gem::StubSpecification for installed gem named +name+
848
+ # only returns stubs that match Gem.platforms
844
849
 
845
- def self.stubs_for name
850
+ def self.stubs_for(name)
846
851
  if @@stubs
847
852
  @@stubs_by_name[name] || []
848
853
  else
849
- pattern = "#{name}-*.gemspec"
850
- stubs = default_stubs(pattern) + installed_stubs(dirs, pattern)
851
- stubs = uniq_by(stubs) { |stub| stub.full_name }.group_by(&:name)
852
- stubs.each_value { |v| sort_by!(v) { |i| i.version } }
853
-
854
- @@stubs_by_name.merge! stubs
855
- @@stubs_by_name[name] ||= EMPTY
854
+ @@stubs_by_name[name] ||= stubs_for_pattern("#{name}-*.gemspec").select do |s|
855
+ s.name == name
856
+ end
856
857
  end
857
858
  end
858
859
 
860
+ ##
861
+ # Finds stub specifications matching a pattern from the standard locations,
862
+ # optionally filtering out specs not matching the current platform
863
+ #
864
+ def self.stubs_for_pattern(pattern, match_platform = true) # :nodoc:
865
+ installed_stubs = installed_stubs(Gem::Specification.dirs, pattern)
866
+ installed_stubs.select! {|s| Gem::Platform.match_spec? s } if match_platform
867
+ stubs = installed_stubs + default_stubs(pattern)
868
+ stubs = stubs.uniq {|stub| stub.full_name }
869
+ _resort!(stubs)
870
+ stubs
871
+ end
872
+
859
873
  def self._resort!(specs) # :nodoc:
860
- specs.sort! { |a, b|
874
+ specs.sort! do |a, b|
861
875
  names = a.name <=> b.name
862
876
  next names if names.nonzero?
863
- b.version <=> a.version
864
- }
877
+ versions = b.version <=> a.version
878
+ next versions if versions.nonzero?
879
+ Gem::Platform.sort_priority(b.platform)
880
+ end
865
881
  end
866
882
 
867
883
  ##
868
884
  # Loads the default specifications. It should be called only once.
869
885
 
870
886
  def self.load_defaults
871
- each_spec([default_specifications_dir]) do |spec|
887
+ each_spec([Gem.default_specifications_dir]) do |spec|
872
888
  # #load returns nil if the spec is bad, so we just ignore
873
889
  # it at this stage
874
890
  Gem.register_default_spec(spec)
@@ -879,45 +895,24 @@ class Gem::Specification < Gem::BasicSpecification
879
895
  # Adds +spec+ to the known specifications, keeping the collection
880
896
  # properly sorted.
881
897
 
882
- def self.add_spec spec
883
- warn "Gem::Specification.add_spec is deprecated and will be removed in Rubygems 3.0" unless Gem::Deprecate.skip
884
- # TODO: find all extraneous adds
885
- # puts
886
- # p :add_spec => [spec.full_name, caller.reject { |s| s =~ /minitest/ }]
887
-
888
- # TODO: flush the rest of the crap from the tests
889
- # raise "no dupes #{spec.full_name} in #{all_names.inspect}" if
890
- # _all.include? spec
891
-
892
- raise "nil spec!" unless spec # TODO: remove once we're happy with tests
893
-
898
+ def self.add_spec(spec)
894
899
  return if _all.include? spec
895
900
 
896
901
  _all << spec
897
902
  stubs << spec
898
903
  (@@stubs_by_name[spec.name] ||= []) << spec
899
- sort_by!(@@stubs_by_name[spec.name]) { |s| s.version }
900
- _resort!(_all)
904
+
905
+ _resort!(@@stubs_by_name[spec.name])
901
906
  _resort!(stubs)
902
907
  end
903
908
 
904
909
  ##
905
- # Adds multiple specs to the known specifications.
906
-
907
- def self.add_specs *specs
908
- warn "Gem::Specification.add_specs is deprecated and will be removed in Rubygems 3.0" unless Gem::Deprecate.skip
909
-
910
- raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
911
-
912
- # TODO: this is much more efficient, but we need the extra checks for now
913
- # _all.concat specs
914
- # _resort!
910
+ # Removes +spec+ from the known specs.
915
911
 
916
- Gem::Deprecate.skip_during do
917
- specs.each do |spec| # TODO: slow
918
- add_spec spec
919
- end
920
- end
912
+ def self.remove_spec(spec)
913
+ _all.delete spec.to_spec
914
+ stubs.delete spec
915
+ (@@stubs_by_name[spec.name] || []).delete spec
921
916
  end
922
917
 
923
918
  ##
@@ -942,7 +937,7 @@ class Gem::Specification < Gem::BasicSpecification
942
937
  #
943
938
  # -- wilsonb
944
939
 
945
- def self.all= specs
940
+ def self.all=(specs)
946
941
  @@stubs_by_name = specs.group_by(&:name)
947
942
  @@all = @@stubs = specs
948
943
  end
@@ -976,19 +971,19 @@ class Gem::Specification < Gem::BasicSpecification
976
971
  # Return the directories that Specification uses to find specs.
977
972
 
978
973
  def self.dirs
979
- @@dirs ||= Gem.path.collect { |dir|
980
- File.join dir.dup.untaint, "specifications"
981
- }
974
+ @@dirs ||= Gem.path.collect do |dir|
975
+ File.join dir.dup.tap(&Gem::UNTAINT), "specifications"
976
+ end
982
977
  end
983
978
 
984
979
  ##
985
980
  # Set the directories that Specification uses to find specs. Setting
986
981
  # this resets the list of known specs.
987
982
 
988
- def self.dirs= dirs
983
+ def self.dirs=(dirs)
989
984
  self.reset
990
985
 
991
- @@dirs = Array(dirs).map { |dir| File.join dir, "specifications" }
986
+ @@dirs = Array(dirs).map {|dir| File.join dir, "specifications" }
992
987
  end
993
988
 
994
989
  extend Enumerable
@@ -1008,7 +1003,7 @@ class Gem::Specification < Gem::BasicSpecification
1008
1003
  ##
1009
1004
  # Returns every spec that matches +name+ and optional +requirements+.
1010
1005
 
1011
- def self.find_all_by_name name, *requirements
1006
+ def self.find_all_by_name(name, *requirements)
1012
1007
  requirements = Gem::Requirement.default if requirements.empty?
1013
1008
 
1014
1009
  # TODO: maybe try: find_all { |s| spec === dep }
@@ -1016,11 +1011,18 @@ class Gem::Specification < Gem::BasicSpecification
1016
1011
  Gem::Dependency.new(name, *requirements).matching_specs
1017
1012
  end
1018
1013
 
1014
+ ##
1015
+ # Returns every spec that has the given +full_name+
1016
+
1017
+ def self.find_all_by_full_name(full_name)
1018
+ stubs.select {|s| s.full_name == full_name }.map(&:to_spec)
1019
+ end
1020
+
1019
1021
  ##
1020
1022
  # Find the best specification matching a +name+ and +requirements+. Raises
1021
1023
  # if the dependency doesn't resolve to a valid specification.
1022
1024
 
1023
- def self.find_by_name name, *requirements
1025
+ def self.find_by_name(name, *requirements)
1024
1026
  requirements = Gem::Requirement.default if requirements.empty?
1025
1027
 
1026
1028
  # TODO: maybe try: find { |s| spec === dep }
@@ -1028,14 +1030,20 @@ class Gem::Specification < Gem::BasicSpecification
1028
1030
  Gem::Dependency.new(name, *requirements).to_spec
1029
1031
  end
1030
1032
 
1033
+ ##
1034
+ # Find the best specification matching a +full_name+.
1035
+ def self.find_by_full_name(full_name)
1036
+ stubs.find {|s| s.full_name == full_name }&.to_spec
1037
+ end
1038
+
1031
1039
  ##
1032
1040
  # Return the best specification that contains the file matching +path+.
1033
1041
 
1034
- def self.find_by_path path
1042
+ def self.find_by_path(path)
1035
1043
  path = path.dup.freeze
1036
- spec = @@spec_with_requirable_file[path] ||= (stubs.find { |s|
1044
+ spec = @@spec_with_requirable_file[path] ||= (stubs.find do |s|
1037
1045
  s.contains_requirable_file? path
1038
- } || NOT_FOUND)
1046
+ end || NOT_FOUND)
1039
1047
  spec.to_spec
1040
1048
  end
1041
1049
 
@@ -1043,38 +1051,34 @@ class Gem::Specification < Gem::BasicSpecification
1043
1051
  # Return the best specification that contains the file matching +path+
1044
1052
  # amongst the specs that are not activated.
1045
1053
 
1046
- def self.find_inactive_by_path path
1047
- stub = stubs.find { |s|
1048
- s.contains_requirable_file? path unless s.activated?
1049
- }
1050
- stub && stub.to_spec
1054
+ def self.find_inactive_by_path(path)
1055
+ stub = stubs.find do |s|
1056
+ next if s.activated?
1057
+ s.contains_requirable_file? path
1058
+ end
1059
+ stub&.to_spec
1051
1060
  end
1052
1061
 
1053
- def self.find_active_stub_by_path path
1054
- stub = @@active_stub_with_requirable_file[path] ||= (stubs.find { |s|
1055
- s.activated? and s.contains_requirable_file? path
1056
- } || NOT_FOUND)
1062
+ def self.find_active_stub_by_path(path)
1063
+ stub = @@active_stub_with_requirable_file[path] ||= (stubs.find do |s|
1064
+ s.activated? && s.contains_requirable_file?(path)
1065
+ end || NOT_FOUND)
1057
1066
  stub.this
1058
1067
  end
1059
1068
 
1060
1069
  ##
1061
1070
  # Return currently unresolved specs that contain the file matching +path+.
1062
1071
 
1063
- def self.find_in_unresolved path
1064
- # TODO: do we need these?? Kill it
1065
- specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
1066
-
1067
- specs.find_all { |spec| spec.contains_requirable_file? path }
1072
+ def self.find_in_unresolved(path)
1073
+ unresolved_specs.find_all {|spec| spec.contains_requirable_file? path }
1068
1074
  end
1069
1075
 
1070
1076
  ##
1071
1077
  # Search through all unresolved deps and sub-dependencies and return
1072
1078
  # specs that contain the file matching +path+.
1073
1079
 
1074
- def self.find_in_unresolved_tree path
1075
- specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
1076
-
1077
- specs.reverse_each do |spec|
1080
+ def self.find_in_unresolved_tree(path)
1081
+ unresolved_specs.each do |spec|
1078
1082
  spec.traverse do |from_spec, dep, to_spec, trail|
1079
1083
  if to_spec.has_conflicts? || to_spec.conficts_when_loaded_with?(trail)
1080
1084
  :next
@@ -1087,6 +1091,11 @@ class Gem::Specification < Gem::BasicSpecification
1087
1091
  []
1088
1092
  end
1089
1093
 
1094
+ def self.unresolved_specs
1095
+ unresolved_deps.values.map {|dep| dep.to_specs }.flatten
1096
+ end
1097
+ private_class_method :unresolved_specs
1098
+
1090
1099
  ##
1091
1100
  # Special loader for YAML files. When a Specification object is loaded
1092
1101
  # from a YAML file, it bypasses the normal Ruby object initialization
@@ -1099,18 +1108,19 @@ class Gem::Specification < Gem::BasicSpecification
1099
1108
  Gem.load_yaml
1100
1109
 
1101
1110
  input = normalize_yaml_input input
1102
- spec = YAML.load input
1111
+ spec = Gem::SafeYAML.safe_load input
1103
1112
 
1104
- if spec && spec.class == FalseClass then
1113
+ if spec && spec.class == FalseClass
1105
1114
  raise Gem::EndOfYAMLException
1106
1115
  end
1107
1116
 
1108
- unless Gem::Specification === spec then
1117
+ unless Gem::Specification === spec
1109
1118
  raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
1110
1119
  end
1111
1120
 
1112
1121
  spec.specification_version ||= NONEXISTENT_SPECIFICATION_VERSION
1113
1122
  spec.reset_nil_attributes_to_default
1123
+ spec.flatten_require_paths
1114
1124
 
1115
1125
  spec
1116
1126
  end
@@ -1119,53 +1129,58 @@ class Gem::Specification < Gem::BasicSpecification
1119
1129
  # Return the latest specs, optionally including prerelease specs if
1120
1130
  # +prerelease+ is true.
1121
1131
 
1122
- def self.latest_specs prerelease = false
1123
- _latest_specs Gem::Specification._all, prerelease
1132
+ def self.latest_specs(prerelease = false)
1133
+ _latest_specs Gem::Specification.stubs, prerelease
1134
+ end
1135
+
1136
+ ##
1137
+ # Return the latest installed spec for gem +name+.
1138
+
1139
+ def self.latest_spec_for(name)
1140
+ latest_specs(true).find {|installed_spec| installed_spec.name == name }
1124
1141
  end
1125
1142
 
1126
- def self._latest_specs specs, prerelease = false # :nodoc:
1127
- result = Hash.new { |h,k| h[k] = {} }
1128
- native = {}
1143
+ def self._latest_specs(specs, prerelease = false) # :nodoc:
1144
+ result = {}
1129
1145
 
1130
1146
  specs.reverse_each do |spec|
1131
1147
  next if spec.version.prerelease? unless prerelease
1132
1148
 
1133
- native[spec.name] = spec.version if spec.platform == Gem::Platform::RUBY
1134
- result[spec.name][spec.platform] = spec
1149
+ result[spec.name] = spec
1135
1150
  end
1136
1151
 
1137
- result.map(&:last).map(&:values).flatten.reject { |spec|
1138
- minimum = native[spec.name]
1139
- minimum && spec.version < minimum
1140
- }.sort_by{ |tup| tup.name }
1152
+ result.map(&:last).flatten.sort_by {|tup| tup.name }
1141
1153
  end
1142
1154
 
1143
1155
  ##
1144
1156
  # Loads Ruby format gemspec from +file+.
1145
1157
 
1146
- def self.load file
1158
+ def self.load(file)
1147
1159
  return unless file
1148
1160
 
1149
- _spec = LOAD_CACHE[file]
1161
+ _spec = @load_cache_mutex.synchronize { @load_cache[file] }
1150
1162
  return _spec if _spec
1151
1163
 
1152
- file = file.dup.untaint
1164
+ file = file.dup.tap(&Gem::UNTAINT)
1153
1165
  return unless File.file?(file)
1154
1166
 
1155
- code = if defined? Encoding
1156
- File.read file, :mode => 'r:UTF-8:-'
1157
- else
1158
- File.read file
1159
- end
1167
+ code = Gem.open_file(file, "r:UTF-8:-", &:read)
1160
1168
 
1161
- code.untaint
1169
+ code.tap(&Gem::UNTAINT)
1162
1170
 
1163
1171
  begin
1164
1172
  _spec = eval code, binding, file
1165
1173
 
1166
1174
  if Gem::Specification === _spec
1167
1175
  _spec.loaded_from = File.expand_path file.to_s
1168
- LOAD_CACHE[file] = _spec
1176
+ @load_cache_mutex.synchronize do
1177
+ prev = @load_cache[file]
1178
+ if prev
1179
+ _spec = prev
1180
+ else
1181
+ @load_cache[file] = _spec
1182
+ end
1183
+ end
1169
1184
  return _spec
1170
1185
  end
1171
1186
 
@@ -1191,7 +1206,7 @@ class Gem::Specification < Gem::BasicSpecification
1191
1206
 
1192
1207
  def self.normalize_yaml_input(input)
1193
1208
  result = input.respond_to?(:read) ? input.read : input
1194
- result = "--- " + result unless result =~ /\A--- /
1209
+ result = "--- " + result unless result.start_with?("--- ")
1195
1210
  result = result.dup
1196
1211
  result.gsub!(/ !!null \n/, " \n")
1197
1212
  # date: 2011-04-26 00:00:00.000000000Z
@@ -1208,7 +1223,7 @@ class Gem::Specification < Gem::BasicSpecification
1208
1223
  # version as well.
1209
1224
 
1210
1225
  def self.outdated
1211
- outdated_and_latest_version.map { |local, _| local.name }
1226
+ outdated_and_latest_version.map {|local, _| local.name }
1212
1227
  end
1213
1228
 
1214
1229
  ##
@@ -1229,28 +1244,17 @@ class Gem::Specification < Gem::BasicSpecification
1229
1244
  Gem::Dependency.new local_spec.name, ">= #{local_spec.version}"
1230
1245
 
1231
1246
  remotes, = fetcher.search_for_dependency dependency
1232
- remotes = remotes.map { |n, _| n.version }
1247
+ remotes = remotes.map {|n, _| n.version }
1233
1248
 
1234
1249
  latest_remote = remotes.sort.last
1235
1250
 
1236
1251
  yield [local_spec, latest_remote] if
1237
- latest_remote and local_spec.version < latest_remote
1252
+ latest_remote && local_spec.version < latest_remote
1238
1253
  end
1239
1254
 
1240
1255
  nil
1241
1256
  end
1242
1257
 
1243
- ##
1244
- # Removes +spec+ from the known specs.
1245
-
1246
- def self.remove_spec spec
1247
- warn "Gem::Specification.remove_spec is deprecated and will be removed in Rubygems 3.0" unless Gem::Deprecate.skip
1248
- _all.delete spec
1249
- stubs.delete_if { |s| s.full_name == spec.full_name }
1250
- (@@stubs_by_name[spec.name] || []).delete_if { |s| s.full_name == spec.full_name }
1251
- reset
1252
- end
1253
-
1254
1258
  ##
1255
1259
  # Is +name+ a required attribute?
1256
1260
 
@@ -1271,60 +1275,99 @@ class Gem::Specification < Gem::BasicSpecification
1271
1275
 
1272
1276
  def self.reset
1273
1277
  @@dirs = nil
1274
- Gem.pre_reset_hooks.each { |hook| hook.call }
1275
- @@all = nil
1276
- @@stubs = nil
1277
- @@stubs_by_name = {}
1278
- @@spec_with_requirable_file = {}
1279
- @@active_stub_with_requirable_file = {}
1280
- _clear_load_cache
1278
+ Gem.pre_reset_hooks.each {|hook| hook.call }
1279
+ clear_specs
1280
+ clear_load_cache
1281
1281
  unresolved = unresolved_deps
1282
- unless unresolved.empty? then
1283
- w = "W" + "ARN"
1284
- warn "#{w}: Unresolved specs during Gem::Specification.reset:"
1282
+ unless unresolved.empty?
1283
+ warn "WARN: Unresolved or ambiguous specs during Gem::Specification.reset:"
1285
1284
  unresolved.values.each do |dep|
1286
1285
  warn " #{dep}"
1286
+
1287
+ versions = find_all_by_name(dep.name)
1288
+ unless versions.empty?
1289
+ warn " Available/installed versions of this gem:"
1290
+ versions.each {|s| warn " - #{s.version}" }
1291
+ end
1287
1292
  end
1288
- warn "#{w}: Clearing out unresolved specs."
1293
+ warn "WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
1289
1294
  warn "Please report a bug if this causes problems."
1290
1295
  unresolved.clear
1291
1296
  end
1292
- Gem.post_reset_hooks.each { |hook| hook.call }
1297
+ Gem.post_reset_hooks.each {|hook| hook.call }
1293
1298
  end
1294
1299
 
1295
1300
  # DOC: This method needs documented or nodoc'd
1296
1301
  def self.unresolved_deps
1297
- @unresolved_deps ||= Hash.new { |h, n| h[n] = Gem::Dependency.new n }
1302
+ @unresolved_deps ||= Hash.new {|h, n| h[n] = Gem::Dependency.new n }
1298
1303
  end
1299
1304
 
1300
1305
  ##
1301
1306
  # Load custom marshal format, re-initializing defaults as needed
1302
1307
 
1303
1308
  def self._load(str)
1304
- array = Marshal.load str
1309
+ Gem.load_yaml
1310
+
1311
+ yaml_set = false
1312
+ retry_count = 0
1313
+
1314
+ array = begin
1315
+ Marshal.load str
1316
+ rescue ArgumentError => e
1317
+ # Avoid an infinite retry loop when the argument error has nothing to do
1318
+ # with the classes not being defined.
1319
+ # 1 retry each allowed in case all 3 of
1320
+ # - YAML
1321
+ # - YAML::Syck::DefaultKey
1322
+ # - YAML::PrivateType
1323
+ # need to be defined
1324
+ raise if retry_count >= 3
1325
+
1326
+ #
1327
+ # Some very old marshaled specs included references to `YAML::PrivateType`
1328
+ # and `YAML::Syck::DefaultKey` constants due to bugs in the old emitter
1329
+ # that generated them. Workaround the issue by defining the necessary
1330
+ # constants and retrying.
1331
+ #
1332
+ message = e.message
1333
+ raise unless message.include?("YAML::")
1334
+
1335
+ unless Object.const_defined?(:YAML)
1336
+ Object.const_set "YAML", Psych
1337
+ yaml_set = true
1338
+ end
1339
+
1340
+ if message.include?("YAML::Syck::")
1341
+ YAML.const_set "Syck", YAML unless YAML.const_defined?(:Syck)
1342
+
1343
+ YAML::Syck.const_set "DefaultKey", Class.new if message.include?("YAML::Syck::DefaultKey") && !YAML::Syck.const_defined?(:DefaultKey)
1344
+ elsif message.include?("YAML::PrivateType") && !YAML.const_defined?(:PrivateType)
1345
+ YAML.const_set "PrivateType", Class.new
1346
+ end
1347
+
1348
+ retry_count += 1
1349
+ retry
1350
+ ensure
1351
+ Object.__send__(:remove_const, "YAML") if yaml_set
1352
+ end
1305
1353
 
1306
1354
  spec = Gem::Specification.new
1307
1355
  spec.instance_variable_set :@specification_version, array[1]
1308
1356
 
1309
1357
  current_version = CURRENT_SPECIFICATION_VERSION
1310
1358
 
1311
- field_count = if spec.specification_version > current_version then
1312
- spec.instance_variable_set :@specification_version,
1313
- current_version
1314
- MARSHAL_FIELDS[current_version]
1315
- else
1316
- MARSHAL_FIELDS[spec.specification_version]
1317
- end
1359
+ field_count = if spec.specification_version > current_version
1360
+ spec.instance_variable_set :@specification_version,
1361
+ current_version
1362
+ MARSHAL_FIELDS[current_version]
1363
+ else
1364
+ MARSHAL_FIELDS[spec.specification_version]
1365
+ end
1318
1366
 
1319
- if array.size < field_count then
1367
+ if array.size < field_count
1320
1368
  raise TypeError, "invalid Gem::Specification format #{array.inspect}"
1321
1369
  end
1322
1370
 
1323
- # Cleanup any YAML::PrivateType. They only show up for an old bug
1324
- # where nil => null, so just convert them to nil based on the type.
1325
-
1326
- array.map! { |e| e.kind_of?(YAML::PrivateType) ? nil : e }
1327
-
1328
1371
  spec.instance_variable_set :@rubygems_version, array[0]
1329
1372
  # spec version
1330
1373
  spec.instance_variable_set :@name, array[2]
@@ -1335,7 +1378,7 @@ class Gem::Specification < Gem::BasicSpecification
1335
1378
  spec.instance_variable_set :@required_rubygems_version, array[7]
1336
1379
  spec.instance_variable_set :@original_platform, array[8]
1337
1380
  spec.instance_variable_set :@dependencies, array[9]
1338
- spec.instance_variable_set :@rubyforge_project, array[10]
1381
+ # offset due to rubyforge_project removal
1339
1382
  spec.instance_variable_set :@email, array[11]
1340
1383
  spec.instance_variable_set :@authors, array[12]
1341
1384
  spec.instance_variable_set :@description, array[13]
@@ -1355,7 +1398,7 @@ class Gem::Specification < Gem::BasicSpecification
1355
1398
  sort_obj <=> other.sort_obj
1356
1399
  end
1357
1400
 
1358
- def == other # :nodoc:
1401
+ def ==(other) # :nodoc:
1359
1402
  self.class === other &&
1360
1403
  name == other.name &&
1361
1404
  version == other.version &&
@@ -1380,7 +1423,7 @@ class Gem::Specification < Gem::BasicSpecification
1380
1423
  @required_rubygems_version,
1381
1424
  @original_platform,
1382
1425
  @dependencies,
1383
- @rubyforge_project,
1426
+ "", # rubyforge_project
1384
1427
  @email,
1385
1428
  @authors,
1386
1429
  @description,
@@ -1388,7 +1431,7 @@ class Gem::Specification < Gem::BasicSpecification
1388
1431
  true, # has_rdoc
1389
1432
  @new_platform,
1390
1433
  @licenses,
1391
- @metadata
1434
+ @metadata,
1392
1435
  ]
1393
1436
  end
1394
1437
 
@@ -1400,7 +1443,7 @@ class Gem::Specification < Gem::BasicSpecification
1400
1443
 
1401
1444
  def activate
1402
1445
  other = Gem.loaded_specs[self.name]
1403
- if other then
1446
+ if other
1404
1447
  check_version_conflict other
1405
1448
  return false
1406
1449
  end
@@ -1414,7 +1457,7 @@ class Gem::Specification < Gem::BasicSpecification
1414
1457
  @activated = true
1415
1458
  @loaded = true
1416
1459
 
1417
- return true
1460
+ true
1418
1461
  end
1419
1462
 
1420
1463
  ##
@@ -1436,9 +1479,13 @@ class Gem::Specification < Gem::BasicSpecification
1436
1479
  raise e
1437
1480
  end
1438
1481
 
1439
- specs = spec_dep.to_specs
1482
+ begin
1483
+ specs = spec_dep.to_specs
1484
+ rescue Gem::MissingSpecError => e
1485
+ raise Gem::MissingSpecError.new(e.name, e.requirement, "at: #{self.spec_file}")
1486
+ end
1440
1487
 
1441
- if specs.size == 1 then
1488
+ if specs.size == 1
1442
1489
  specs.first.activate
1443
1490
  else
1444
1491
  name = spec_dep.name
@@ -1472,7 +1519,7 @@ class Gem::Specification < Gem::BasicSpecification
1472
1519
  self.summary = sanitize_string(summary)
1473
1520
  self.description = sanitize_string(description)
1474
1521
  self.post_install_message = sanitize_string(post_install_message)
1475
- self.authors = authors.collect { |a| sanitize_string(a) }
1522
+ self.authors = authors.collect {|a| sanitize_string(a) }
1476
1523
  end
1477
1524
 
1478
1525
  ##
@@ -1481,16 +1528,10 @@ class Gem::Specification < Gem::BasicSpecification
1481
1528
  def sanitize_string(string)
1482
1529
  return string unless string
1483
1530
 
1484
- # HACK the #to_s is in here because RSpec has an Array of Arrays of
1531
+ # HACK: the #to_s is in here because RSpec has an Array of Arrays of
1485
1532
  # Strings for authors. Need a way to disallow bad values on gemspec
1486
1533
  # generation. (Probably won't happen.)
1487
- string = string.to_s
1488
-
1489
- begin
1490
- Builder::XChar.encode string
1491
- rescue NameError, NoMethodError
1492
- string.to_xs
1493
- end
1534
+ string.to_s
1494
1535
  end
1495
1536
 
1496
1537
  ##
@@ -1500,13 +1541,13 @@ class Gem::Specification < Gem::BasicSpecification
1500
1541
  def add_bindir(executables)
1501
1542
  return nil if executables.nil?
1502
1543
 
1503
- if @bindir then
1504
- Array(executables).map { |e| File.join(@bindir, e) }
1544
+ if @bindir
1545
+ Array(executables).map {|e| File.join(@bindir, e) }
1505
1546
  else
1506
1547
  executables
1507
1548
  end
1508
- rescue
1509
- return nil
1549
+ rescue StandardError
1550
+ nil
1510
1551
  end
1511
1552
 
1512
1553
  ##
@@ -1514,12 +1555,12 @@ class Gem::Specification < Gem::BasicSpecification
1514
1555
  # +requirements+. Valid types are currently <tt>:runtime</tt> and
1515
1556
  # <tt>:development</tt>.
1516
1557
 
1517
- def add_dependency_with_type(dependency, type, *requirements)
1518
- requirements = if requirements.empty? then
1519
- Gem::Requirement.default
1520
- else
1521
- requirements.flatten
1522
- end
1558
+ def add_dependency_with_type(dependency, type, requirements)
1559
+ requirements = if requirements.empty?
1560
+ Gem::Requirement.default
1561
+ else
1562
+ requirements.flatten
1563
+ end
1523
1564
 
1524
1565
  unless dependency.respond_to?(:name) &&
1525
1566
  dependency.respond_to?(:requirement)
@@ -1541,23 +1582,14 @@ class Gem::Specification < Gem::BasicSpecification
1541
1582
 
1542
1583
  paths = full_require_paths
1543
1584
 
1544
- # gem directories must come after -I and ENV['RUBYLIB']
1545
- insert_index = Gem.load_path_insert_index
1546
-
1547
- if insert_index then
1548
- # gem directories must come after -I and ENV['RUBYLIB']
1549
- $LOAD_PATH.insert(insert_index, *paths)
1550
- else
1551
- # we are probably testing in core, -I and RUBYLIB don't apply
1552
- $LOAD_PATH.unshift(*paths)
1553
- end
1585
+ Gem.add_to_load_path(*paths)
1554
1586
  end
1555
1587
 
1556
1588
  ##
1557
1589
  # Singular reader for #authors. Returns the first author in the list
1558
1590
 
1559
1591
  def author
1560
- val = authors and val.first
1592
+ (val = authors) && val.first
1561
1593
  end
1562
1594
 
1563
1595
  ##
@@ -1576,13 +1608,13 @@ class Gem::Specification < Gem::BasicSpecification
1576
1608
  # a full path.
1577
1609
 
1578
1610
  def bin_dir
1579
- @bin_dir ||= File.join gem_dir, bindir # TODO: this is unfortunate
1611
+ @bin_dir ||= File.join gem_dir, bindir
1580
1612
  end
1581
1613
 
1582
1614
  ##
1583
1615
  # Returns the full path to an executable named +name+ in this gem.
1584
1616
 
1585
- def bin_file name
1617
+ def bin_file(name)
1586
1618
  File.join bin_dir, name
1587
1619
  end
1588
1620
 
@@ -1592,7 +1624,7 @@ class Gem::Specification < Gem::BasicSpecification
1592
1624
  def build_args
1593
1625
  if File.exist? build_info_file
1594
1626
  build_info = File.readlines build_info_file
1595
- build_info = build_info.map { |x| x.strip }
1627
+ build_info = build_info.map {|x| x.strip }
1596
1628
  build_info.delete ""
1597
1629
  build_info
1598
1630
  else
@@ -1605,12 +1637,13 @@ class Gem::Specification < Gem::BasicSpecification
1605
1637
  # the gem.build_complete file is missing.
1606
1638
 
1607
1639
  def build_extensions # :nodoc:
1608
- return if default_gem?
1609
1640
  return if extensions.empty?
1610
- return if installed_by_version < Gem::Version.new('2.2.0.preview.2')
1641
+ return if default_gem?
1642
+ # we need to fresh build when same name and version of default gems
1643
+ return if self.class.find_by_full_name(full_name)&.default_gem?
1611
1644
  return if File.exist? gem_build_complete_path
1612
- return if !File.writable?(base_dir)
1613
- return if !File.exist?(File.join(base_dir, 'extensions'))
1645
+ return unless File.writable?(base_dir)
1646
+ return unless File.exist?(File.join(base_dir, "extensions"))
1614
1647
 
1615
1648
  begin
1616
1649
  # We need to require things in $LOAD_PATH without looking for the
@@ -1618,9 +1651,9 @@ class Gem::Specification < Gem::BasicSpecification
1618
1651
  unresolved_deps = Gem::Specification.unresolved_deps.dup
1619
1652
  Gem::Specification.unresolved_deps.clear
1620
1653
 
1621
- require 'rubygems/config_file'
1622
- require 'rubygems/ext'
1623
- require 'rubygems/user_interaction'
1654
+ require_relative "config_file"
1655
+ require_relative "ext"
1656
+ require_relative "user_interaction"
1624
1657
 
1625
1658
  ui = Gem::SilentUI.new
1626
1659
  Gem::DefaultUserInteraction.use_ui ui do
@@ -1628,7 +1661,7 @@ class Gem::Specification < Gem::BasicSpecification
1628
1661
  builder.build_extensions
1629
1662
  end
1630
1663
  ensure
1631
- ui.close if ui
1664
+ ui&.close
1632
1665
  Gem::Specification.unresolved_deps.replace unresolved_deps
1633
1666
  end
1634
1667
  end
@@ -1648,16 +1681,6 @@ class Gem::Specification < Gem::BasicSpecification
1648
1681
  File.join build_info_dir, "#{full_name}.info"
1649
1682
  end
1650
1683
 
1651
- ##
1652
- # Used to detect if the gem is bundled in older version of Ruby, but not
1653
- # detectable as default gem (see BasicSpecification#default_gem?).
1654
-
1655
- def bundled_gem_in_old_ruby?
1656
- !default_gem? &&
1657
- RUBY_VERSION < "2.0.0" &&
1658
- summary == "This #{name} is bundled with Ruby"
1659
- end
1660
-
1661
1684
  ##
1662
1685
  # Returns the full path to the cache directory containing this
1663
1686
  # spec's cached gem.
@@ -1678,12 +1701,12 @@ class Gem::Specification < Gem::BasicSpecification
1678
1701
 
1679
1702
  def conflicts
1680
1703
  conflicts = {}
1681
- self.runtime_dependencies.each { |dep|
1704
+ self.runtime_dependencies.each do |dep|
1682
1705
  spec = Gem.loaded_specs[dep.name]
1683
- if spec and not spec.satisfies_requirement? dep
1706
+ if spec && !spec.satisfies_requirement?(dep)
1684
1707
  (conflicts[spec] ||= []) << dep
1685
1708
  end
1686
- }
1709
+ end
1687
1710
  env_req = Gem.env_requirement(name)
1688
1711
  (conflicts[self] ||= []) << env_req unless env_req.satisfied_by? version
1689
1712
  conflicts
@@ -1693,9 +1716,9 @@ class Gem::Specification < Gem::BasicSpecification
1693
1716
  # return true if there will be conflict when spec if loaded together with the list of specs.
1694
1717
 
1695
1718
  def conficts_when_loaded_with?(list_of_specs) # :nodoc:
1696
- result = list_of_specs.any? { |spec|
1697
- spec.dependencies.any? { |dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
1698
- }
1719
+ result = list_of_specs.any? do |spec|
1720
+ spec.dependencies.any? {|dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
1721
+ end
1699
1722
  result
1700
1723
  end
1701
1724
 
@@ -1704,64 +1727,61 @@ class Gem::Specification < Gem::BasicSpecification
1704
1727
 
1705
1728
  def has_conflicts?
1706
1729
  return true unless Gem.env_requirement(name).satisfied_by?(version)
1707
- self.dependencies.any? { |dep|
1708
- if dep.runtime? then
1730
+ self.dependencies.any? do |dep|
1731
+ if dep.runtime?
1709
1732
  spec = Gem.loaded_specs[dep.name]
1710
- spec and not spec.satisfies_requirement? dep
1733
+ spec && !spec.satisfies_requirement?(dep)
1711
1734
  else
1712
1735
  false
1713
1736
  end
1714
- }
1737
+ end
1715
1738
  end
1716
1739
 
1717
- ##
1718
- # The date this gem was created. Lazily defaults to the current UTC date.
1740
+ # The date this gem was created.
1741
+ #
1742
+ # If SOURCE_DATE_EPOCH is set as an environment variable, use that to support
1743
+ # reproducible builds; otherwise, default to the current UTC date.
1719
1744
  #
1720
- # There is no need to set this in your gem specification.
1745
+ # Details on SOURCE_DATE_EPOCH:
1746
+ # https://reproducible-builds.org/specs/source-date-epoch/
1721
1747
 
1722
1748
  def date
1723
- @date ||= TODAY
1749
+ @date ||= Time.utc(*Gem.source_date_epoch.utc.to_a[3..5].reverse)
1724
1750
  end
1725
1751
 
1726
1752
  DateLike = Object.new # :nodoc:
1727
1753
  def DateLike.===(obj) # :nodoc:
1728
- defined?(::Date) and Date === obj
1754
+ defined?(::Date) && Date === obj
1729
1755
  end
1730
1756
 
1731
1757
  DateTimeFormat = # :nodoc:
1732
1758
  /\A
1733
1759
  (\d{4})-(\d{2})-(\d{2})
1734
1760
  (\s+ \d{2}:\d{2}:\d{2}\.\d+ \s* (Z | [-+]\d\d:\d\d) )?
1735
- \Z/x
1761
+ \Z/x.freeze
1736
1762
 
1737
1763
  ##
1738
1764
  # The date this gem was created
1739
1765
  #
1740
1766
  # DO NOT set this, it is set automatically when the gem is packaged.
1741
1767
 
1742
- def date= date
1768
+ def date=(date)
1743
1769
  # We want to end up with a Time object with one-day resolution.
1744
1770
  # This is the cleanest, most-readable, faster-than-using-Date
1745
1771
  # way to do it.
1746
1772
  @date = case date
1747
- when String then
1748
- if DateTimeFormat =~ date then
1749
- Time.utc($1.to_i, $2.to_i, $3.to_i)
1750
-
1751
- # Workaround for where the date format output from psych isn't
1752
- # parsed as a Time object by syck and thus comes through as a
1753
- # string.
1754
- elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date then
1755
- Time.utc($1.to_i, $2.to_i, $3.to_i)
1756
- else
1757
- raise(Gem::InvalidSpecificationException,
1758
- "invalid date format in specification: #{date.inspect}")
1759
- end
1760
- when Time, DateLike then
1761
- Time.utc(date.year, date.month, date.day)
1762
- else
1763
- TODAY
1764
- end
1773
+ when String then
1774
+ if DateTimeFormat =~ date
1775
+ Time.utc($1.to_i, $2.to_i, $3.to_i)
1776
+ else
1777
+ raise(Gem::InvalidSpecificationException,
1778
+ "invalid date format in specification: #{date.inspect}")
1779
+ end
1780
+ when Time, DateLike then
1781
+ Time.utc(date.year, date.month, date.day)
1782
+ else
1783
+ TODAY
1784
+ end
1765
1785
  end
1766
1786
 
1767
1787
  ##
@@ -1771,20 +1791,21 @@ class Gem::Specification < Gem::BasicSpecification
1771
1791
  # executable now. See Gem.bin_path.
1772
1792
 
1773
1793
  def default_executable # :nodoc:
1774
- if defined?(@default_executable) and @default_executable
1794
+ if defined?(@default_executable) && @default_executable
1775
1795
  result = @default_executable
1776
- elsif @executables and @executables.size == 1
1796
+ elsif @executables && @executables.size == 1
1777
1797
  result = Array(@executables).first
1778
1798
  else
1779
1799
  result = nil
1780
1800
  end
1781
1801
  result
1782
1802
  end
1803
+ rubygems_deprecate :default_executable
1783
1804
 
1784
1805
  ##
1785
1806
  # The default value for specification attribute +name+
1786
1807
 
1787
- def default_value name
1808
+ def default_value(name)
1788
1809
  @@default_value[name]
1789
1810
  end
1790
1811
 
@@ -1804,17 +1825,17 @@ class Gem::Specification < Gem::BasicSpecification
1804
1825
  #
1805
1826
  # [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
1806
1827
 
1807
- def dependent_gems
1828
+ def dependent_gems(check_dev=true)
1808
1829
  out = []
1809
1830
  Gem::Specification.each do |spec|
1810
- spec.dependencies.each do |dep|
1811
- if self.satisfies_requirement?(dep) then
1812
- sats = []
1813
- find_all_satisfiers(dep) do |sat|
1814
- sats << sat
1815
- end
1816
- out << [spec, dep, sats]
1831
+ deps = check_dev ? spec.dependencies : spec.runtime_dependencies
1832
+ deps.each do |dep|
1833
+ next unless self.satisfies_requirement?(dep)
1834
+ sats = []
1835
+ find_all_satisfiers(dep) do |sat|
1836
+ sats << sat
1817
1837
  end
1838
+ out << [spec, dep, sats]
1818
1839
  end
1819
1840
  end
1820
1841
  out
@@ -1824,13 +1845,13 @@ class Gem::Specification < Gem::BasicSpecification
1824
1845
  # Returns all specs that matches this spec's runtime dependencies.
1825
1846
 
1826
1847
  def dependent_specs
1827
- runtime_dependencies.map { |dep| dep.to_specs }.flatten
1848
+ runtime_dependencies.map {|dep| dep.to_specs }.flatten
1828
1849
  end
1829
1850
 
1830
1851
  ##
1831
1852
  # A detailed description of this gem. See also #summary
1832
1853
 
1833
- def description= str
1854
+ def description=(str)
1834
1855
  @description = str.to_s
1835
1856
  end
1836
1857
 
@@ -1838,7 +1859,7 @@ class Gem::Specification < Gem::BasicSpecification
1838
1859
  # List of dependencies that are used for development
1839
1860
 
1840
1861
  def development_dependencies
1841
- dependencies.select { |d| d.type == :development }
1862
+ dependencies.select {|d| d.type == :development }
1842
1863
  end
1843
1864
 
1844
1865
  ##
@@ -1849,30 +1870,30 @@ class Gem::Specification < Gem::BasicSpecification
1849
1870
  #
1850
1871
  # spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri"
1851
1872
 
1852
- def doc_dir type = nil
1853
- @doc_dir ||= File.join base_dir, 'doc', full_name
1873
+ def doc_dir(type = nil)
1874
+ @doc_dir ||= File.join base_dir, "doc", full_name
1854
1875
 
1855
- if type then
1876
+ if type
1856
1877
  File.join @doc_dir, type
1857
1878
  else
1858
1879
  @doc_dir
1859
1880
  end
1860
1881
  end
1861
1882
 
1862
- def encode_with coder # :nodoc:
1883
+ def encode_with(coder) # :nodoc:
1863
1884
  mark_version
1864
1885
 
1865
- coder.add 'name', @name
1866
- coder.add 'version', @version
1886
+ coder.add "name", @name
1887
+ coder.add "version", @version
1867
1888
  platform = case @original_platform
1868
- when nil, '' then
1869
- 'ruby'
1870
- when String then
1871
- @original_platform
1872
- else
1873
- @original_platform.to_s
1874
- end
1875
- coder.add 'platform', platform
1889
+ when nil, "" then
1890
+ "ruby"
1891
+ when String then
1892
+ @original_platform
1893
+ else
1894
+ @original_platform.to_s
1895
+ end
1896
+ coder.add "platform", platform
1876
1897
 
1877
1898
  attributes = @@attributes.map(&:to_s) - %w[name version platform]
1878
1899
  attributes.each do |name|
@@ -1880,7 +1901,7 @@ class Gem::Specification < Gem::BasicSpecification
1880
1901
  end
1881
1902
  end
1882
1903
 
1883
- def eql? other # :nodoc:
1904
+ def eql?(other) # :nodoc:
1884
1905
  self.class === other && same_attributes?(other)
1885
1906
  end
1886
1907
 
@@ -1888,40 +1909,34 @@ class Gem::Specification < Gem::BasicSpecification
1888
1909
  # Singular accessor for #executables
1889
1910
 
1890
1911
  def executable
1891
- val = executables and val.first
1912
+ (val = executables) && val.first
1892
1913
  end
1893
1914
 
1894
1915
  ##
1895
1916
  # Singular accessor for #executables
1896
1917
 
1897
- def executable=o
1918
+ def executable=(o)
1898
1919
  self.executables = [o]
1899
1920
  end
1900
1921
 
1901
1922
  ##
1902
- # Sets executables to +value+, ensuring it is an array. Don't
1903
- # use this, push onto the array instead.
1923
+ # Sets executables to +value+, ensuring it is an array.
1904
1924
 
1905
- def executables= value
1906
- # TODO: warn about setting instead of pushing
1925
+ def executables=(value)
1907
1926
  @executables = Array(value)
1908
1927
  end
1909
1928
 
1910
1929
  ##
1911
- # Sets extensions to +extensions+, ensuring it is an array. Don't
1912
- # use this, push onto the array instead.
1930
+ # Sets extensions to +extensions+, ensuring it is an array.
1913
1931
 
1914
- def extensions= extensions
1915
- # TODO: warn about setting instead of pushing
1932
+ def extensions=(extensions)
1916
1933
  @extensions = Array extensions
1917
1934
  end
1918
1935
 
1919
1936
  ##
1920
- # Sets extra_rdoc_files to +files+, ensuring it is an array. Don't
1921
- # use this, push onto the array instead.
1937
+ # Sets extra_rdoc_files to +files+, ensuring it is an array.
1922
1938
 
1923
- def extra_rdoc_files= files
1924
- # TODO: warn about setting instead of pushing
1939
+ def extra_rdoc_files=(files)
1925
1940
  @extra_rdoc_files = Array files
1926
1941
  end
1927
1942
 
@@ -1937,14 +1952,14 @@ class Gem::Specification < Gem::BasicSpecification
1937
1952
  ##
1938
1953
  # Sets files to +files+, ensuring it is an array.
1939
1954
 
1940
- def files= files
1955
+ def files=(files)
1941
1956
  @files = Array files
1942
1957
  end
1943
1958
 
1944
1959
  ##
1945
1960
  # Finds all gems that satisfy +dep+
1946
1961
 
1947
- def find_all_satisfiers dep
1962
+ def find_all_satisfiers(dep)
1948
1963
  Gem::Specification.each do |spec|
1949
1964
  yield spec if spec.satisfies_requirement? dep
1950
1965
  end
@@ -1976,8 +1991,7 @@ class Gem::Specification < Gem::BasicSpecification
1976
1991
  end
1977
1992
 
1978
1993
  def gems_dir
1979
- # TODO: this logic seems terribly broken, but tests fail if just base_dir
1980
- @gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
1994
+ @gems_dir ||= File.join(base_dir, "gems")
1981
1995
  end
1982
1996
 
1983
1997
  ##
@@ -1988,23 +2002,26 @@ class Gem::Specification < Gem::BasicSpecification
1988
2002
  def has_rdoc # :nodoc:
1989
2003
  true
1990
2004
  end
2005
+ rubygems_deprecate :has_rdoc
1991
2006
 
1992
2007
  ##
1993
2008
  # Deprecated and ignored.
1994
2009
  #
1995
2010
  # Formerly used to indicate this gem was RDoc-capable.
1996
2011
 
1997
- def has_rdoc= ignored # :nodoc:
2012
+ def has_rdoc=(ignored) # :nodoc:
1998
2013
  @has_rdoc = true
1999
2014
  end
2015
+ rubygems_deprecate :has_rdoc=
2000
2016
 
2001
2017
  alias :has_rdoc? :has_rdoc # :nodoc:
2018
+ rubygems_deprecate :has_rdoc?
2002
2019
 
2003
2020
  ##
2004
2021
  # True if this gem has files in test_files
2005
2022
 
2006
2023
  def has_unit_tests? # :nodoc:
2007
- not test_files.empty?
2024
+ !test_files.empty?
2008
2025
  end
2009
2026
 
2010
2027
  # :stopdoc:
@@ -2015,17 +2032,31 @@ class Gem::Specification < Gem::BasicSpecification
2015
2032
  name.hash ^ version.hash
2016
2033
  end
2017
2034
 
2018
- def init_with coder # :nodoc:
2035
+ def init_with(coder) # :nodoc:
2019
2036
  @installed_by_version ||= nil
2020
2037
  yaml_initialize coder.tag, coder.map
2021
2038
  end
2022
2039
 
2040
+ eval <<-RUBY, binding, __FILE__, __LINE__ + 1
2041
+ # frozen_string_literal: true
2042
+
2043
+ def set_nil_attributes_to_nil
2044
+ #{@@nil_attributes.map {|key| "@#{key} = nil" }.join "; "}
2045
+ end
2046
+ private :set_nil_attributes_to_nil
2047
+
2048
+ def set_not_nil_attributes_to_default_values
2049
+ #{@@non_nil_attributes.map {|key| "@#{key} = #{INITIALIZE_CODE_FOR_DEFAULTS[key]}" }.join ";"}
2050
+ end
2051
+ private :set_not_nil_attributes_to_default_values
2052
+ RUBY
2053
+
2023
2054
  ##
2024
2055
  # Specification constructor. Assigns the default values to the attributes
2025
2056
  # and yields itself for further initialization. Optionally takes +name+ and
2026
2057
  # +version+.
2027
2058
 
2028
- def initialize name = nil, version = nil
2059
+ def initialize(name = nil, version = nil)
2029
2060
  super()
2030
2061
  @gems_dir = nil
2031
2062
  @base_dir = nil
@@ -2035,35 +2066,32 @@ class Gem::Specification < Gem::BasicSpecification
2035
2066
  @original_platform = nil
2036
2067
  @installed_by_version = nil
2037
2068
 
2038
- @@nil_attributes.each do |key|
2039
- instance_variable_set "@#{key}", nil
2040
- end
2041
-
2042
- @@non_nil_attributes.each do |key|
2043
- default = default_value(key)
2044
- value = Dupable[key] ? default.dup : default
2045
- instance_variable_set "@#{key}", value
2046
- end
2069
+ set_nil_attributes_to_nil
2070
+ set_not_nil_attributes_to_default_values
2047
2071
 
2048
2072
  @new_platform = Gem::Platform::RUBY
2049
2073
 
2050
2074
  self.name = name if name
2051
2075
  self.version = version if version
2052
2076
 
2077
+ if (platform = Gem.platforms.last) && platform != Gem::Platform::RUBY && platform != Gem::Platform.local
2078
+ self.platform = platform
2079
+ end
2080
+
2053
2081
  yield self if block_given?
2054
2082
  end
2055
2083
 
2056
2084
  ##
2057
2085
  # Duplicates array_attributes from +other_spec+ so state isn't shared.
2058
2086
 
2059
- def initialize_copy other_spec
2087
+ def initialize_copy(other_spec)
2060
2088
  self.class.array_attributes.each do |name|
2061
2089
  name = :"@#{name}"
2062
2090
  next unless other_spec.instance_variable_defined? name
2063
2091
 
2064
2092
  begin
2065
2093
  val = other_spec.instance_variable_get(name)
2066
- if val then
2094
+ if val
2067
2095
  instance_variable_set name, val.dup
2068
2096
  elsif Gem.configuration.really_verbose
2069
2097
  warn "WARNING: #{full_name} has an invalid nil value for #{name}"
@@ -2080,11 +2108,11 @@ class Gem::Specification < Gem::BasicSpecification
2080
2108
 
2081
2109
  def base_dir
2082
2110
  return Gem.dir unless loaded_from
2083
- @base_dir ||= if default_gem? then
2084
- File.dirname File.dirname File.dirname loaded_from
2085
- else
2086
- File.dirname File.dirname loaded_from
2087
- end
2111
+ @base_dir ||= if default_gem?
2112
+ File.dirname File.dirname File.dirname loaded_from
2113
+ else
2114
+ File.dirname File.dirname loaded_from
2115
+ end
2088
2116
  end
2089
2117
 
2090
2118
  ##
@@ -2102,7 +2130,7 @@ class Gem::Specification < Gem::BasicSpecification
2102
2130
  if $DEBUG
2103
2131
  super
2104
2132
  else
2105
- "#<#{self.class}:0x#{__id__.to_s(16)} #{full_name}>"
2133
+ "#{super[0..-2]} #{full_name}>"
2106
2134
  end
2107
2135
  end
2108
2136
 
@@ -2152,11 +2180,17 @@ class Gem::Specification < Gem::BasicSpecification
2152
2180
  end
2153
2181
 
2154
2182
  ##
2183
+ # Track removed method calls to warn about during build time.
2155
2184
  # Warn about unknown attributes while loading a spec.
2156
2185
 
2157
2186
  def method_missing(sym, *a, &b) # :nodoc:
2158
- if @specification_version > CURRENT_SPECIFICATION_VERSION and
2159
- sym.to_s =~ /=$/ then
2187
+ if REMOVED_METHODS.include?(sym)
2188
+ removed_method_calls << sym
2189
+ return
2190
+ end
2191
+
2192
+ if @specification_version > CURRENT_SPECIFICATION_VERSION &&
2193
+ sym.to_s.end_with?("=")
2160
2194
  warn "ignoring #{sym} loading #{full_name}" if $DEBUG
2161
2195
  else
2162
2196
  super
@@ -2168,9 +2202,8 @@ class Gem::Specification < Gem::BasicSpecification
2168
2202
  # probably want to build_extensions
2169
2203
 
2170
2204
  def missing_extensions?
2171
- return false if default_gem?
2172
2205
  return false if extensions.empty?
2173
- return false if installed_by_version < Gem::Version.new('2.2.0.preview.2')
2206
+ return false if default_gem?
2174
2207
  return false if File.exist? gem_build_complete_path
2175
2208
 
2176
2209
  true
@@ -2183,7 +2216,7 @@ class Gem::Specification < Gem::BasicSpecification
2183
2216
  # file list.
2184
2217
 
2185
2218
  def normalize
2186
- if defined?(@extra_rdoc_files) and @extra_rdoc_files then
2219
+ if defined?(@extra_rdoc_files) && @extra_rdoc_files
2187
2220
  @extra_rdoc_files.uniq!
2188
2221
  @files ||= []
2189
2222
  @files.concat(@extra_rdoc_files)
@@ -2208,7 +2241,7 @@ class Gem::Specification < Gem::BasicSpecification
2208
2241
  # platform. For use with legacy gems.
2209
2242
 
2210
2243
  def original_name # :nodoc:
2211
- if platform == Gem::Platform::RUBY or platform.nil? then
2244
+ if platform == Gem::Platform::RUBY || platform.nil?
2212
2245
  "#{@name}-#{@version}"
2213
2246
  else
2214
2247
  "#{@name}-#{@version}-#{@original_platform}"
@@ -2226,11 +2259,11 @@ class Gem::Specification < Gem::BasicSpecification
2226
2259
  # The platform this gem runs on. See Gem::Platform for details.
2227
2260
 
2228
2261
  def platform
2229
- @new_platform ||= Gem::Platform::RUBY
2262
+ @new_platform ||= Gem::Platform::RUBY # rubocop:disable Naming/MemoizedInstanceVariableName
2230
2263
  end
2231
2264
 
2232
2265
  def pretty_print(q) # :nodoc:
2233
- q.group 2, 'Gem::Specification.new do |s|', 'end' do
2266
+ q.group 2, "Gem::Specification.new do |s|", "end" do
2234
2267
  q.breakable
2235
2268
 
2236
2269
  attributes = @@attributes - [:name, :version]
@@ -2240,21 +2273,21 @@ class Gem::Specification < Gem::BasicSpecification
2240
2273
 
2241
2274
  attributes.each do |attr_name|
2242
2275
  current_value = self.send attr_name
2243
- if current_value != default_value(attr_name) or
2244
- self.class.required_attribute? attr_name then
2276
+ current_value = current_value.sort if %i[files test_files].include? attr_name
2277
+ next unless current_value != default_value(attr_name) ||
2278
+ self.class.required_attribute?(attr_name)
2245
2279
 
2246
- q.text "s.#{attr_name} = "
2280
+ q.text "s.#{attr_name} = "
2247
2281
 
2248
- if attr_name == :date then
2249
- current_value = current_value.utc
2282
+ if attr_name == :date
2283
+ current_value = current_value.utc
2250
2284
 
2251
- q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
2252
- else
2253
- q.pp current_value
2254
- end
2255
-
2256
- q.breakable
2285
+ q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
2286
+ else
2287
+ q.pp current_value
2257
2288
  end
2289
+
2290
+ q.breakable
2258
2291
  end
2259
2292
  end
2260
2293
  end
@@ -2263,7 +2296,7 @@ class Gem::Specification < Gem::BasicSpecification
2263
2296
  # Raise an exception if the version of this spec conflicts with the one
2264
2297
  # that is already loaded (+other+)
2265
2298
 
2266
- def check_version_conflict other # :nodoc:
2299
+ def check_version_conflict(other) # :nodoc:
2267
2300
  return if self.version == other.version
2268
2301
 
2269
2302
  # This gem is already loaded. If the currently loaded gem is not in the
@@ -2273,7 +2306,6 @@ class Gem::Specification < Gem::BasicSpecification
2273
2306
 
2274
2307
  e = Gem::LoadError.new msg
2275
2308
  e.name = self.name
2276
- # TODO: e.requirement = dep.requirement
2277
2309
 
2278
2310
  raise e
2279
2311
  end
@@ -2284,17 +2316,15 @@ class Gem::Specification < Gem::BasicSpecification
2284
2316
  # Check the spec for possible conflicts and freak out if there are any.
2285
2317
 
2286
2318
  def raise_if_conflicts # :nodoc:
2287
- if has_conflicts? then
2319
+ if has_conflicts?
2288
2320
  raise Gem::ConflictError.new self, conflicts
2289
2321
  end
2290
2322
  end
2291
2323
 
2292
2324
  ##
2293
- # Sets rdoc_options to +value+, ensuring it is an array. Don't
2294
- # use this, push onto the array instead.
2325
+ # Sets rdoc_options to +value+, ensuring it is an array.
2295
2326
 
2296
- def rdoc_options= options
2297
- # TODO: warn about setting instead of pushing
2327
+ def rdoc_options=(options)
2298
2328
  @rdoc_options = Array options
2299
2329
  end
2300
2330
 
@@ -2302,26 +2332,24 @@ class Gem::Specification < Gem::BasicSpecification
2302
2332
  # Singular accessor for #require_paths
2303
2333
 
2304
2334
  def require_path
2305
- val = require_paths and val.first
2335
+ (val = require_paths) && val.first
2306
2336
  end
2307
2337
 
2308
2338
  ##
2309
2339
  # Singular accessor for #require_paths
2310
2340
 
2311
- def require_path= path
2341
+ def require_path=(path)
2312
2342
  self.require_paths = Array(path)
2313
2343
  end
2314
2344
 
2315
2345
  ##
2316
- # Set requirements to +req+, ensuring it is an array. Don't
2317
- # use this, push onto the array instead.
2346
+ # Set requirements to +req+, ensuring it is an array.
2318
2347
 
2319
- def requirements= req
2320
- # TODO: warn about setting instead of pushing
2348
+ def requirements=(req)
2321
2349
  @requirements = Array req
2322
2350
  end
2323
2351
 
2324
- def respond_to_missing? m, include_private = false # :nodoc:
2352
+ def respond_to_missing?(m, include_private = false) # :nodoc:
2325
2353
  false
2326
2354
  end
2327
2355
 
@@ -2329,7 +2357,7 @@ class Gem::Specification < Gem::BasicSpecification
2329
2357
  # Returns the full path to this spec's ri directory.
2330
2358
 
2331
2359
  def ri_dir
2332
- @ri_dir ||= File.join base_dir, 'ri', full_name
2360
+ @ri_dir ||= File.join base_dir, "ri", full_name
2333
2361
  end
2334
2362
 
2335
2363
  ##
@@ -2338,18 +2366,18 @@ class Gem::Specification < Gem::BasicSpecification
2338
2366
 
2339
2367
  def ruby_code(obj)
2340
2368
  case obj
2341
- when String then obj.dump + ".freeze"
2342
- when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
2343
- when Hash then
2344
- seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
2345
- "{ #{seg.join(', ')} }"
2346
- when Gem::Version then obj.to_s.dump
2347
- when DateLike then obj.strftime('%Y-%m-%d').dump
2348
- when Time then obj.strftime('%Y-%m-%d').dump
2349
- when Numeric then obj.inspect
2350
- when true, false, nil then obj.inspect
2351
- when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
2352
- when Gem::Requirement then
2369
+ when String then obj.dump + ".freeze"
2370
+ when Array then "[" + obj.map {|x| ruby_code x }.join(", ") + "]"
2371
+ when Hash then
2372
+ seg = obj.keys.sort.map {|k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
2373
+ "{ #{seg.join(", ")} }"
2374
+ when Gem::Version then ruby_code(obj.to_s)
2375
+ when DateLike then obj.strftime("%Y-%m-%d").dump
2376
+ when Time then obj.strftime("%Y-%m-%d").dump
2377
+ when Numeric then obj.inspect
2378
+ when true, false, nil then obj.inspect
2379
+ when Gem::Platform then "Gem::Platform.new(#{ruby_code obj.to_a})"
2380
+ when Gem::Requirement then
2353
2381
  list = obj.as_list
2354
2382
  "Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
2355
2383
  else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
@@ -2368,8 +2396,8 @@ class Gem::Specification < Gem::BasicSpecification
2368
2396
  ##
2369
2397
  # True if this gem has the same attributes as +other+.
2370
2398
 
2371
- def same_attributes? spec
2372
- @@attributes.all? { |name, default| self.send(name) == spec.send(name) }
2399
+ def same_attributes?(spec)
2400
+ @@attributes.all? {|name, default| self.send(name) == spec.send(name) }
2373
2401
  end
2374
2402
 
2375
2403
  private :same_attributes?
@@ -2377,8 +2405,8 @@ class Gem::Specification < Gem::BasicSpecification
2377
2405
  ##
2378
2406
  # Checks if this specification meets the requirement of +dependency+.
2379
2407
 
2380
- def satisfies_requirement? dependency
2381
- return @name == dependency.name &&
2408
+ def satisfies_requirement?(dependency)
2409
+ @name == dependency.name &&
2382
2410
  dependency.requirement.satisfied_by?(@version)
2383
2411
  end
2384
2412
 
@@ -2386,7 +2414,7 @@ class Gem::Specification < Gem::BasicSpecification
2386
2414
  # Returns an object you can use to sort specifications in #sort_by.
2387
2415
 
2388
2416
  def sort_obj
2389
- [@name, @version, @new_platform == Gem::Platform::RUBY ? -1 : 1]
2417
+ [@name, @version, Gem::Platform.sort_priority(@new_platform)]
2390
2418
  end
2391
2419
 
2392
2420
  ##
@@ -2424,7 +2452,7 @@ class Gem::Specification < Gem::BasicSpecification
2424
2452
  ##
2425
2453
  # A short summary of this gem's description.
2426
2454
 
2427
- def summary= str
2455
+ def summary=(str)
2428
2456
  @summary = str.to_s.strip.
2429
2457
  gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').gsub(/\n[ \t]*/, " ") # so. weird.
2430
2458
  end
@@ -2433,13 +2461,13 @@ class Gem::Specification < Gem::BasicSpecification
2433
2461
  # Singular accessor for #test_files
2434
2462
 
2435
2463
  def test_file # :nodoc:
2436
- val = test_files and val.first
2464
+ (val = test_files) && val.first
2437
2465
  end
2438
2466
 
2439
2467
  ##
2440
2468
  # Singular mutator for #test_files
2441
2469
 
2442
- def test_file= file # :nodoc:
2470
+ def test_file=(file) # :nodoc:
2443
2471
  self.test_files = [file]
2444
2472
  end
2445
2473
 
@@ -2451,11 +2479,11 @@ class Gem::Specification < Gem::BasicSpecification
2451
2479
  # Handle the possibility that we have @test_suite_file but not
2452
2480
  # @test_files. This will happen when an old gem is loaded via
2453
2481
  # YAML.
2454
- if defined? @test_suite_file then
2482
+ if defined? @test_suite_file
2455
2483
  @test_files = [@test_suite_file].flatten
2456
2484
  @test_suite_file = nil
2457
2485
  end
2458
- if defined?(@test_files) and @test_files then
2486
+ if defined?(@test_files) && @test_files
2459
2487
  @test_files
2460
2488
  else
2461
2489
  @test_files = []
@@ -2479,13 +2507,13 @@ class Gem::Specification < Gem::BasicSpecification
2479
2507
 
2480
2508
  result << " s.name = #{ruby_code name}"
2481
2509
  result << " s.version = #{ruby_code version}"
2482
- unless platform.nil? or platform == Gem::Platform::RUBY then
2510
+ unless platform.nil? || platform == Gem::Platform::RUBY
2483
2511
  result << " s.platform = #{ruby_code original_platform}"
2484
2512
  end
2485
2513
  result << ""
2486
2514
  result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version="
2487
2515
 
2488
- if metadata and !metadata.empty?
2516
+ if metadata && !metadata.empty?
2489
2517
  result << " s.metadata = #{ruby_code metadata} if s.respond_to? :metadata="
2490
2518
  end
2491
2519
  result << " s.require_paths = #{ruby_code raw_require_paths}"
@@ -2500,52 +2528,36 @@ class Gem::Specification < Gem::BasicSpecification
2500
2528
  :version,
2501
2529
  :has_rdoc,
2502
2530
  :default_executable,
2503
- :metadata
2531
+ :metadata,
2532
+ :signing_key,
2504
2533
  ]
2505
2534
 
2506
2535
  @@attributes.each do |attr_name|
2507
2536
  next if handled.include? attr_name
2508
2537
  current_value = self.send(attr_name)
2509
- if current_value != default_value(attr_name) or
2510
- self.class.required_attribute? attr_name then
2538
+ if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name)
2511
2539
  result << " s.#{attr_name} = #{ruby_code current_value}"
2512
2540
  end
2513
2541
  end
2514
2542
 
2515
- if @installed_by_version then
2543
+ if String === signing_key
2544
+ result << " s.signing_key = #{ruby_code signing_key}"
2545
+ end
2546
+
2547
+ if @installed_by_version
2516
2548
  result << nil
2517
- result << " s.installed_by_version = \"#{Gem::VERSION}\" if s.respond_to? :installed_by_version"
2549
+ result << " s.installed_by_version = #{ruby_code Gem::VERSION} if s.respond_to? :installed_by_version"
2518
2550
  end
2519
2551
 
2520
- unless dependencies.empty? then
2552
+ unless dependencies.empty?
2521
2553
  result << nil
2522
- result << " if s.respond_to? :specification_version then"
2523
- result << " s.specification_version = #{specification_version}"
2554
+ result << " s.specification_version = #{specification_version}"
2524
2555
  result << nil
2525
2556
 
2526
- result << " if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then"
2527
-
2528
2557
  dependencies.each do |dep|
2529
- req = dep.requirements_list.inspect
2530
2558
  dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
2531
- result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
2532
- end
2533
-
2534
- result << " else"
2535
-
2536
- dependencies.each do |dep|
2537
- version_reqs_param = dep.requirements_list.inspect
2538
- result << " s.add_dependency(%q<#{dep.name}>.freeze, #{version_reqs_param})"
2559
+ result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{ruby_code dep.requirements_list})"
2539
2560
  end
2540
-
2541
- result << ' end'
2542
-
2543
- result << " else"
2544
- dependencies.each do |dep|
2545
- version_reqs_param = dep.requirements_list.inspect
2546
- result << " s.add_dependency(%q<#{dep.name}>.freeze, #{version_reqs_param})"
2547
- end
2548
- result << " end"
2549
2561
  end
2550
2562
 
2551
2563
  result << "end"
@@ -2576,44 +2588,38 @@ class Gem::Specification < Gem::BasicSpecification
2576
2588
  end
2577
2589
 
2578
2590
  def to_yaml(opts = {}) # :nodoc:
2579
- if (YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?) ||
2580
- (defined?(Psych) && YAML == Psych) then
2581
- # Because the user can switch the YAML engine behind our
2582
- # back, we have to check again here to make sure that our
2583
- # psych code was properly loaded, and load it if not.
2584
- unless Gem.const_defined?(:NoAliasYAMLTree)
2585
- require 'rubygems/psych_tree'
2586
- end
2591
+ Gem.load_yaml
2587
2592
 
2588
- builder = Gem::NoAliasYAMLTree.create
2589
- builder << self
2590
- ast = builder.tree
2593
+ # Because the user can switch the YAML engine behind our
2594
+ # back, we have to check again here to make sure that our
2595
+ # psych code was properly loaded, and load it if not.
2596
+ unless Gem.const_defined?(:NoAliasYAMLTree)
2597
+ require_relative "psych_tree"
2598
+ end
2591
2599
 
2592
- io = StringIO.new
2593
- io.set_encoding Encoding::UTF_8 if Object.const_defined? :Encoding
2600
+ builder = Gem::NoAliasYAMLTree.create
2601
+ builder << self
2602
+ ast = builder.tree
2594
2603
 
2595
- Psych::Visitors::Emitter.new(io).accept(ast)
2604
+ require "stringio"
2605
+ io = StringIO.new
2606
+ io.set_encoding Encoding::UTF_8
2596
2607
 
2597
- io.string.gsub(/ !!null \n/, " \n")
2598
- else
2599
- YAML.quick_emit object_id, opts do |out|
2600
- out.map taguri, to_yaml_style do |map|
2601
- encode_with map
2602
- end
2603
- end
2604
- end
2608
+ Psych::Visitors::Emitter.new(io).accept(ast)
2609
+
2610
+ io.string.gsub(/ !!null \n/, " \n")
2605
2611
  end
2606
2612
 
2607
2613
  ##
2608
2614
  # Recursively walk dependencies of this spec, executing the +block+ for each
2609
2615
  # hop.
2610
2616
 
2611
- def traverse trail = [], visited = {}, &block
2617
+ def traverse(trail = [], visited = {}, &block)
2612
2618
  trail.push(self)
2613
2619
  begin
2614
2620
  dependencies.each do |dep|
2615
2621
  next unless dep.runtime?
2616
- dep.to_specs.reverse_each do |dep_spec|
2622
+ dep.matching_specs(true).each do |dep_spec|
2617
2623
  next if visited.has_key?(dep_spec)
2618
2624
  visited[dep_spec] = true
2619
2625
  trail.push(dep_spec)
@@ -2622,11 +2628,10 @@ class Gem::Specification < Gem::BasicSpecification
2622
2628
  ensure
2623
2629
  trail.pop
2624
2630
  end
2625
- unless result == :next
2626
- spec_name = dep_spec.name
2627
- dep_spec.traverse(trail, visited, &block) unless
2628
- trail.any? { |s| s.name == spec_name }
2629
- end
2631
+ next if result == :next
2632
+ spec_name = dep_spec.name
2633
+ dep_spec.traverse(trail, visited, &block) unless
2634
+ trail.any? {|s| s.name == spec_name }
2630
2635
  end
2631
2636
  end
2632
2637
  ensure
@@ -2641,317 +2646,54 @@ class Gem::Specification < Gem::BasicSpecification
2641
2646
  # Raises InvalidSpecificationException if the spec does not pass the
2642
2647
  # checks..
2643
2648
 
2644
- def validate packaging = true
2645
- @warnings = 0
2646
- require 'rubygems/user_interaction'
2647
- extend Gem::UserInteraction
2649
+ def validate(packaging = true, strict = false)
2648
2650
  normalize
2649
2651
 
2650
- nil_attributes = self.class.non_nil_attributes.find_all do |attrname|
2651
- instance_variable_get("@#{attrname}").nil?
2652
- end
2653
-
2654
- unless nil_attributes.empty? then
2655
- raise Gem::InvalidSpecificationException,
2656
- "#{nil_attributes.join ', '} must not be nil"
2657
- end
2658
-
2659
- if packaging and rubygems_version != Gem::VERSION then
2660
- raise Gem::InvalidSpecificationException,
2661
- "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
2662
- end
2663
-
2664
- @@required_attributes.each do |symbol|
2665
- unless self.send symbol then
2666
- raise Gem::InvalidSpecificationException,
2667
- "missing value for attribute #{symbol}"
2668
- end
2669
- end
2670
-
2671
- unless String === name then
2672
- raise Gem::InvalidSpecificationException,
2673
- "invalid value for attribute name: \"#{name.inspect}\""
2674
- end
2675
-
2676
- if raw_require_paths.empty? then
2677
- raise Gem::InvalidSpecificationException,
2678
- 'specification must have at least one require_path'
2679
- end
2680
-
2681
- @files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2682
- @test_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2683
- @executables.delete_if { |x| File.directory?(File.join(@bindir, x)) }
2684
- @extra_rdoc_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2685
- @extensions.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2686
-
2687
- non_files = files.reject { |x| File.file?(x) || File.symlink?(x) }
2688
-
2689
- unless not packaging or non_files.empty? then
2690
- raise Gem::InvalidSpecificationException,
2691
- "[\"#{non_files.join "\", \""}\"] are not files"
2692
- end
2693
-
2694
- if files.include? file_name then
2695
- raise Gem::InvalidSpecificationException,
2696
- "#{full_name} contains itself (#{file_name}), check your files list"
2697
- end
2698
-
2699
- unless specification_version.is_a?(Fixnum)
2700
- raise Gem::InvalidSpecificationException,
2701
- 'specification_version must be a Fixnum (did you mean version?)'
2702
- end
2703
-
2704
- case platform
2705
- when Gem::Platform, Gem::Platform::RUBY then # ok
2706
- else
2707
- raise Gem::InvalidSpecificationException,
2708
- "invalid platform #{platform.inspect}, see Gem::Platform"
2709
- end
2710
-
2711
- self.class.array_attributes.each do |field|
2712
- val = self.send field
2713
- klass = case field
2714
- when :dependencies
2715
- Gem::Dependency
2716
- else
2717
- String
2718
- end
2719
-
2720
- unless Array === val and val.all? { |x| x.kind_of?(klass) } then
2721
- raise(Gem::InvalidSpecificationException,
2722
- "#{field} must be an Array of #{klass}")
2723
- end
2724
- end
2725
-
2726
- [:authors].each do |field|
2727
- val = self.send field
2728
- raise Gem::InvalidSpecificationException, "#{field} may not be empty" if
2729
- val.empty?
2730
- end
2731
-
2732
- unless Hash === metadata
2733
- raise Gem::InvalidSpecificationException,
2734
- 'metadata must be a hash'
2735
- end
2736
-
2737
- metadata.keys.each do |k|
2738
- if !k.kind_of?(String)
2739
- raise Gem::InvalidSpecificationException,
2740
- 'metadata keys must be a String'
2741
- end
2742
-
2743
- if k.size > 128
2744
- raise Gem::InvalidSpecificationException,
2745
- "metadata key too large (#{k.size} > 128)"
2746
- end
2747
- end
2748
-
2749
- metadata.values.each do |k|
2750
- if !k.kind_of?(String)
2751
- raise Gem::InvalidSpecificationException,
2752
- 'metadata values must be a String'
2753
- end
2754
-
2755
- if k.size > 1024
2756
- raise Gem::InvalidSpecificationException,
2757
- "metadata value too large (#{k.size} > 1024)"
2758
- end
2759
- end
2760
-
2761
- licenses.each { |license|
2762
- if license.length > 64
2763
- raise Gem::InvalidSpecificationException,
2764
- "each license must be 64 characters or less"
2765
- end
2766
-
2767
- if !Gem::Licenses.match?(license)
2768
- suggestions = Gem::Licenses.suggestions(license)
2769
- message = <<-warning
2770
- license value '#{license}' is invalid. Use a license identifier from
2771
- http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
2772
- warning
2773
- message += "Did you mean #{suggestions.map { |s| "'#{s}'"}.join(', ')}?\n" unless suggestions.nil?
2774
- warning(message)
2775
- end
2776
- }
2777
-
2778
- warning <<-warning if licenses.empty?
2779
- licenses is empty, but is recommended. Use a license identifier from
2780
- http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
2781
- warning
2782
-
2783
- validate_permissions
2784
-
2785
- # reject lazy developers:
2786
-
2787
- lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
2788
-
2789
- unless authors.grep(/FI XME|TO DO/x).empty? then
2790
- raise Gem::InvalidSpecificationException, "#{lazy} is not an author"
2791
- end
2792
-
2793
- unless Array(email).grep(/FI XME|TO DO/x).empty? then
2794
- raise Gem::InvalidSpecificationException, "#{lazy} is not an email"
2795
- end
2796
-
2797
- if description =~ /FI XME|TO DO/x then
2798
- raise Gem::InvalidSpecificationException, "#{lazy} is not a description"
2799
- end
2800
-
2801
- if summary =~ /FI XME|TO DO/x then
2802
- raise Gem::InvalidSpecificationException, "#{lazy} is not a summary"
2803
- end
2804
-
2805
- if homepage and not homepage.empty? and
2806
- homepage !~ /\A[a-z][a-z\d+.-]*:/i then
2807
- raise Gem::InvalidSpecificationException,
2808
- "\"#{homepage}\" is not a URI"
2809
- end
2810
-
2811
- # Warnings
2812
-
2813
- %w[author email homepage summary].each do |attribute|
2814
- value = self.send attribute
2815
- warning "no #{attribute} specified" if value.nil? or value.empty?
2816
- end
2817
-
2818
- if description == summary then
2819
- warning 'description and summary are identical'
2820
- end
2821
-
2822
- # TODO: raise at some given date
2823
- warning "deprecated autorequire specified" if autorequire
2824
-
2825
- executables.each do |executable|
2826
- executable_path = File.join(bindir, executable)
2827
- shebang = File.read(executable_path, 2) == '#!'
2828
-
2829
- warning "#{executable_path} is missing #! line" unless shebang
2830
- end
2831
-
2832
- files.each do |file|
2833
- next unless File.symlink?(file)
2834
- warning "#{file} is a symlink, which is not supported on all platforms"
2835
- end
2836
-
2837
- validate_dependencies
2838
-
2839
- true
2840
- ensure
2841
- if $! or @warnings > 0 then
2842
- alert_warning "See http://guides.rubygems.org/specification-reference/ for help"
2843
- end
2652
+ validation_policy = Gem::SpecificationPolicy.new(self)
2653
+ validation_policy.packaging = packaging
2654
+ validation_policy.validate(strict)
2844
2655
  end
2845
2656
 
2846
- ##
2847
- # Checks that dependencies use requirements as we recommend. Warnings are
2848
- # issued when dependencies are open-ended or overly strict for semantic
2849
- # versioning.
2850
-
2851
- def validate_dependencies # :nodoc:
2852
- # NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
2853
- seen = Gem::Dependency::TYPES.inject({}) { |types, type| types.merge({ type => {}}) }
2854
-
2855
- error_messages = []
2856
- warning_messages = []
2857
- dependencies.each do |dep|
2858
- if prev = seen[dep.type][dep.name] then
2859
- error_messages << <<-MESSAGE
2860
- duplicate dependency on #{dep}, (#{prev.requirement}) use:
2861
- add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
2862
- MESSAGE
2863
- end
2864
-
2865
- seen[dep.type][dep.name] = dep
2866
-
2867
- prerelease_dep = dep.requirements_list.any? do |req|
2868
- Gem::Requirement.new(req).prerelease?
2869
- end
2870
-
2871
- warning_messages << "prerelease dependency on #{dep} is not recommended" if
2872
- prerelease_dep && !version.prerelease?
2873
-
2874
- overly_strict = dep.requirement.requirements.length == 1 &&
2875
- dep.requirement.requirements.any? do |op, version|
2876
- op == '~>' and
2877
- not version.prerelease? and
2878
- version.segments.length > 2 and
2879
- version.segments.first != 0
2880
- end
2881
-
2882
- if overly_strict then
2883
- _, dep_version = dep.requirement.requirements.first
2884
-
2885
- base = dep_version.segments.first 2
2886
-
2887
- warning_messages << <<-WARNING
2888
- pessimistic dependency on #{dep} may be overly strict
2889
- if #{dep.name} is semantically versioned, use:
2890
- add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}', '>= #{dep_version}'
2891
- WARNING
2892
- end
2893
-
2894
- open_ended = dep.requirement.requirements.all? do |op, version|
2895
- not version.prerelease? and (op == '>' or op == '>=')
2896
- end
2897
-
2898
- if open_ended then
2899
- op, dep_version = dep.requirement.requirements.first
2900
-
2901
- base = dep_version.segments.first 2
2902
-
2903
- bugfix = if op == '>' then
2904
- ", '> #{dep_version}'"
2905
- elsif op == '>=' and base != dep_version.segments then
2906
- ", '>= #{dep_version}'"
2907
- end
2657
+ def keep_only_files_and_directories
2658
+ @executables.delete_if {|x| File.directory?(File.join(@bindir, x)) }
2659
+ @extensions.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2660
+ @extra_rdoc_files.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2661
+ @files.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2662
+ @test_files.delete_if {|x| File.directory?(x) && !File.symlink?(x) }
2663
+ end
2908
2664
 
2909
- warning_messages << <<-WARNING
2910
- open-ended dependency on #{dep} is not recommended
2911
- if #{dep.name} is semantically versioned, use:
2912
- add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}
2913
- WARNING
2914
- end
2915
- end
2916
- if error_messages.any?
2917
- raise Gem::InvalidSpecificationException, error_messages.join
2918
- end
2919
- if warning_messages.any?
2920
- warning_messages.each { |warning_message| warning warning_message }
2921
- end
2665
+ def validate_metadata
2666
+ Gem::SpecificationPolicy.new(self).validate_metadata
2922
2667
  end
2668
+ rubygems_deprecate :validate_metadata
2923
2669
 
2924
- ##
2925
- # Checks to see if the files to be packaged are world-readable.
2670
+ def validate_dependencies
2671
+ Gem::SpecificationPolicy.new(self).validate_dependencies
2672
+ end
2673
+ rubygems_deprecate :validate_dependencies
2926
2674
 
2927
2675
  def validate_permissions
2928
- return if Gem.win_platform?
2929
-
2930
- files.each do |file|
2931
- next unless File.file?(file)
2932
- next if File.stat(file).mode & 0444 == 0444
2933
- warning "#{file} is not world-readable"
2934
- end
2935
-
2936
- executables.each do |name|
2937
- exec = File.join @bindir, name
2938
- next unless File.file?(exec)
2939
- next if File.stat(exec).executable?
2940
- warning "#{exec} is not executable"
2941
- end
2676
+ Gem::SpecificationPolicy.new(self).validate_permissions
2942
2677
  end
2678
+ rubygems_deprecate :validate_permissions
2943
2679
 
2944
2680
  ##
2945
2681
  # Set the version to +version+, potentially also setting
2946
2682
  # required_rubygems_version if +version+ indicates it is a
2947
2683
  # prerelease.
2948
2684
 
2949
- def version= version
2685
+ def version=(version)
2950
2686
  @version = Gem::Version.create(version)
2951
- self.required_rubygems_version = '> 1.3.1' if @version.prerelease?
2687
+ return if @version.nil?
2688
+
2689
+ # skip to set required_ruby_version when pre-released rubygems.
2690
+ # It caused to raise CircularDependencyError
2691
+ if @version.prerelease? && (@name.nil? || @name.strip != "rubygems")
2692
+ self.required_rubygems_version = "> 1.3.1"
2693
+ end
2952
2694
  invalidate_memoized_attributes
2953
2695
 
2954
- return @version
2696
+ @version
2955
2697
  end
2956
2698
 
2957
2699
  def stubbed?
@@ -2963,9 +2705,9 @@ open-ended dependency on #{dep} is not recommended
2963
2705
  case ivar
2964
2706
  when "date"
2965
2707
  # Force Date to go through the extra coerce logic in date=
2966
- self.date = val.untaint
2708
+ self.date = val.tap(&Gem::UNTAINT)
2967
2709
  else
2968
- instance_variable_set "@#{ivar}", val.untaint
2710
+ instance_variable_set "@#{ivar}", val.tap(&Gem::UNTAINT)
2969
2711
  end
2970
2712
  end
2971
2713
 
@@ -2985,37 +2727,26 @@ open-ended dependency on #{dep} is not recommended
2985
2727
  default = self.default_value attribute
2986
2728
 
2987
2729
  value = case default
2988
- when Time, Numeric, Symbol, true, false, nil then default
2989
- else default.dup
2990
- end
2730
+ when Time, Numeric, Symbol, true, false, nil then default
2731
+ else default.dup
2732
+ end
2991
2733
 
2992
2734
  instance_variable_set "@#{attribute}", value
2993
2735
  end
2994
2736
 
2995
2737
  @installed_by_version ||= nil
2738
+
2739
+ nil
2996
2740
  end
2997
2741
 
2998
- def warning statement # :nodoc:
2999
- @warnings += 1
2742
+ def flatten_require_paths # :nodoc:
2743
+ return unless raw_require_paths.first.is_a?(Array)
3000
2744
 
3001
- alert_warning statement
2745
+ warn "#{name} #{version} includes a gemspec with `require_paths` set to an array of arrays. Newer versions of this gem might've already fixed this"
2746
+ raw_require_paths.flatten!
3002
2747
  end
3003
2748
 
3004
2749
  def raw_require_paths # :nodoc:
3005
2750
  @require_paths
3006
2751
  end
3007
-
3008
- extend Gem::Deprecate
3009
-
3010
- # TODO:
3011
- # deprecate :has_rdoc, :none, 2011, 10
3012
- # deprecate :has_rdoc?, :none, 2011, 10
3013
- # deprecate :has_rdoc=, :none, 2011, 10
3014
- # deprecate :default_executable, :none, 2011, 10
3015
- # deprecate :default_executable=, :none, 2011, 10
3016
- # deprecate :file_name, :cache_file, 2011, 10
3017
- # deprecate :full_gem_path, :cache_file, 2011, 10
3018
2752
  end
3019
-
3020
- # DOC: What is this and why is it here, randomly, at the end of this file?
3021
- Gem.clear_paths