rubygems-update 2.7.11 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +67 -0
  3. data/.travis.yml +24 -18
  4. data/CODE_OF_CONDUCT.md +10 -8
  5. data/CONTRIBUTING.md +148 -0
  6. data/History.txt +458 -8
  7. data/MAINTAINERS.txt +1 -0
  8. data/Manifest.txt +16 -9
  9. data/POLICIES.md +92 -0
  10. data/README.md +53 -26
  11. data/Rakefile +77 -211
  12. data/{UPGRADING.rdoc → UPGRADING.md} +31 -32
  13. data/appveyor.yml +20 -45
  14. data/bin/gem +1 -2
  15. data/bin/update_rubygems +2 -3
  16. data/bundler/CHANGELOG.md +65 -0
  17. data/bundler/bundler.gemspec +7 -1
  18. data/bundler/lib/bundler/build_metadata.rb +1 -1
  19. data/bundler/lib/bundler/cli/add.rb +15 -5
  20. data/bundler/lib/bundler/cli/binstubs.rb +8 -2
  21. data/bundler/lib/bundler/cli/doctor.rb +47 -1
  22. data/bundler/lib/bundler/cli/install.rb +8 -5
  23. data/bundler/lib/bundler/cli/list.rb +41 -5
  24. data/bundler/lib/bundler/cli/outdated.rb +7 -1
  25. data/bundler/lib/bundler/cli/pristine.rb +4 -0
  26. data/bundler/lib/bundler/cli/remove.rb +18 -0
  27. data/bundler/lib/bundler/cli.rb +63 -21
  28. data/bundler/lib/bundler/definition.rb +15 -16
  29. data/bundler/lib/bundler/dependency.rb +2 -2
  30. data/bundler/lib/bundler/dsl.rb +19 -3
  31. data/bundler/lib/bundler/feature_flag.rb +7 -0
  32. data/bundler/lib/bundler/gem_version_promoter.rb +4 -2
  33. data/bundler/lib/bundler/injector.rb +168 -9
  34. data/bundler/lib/bundler/installer/parallel_installer.rb +5 -0
  35. data/bundler/lib/bundler/installer.rb +29 -6
  36. data/bundler/lib/bundler/plugin/events.rb +61 -0
  37. data/bundler/lib/bundler/plugin.rb +10 -3
  38. data/bundler/lib/bundler/resolver.rb +2 -2
  39. data/bundler/lib/bundler/rubygems_gem_installer.rb +7 -0
  40. data/bundler/lib/bundler/runtime.rb +8 -2
  41. data/bundler/lib/bundler/settings/validator.rb +23 -0
  42. data/bundler/lib/bundler/settings.rb +24 -3
  43. data/bundler/lib/bundler/shared_helpers.rb +19 -3
  44. data/bundler/lib/bundler/source/metadata.rb +2 -3
  45. data/bundler/lib/bundler/source.rb +9 -9
  46. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  47. data/bundler/lib/bundler/version.rb +1 -1
  48. data/bundler/lib/bundler.rb +26 -8
  49. data/bundler/man/bundle-add.ronn +13 -2
  50. data/bundler/man/bundle-config.ronn +21 -0
  51. data/bundler/man/bundle-install.ronn +1 -1
  52. data/bundler/man/bundle-list.ronn +19 -1
  53. data/bundler/man/bundle-outdated.ronn +4 -0
  54. data/bundler/man/bundle-remove.ronn +23 -0
  55. data/bundler/man/bundle-update.ronn +1 -1
  56. data/bundler/man/bundle.ronn +3 -0
  57. data/lib/rubygems/available_set.rb +1 -1
  58. data/lib/rubygems/basic_specification.rb +12 -12
  59. data/lib/rubygems/bundler_version_finder.rb +3 -3
  60. data/lib/rubygems/command.rb +22 -15
  61. data/lib/rubygems/command_manager.rb +22 -5
  62. data/lib/rubygems/commands/build_command.rb +41 -7
  63. data/lib/rubygems/commands/cert_command.rb +45 -24
  64. data/lib/rubygems/commands/check_command.rb +1 -1
  65. data/lib/rubygems/commands/cleanup_command.rb +14 -7
  66. data/lib/rubygems/commands/contents_command.rb +14 -15
  67. data/lib/rubygems/commands/dependency_command.rb +17 -17
  68. data/lib/rubygems/commands/environment_command.rb +20 -1
  69. data/lib/rubygems/commands/fetch_command.rb +2 -3
  70. data/lib/rubygems/commands/generate_index_command.rb +2 -3
  71. data/lib/rubygems/commands/help_command.rb +12 -13
  72. data/lib/rubygems/commands/info_command.rb +33 -0
  73. data/lib/rubygems/commands/install_command.rb +21 -17
  74. data/lib/rubygems/commands/list_command.rb +0 -1
  75. data/lib/rubygems/commands/lock_command.rb +3 -4
  76. data/lib/rubygems/commands/open_command.rb +16 -10
  77. data/lib/rubygems/commands/owner_command.rb +21 -7
  78. data/lib/rubygems/commands/pristine_command.rb +23 -16
  79. data/lib/rubygems/commands/push_command.rb +19 -8
  80. data/lib/rubygems/commands/query_command.rb +24 -24
  81. data/lib/rubygems/commands/rdoc_command.rb +3 -4
  82. data/lib/rubygems/commands/search_command.rb +0 -1
  83. data/lib/rubygems/commands/server_command.rb +1 -2
  84. data/lib/rubygems/commands/setup_command.rb +86 -48
  85. data/lib/rubygems/commands/signin_command.rb +2 -1
  86. data/lib/rubygems/commands/signout_command.rb +2 -2
  87. data/lib/rubygems/commands/sources_command.rb +11 -12
  88. data/lib/rubygems/commands/specification_command.rb +7 -7
  89. data/lib/rubygems/commands/uninstall_command.rb +50 -18
  90. data/lib/rubygems/commands/unpack_command.rb +16 -7
  91. data/lib/rubygems/commands/update_command.rb +28 -23
  92. data/lib/rubygems/commands/which_command.rb +5 -8
  93. data/lib/rubygems/commands/yank_command.rb +1 -2
  94. data/lib/rubygems/compatibility.rb +1 -21
  95. data/lib/rubygems/config_file.rb +36 -36
  96. data/lib/rubygems/core_ext/kernel_require.rb +6 -6
  97. data/lib/rubygems/core_ext/kernel_warn.rb +45 -0
  98. data/lib/rubygems/defaults.rb +31 -19
  99. data/lib/rubygems/dependency.rb +15 -15
  100. data/lib/rubygems/dependency_installer.rb +30 -33
  101. data/lib/rubygems/dependency_list.rb +9 -10
  102. data/lib/rubygems/deprecate.rb +2 -3
  103. data/lib/rubygems/doctor.rb +5 -6
  104. data/lib/rubygems/errors.rb +3 -3
  105. data/lib/rubygems/exceptions.rb +11 -8
  106. data/lib/rubygems/ext/build_error.rb +0 -1
  107. data/lib/rubygems/ext/builder.rb +50 -23
  108. data/lib/rubygems/ext/cmake_builder.rb +2 -2
  109. data/lib/rubygems/ext/configure_builder.rb +2 -3
  110. data/lib/rubygems/ext/ext_conf_builder.rb +8 -7
  111. data/lib/rubygems/ext/rake_builder.rb +16 -18
  112. data/lib/rubygems/ext.rb +0 -1
  113. data/lib/rubygems/gem_runner.rb +2 -2
  114. data/lib/rubygems/gemcutter_utilities.rb +46 -12
  115. data/lib/rubygems/indexer.rb +19 -12
  116. data/lib/rubygems/install_default_message.rb +0 -1
  117. data/lib/rubygems/install_message.rb +0 -1
  118. data/lib/rubygems/install_update_options.rb +3 -29
  119. data/lib/rubygems/installer.rb +97 -55
  120. data/lib/rubygems/installer_test_case.rb +2 -16
  121. data/lib/rubygems/local_remote_options.rb +5 -4
  122. data/lib/rubygems/mock_gem_ui.rb +3 -4
  123. data/lib/rubygems/name_tuple.rb +4 -4
  124. data/lib/rubygems/package/digest_io.rb +3 -4
  125. data/lib/rubygems/package/file_source.rb +3 -4
  126. data/lib/rubygems/package/io_source.rb +1 -2
  127. data/lib/rubygems/package/old.rb +8 -16
  128. data/lib/rubygems/package/source.rb +0 -1
  129. data/lib/rubygems/package/tar_header.rb +13 -4
  130. data/lib/rubygems/package/tar_reader/entry.rb +20 -4
  131. data/lib/rubygems/package/tar_reader.rb +2 -4
  132. data/lib/rubygems/package/tar_test_case.rb +2 -8
  133. data/lib/rubygems/package/tar_writer.rb +13 -15
  134. data/lib/rubygems/package.rb +90 -63
  135. data/lib/rubygems/package_task.rb +0 -1
  136. data/lib/rubygems/path_support.rb +16 -6
  137. data/lib/rubygems/platform.rb +4 -5
  138. data/lib/rubygems/psych_tree.rb +1 -1
  139. data/lib/rubygems/rdoc.rb +2 -313
  140. data/lib/rubygems/remote_fetcher.rb +29 -82
  141. data/lib/rubygems/request/connection_pools.rb +24 -13
  142. data/lib/rubygems/request/http_pool.rb +3 -4
  143. data/lib/rubygems/request/https_pool.rb +1 -3
  144. data/lib/rubygems/request.rb +17 -16
  145. data/lib/rubygems/request_set/gem_dependency_api.rb +46 -49
  146. data/lib/rubygems/request_set/lockfile/parser.rb +18 -29
  147. data/lib/rubygems/request_set/lockfile/tokenizer.rb +9 -9
  148. data/lib/rubygems/request_set/lockfile.rb +12 -12
  149. data/lib/rubygems/request_set.rb +52 -25
  150. data/lib/rubygems/requirement.rb +32 -21
  151. data/lib/rubygems/resolver/activation_request.rb +6 -6
  152. data/lib/rubygems/resolver/api_set.rb +5 -6
  153. data/lib/rubygems/resolver/api_specification.rb +2 -3
  154. data/lib/rubygems/resolver/best_set.rb +5 -6
  155. data/lib/rubygems/resolver/composed_set.rb +5 -6
  156. data/lib/rubygems/resolver/conflict.rb +5 -5
  157. data/lib/rubygems/resolver/current_set.rb +1 -2
  158. data/lib/rubygems/resolver/dependency_request.rb +4 -4
  159. data/lib/rubygems/resolver/git_set.rb +5 -6
  160. data/lib/rubygems/resolver/git_specification.rb +4 -5
  161. data/lib/rubygems/resolver/index_set.rb +5 -6
  162. data/lib/rubygems/resolver/index_specification.rb +3 -4
  163. data/lib/rubygems/resolver/installed_specification.rb +3 -4
  164. data/lib/rubygems/resolver/installer_set.rb +12 -12
  165. data/lib/rubygems/resolver/local_specification.rb +1 -2
  166. data/lib/rubygems/resolver/lock_set.rb +5 -6
  167. data/lib/rubygems/resolver/lock_specification.rb +7 -8
  168. data/lib/rubygems/resolver/requirement_list.rb +1 -1
  169. data/lib/rubygems/resolver/set.rb +2 -2
  170. data/lib/rubygems/resolver/source_set.rb +4 -5
  171. data/lib/rubygems/resolver/spec_specification.rb +1 -2
  172. data/lib/rubygems/resolver/specification.rb +10 -7
  173. data/lib/rubygems/resolver/stats.rb +1 -1
  174. data/lib/rubygems/resolver/vendor_set.rb +4 -5
  175. data/lib/rubygems/resolver/vendor_specification.rb +2 -3
  176. data/lib/rubygems/resolver.rb +14 -16
  177. data/lib/rubygems/s3_uri_signer.rb +183 -0
  178. data/lib/rubygems/safe_yaml.rb +18 -10
  179. data/lib/rubygems/security/policies.rb +1 -2
  180. data/lib/rubygems/security/policy.rb +25 -25
  181. data/lib/rubygems/security/signer.rb +72 -24
  182. data/lib/rubygems/security/trust_dir.rb +10 -10
  183. data/lib/rubygems/security.rb +21 -22
  184. data/lib/rubygems/security_option.rb +0 -1
  185. data/lib/rubygems/server.rb +21 -21
  186. data/lib/rubygems/source/git.rb +9 -10
  187. data/lib/rubygems/source/installed.rb +3 -4
  188. data/lib/rubygems/source/local.rb +7 -7
  189. data/lib/rubygems/source/lock.rb +4 -4
  190. data/lib/rubygems/source/specific_file.rb +5 -5
  191. data/lib/rubygems/source/vendor.rb +2 -3
  192. data/lib/rubygems/source.rb +16 -25
  193. data/lib/rubygems/source_list.rb +2 -2
  194. data/lib/rubygems/source_local.rb +0 -1
  195. data/lib/rubygems/spec_fetcher.rb +5 -6
  196. data/lib/rubygems/specification.rb +219 -558
  197. data/lib/rubygems/specification_policy.rb +407 -0
  198. data/lib/rubygems/stub_specification.rb +12 -17
  199. data/lib/rubygems/test_case.rb +161 -75
  200. data/lib/rubygems/test_utilities.rb +20 -35
  201. data/lib/rubygems/text.rb +6 -6
  202. data/lib/rubygems/uninstaller.rb +38 -27
  203. data/lib/rubygems/uri_formatter.rb +1 -2
  204. data/lib/rubygems/user_interaction.rb +37 -89
  205. data/lib/rubygems/util/licenses.rb +27 -1
  206. data/lib/rubygems/util/list.rb +1 -1
  207. data/lib/rubygems/util.rb +32 -14
  208. data/lib/rubygems/validator.rb +4 -5
  209. data/lib/rubygems/version.rb +15 -15
  210. data/lib/rubygems/version_option.rb +2 -3
  211. data/lib/rubygems.rb +71 -102
  212. data/rubygems-update.gemspec +43 -0
  213. data/setup.rb +2 -8
  214. data/test/rubygems/ca_cert.pem +74 -65
  215. data/test/rubygems/client.pem +103 -45
  216. data/test/rubygems/rubygems_plugin.rb +0 -1
  217. data/test/rubygems/simple_gem.rb +1 -1
  218. data/test/rubygems/ssl_cert.pem +78 -17
  219. data/test/rubygems/ssl_key.pem +25 -13
  220. data/test/rubygems/test_bundled_ca.rb +1 -1
  221. data/test/rubygems/test_config.rb +7 -2
  222. data/test/rubygems/test_gem.rb +205 -132
  223. data/test/rubygems/test_gem_bundler_version_finder.rb +4 -0
  224. data/test/rubygems/test_gem_command.rb +0 -1
  225. data/test/rubygems/test_gem_command_manager.rb +18 -3
  226. data/test/rubygems/test_gem_commands_build_command.rb +220 -15
  227. data/test/rubygems/test_gem_commands_cert_command.rb +69 -8
  228. data/test/rubygems/test_gem_commands_check_command.rb +1 -1
  229. data/test/rubygems/test_gem_commands_cleanup_command.rb +27 -1
  230. data/test/rubygems/test_gem_commands_contents_command.rb +1 -2
  231. data/test/rubygems/test_gem_commands_dependency_command.rb +33 -34
  232. data/test/rubygems/test_gem_commands_environment_command.rb +1 -0
  233. data/test/rubygems/test_gem_commands_fetch_command.rb +0 -1
  234. data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -1
  235. data/test/rubygems/test_gem_commands_help_command.rb +7 -4
  236. data/test/rubygems/test_gem_commands_info_command.rb +44 -0
  237. data/test/rubygems/test_gem_commands_install_command.rb +79 -12
  238. data/test/rubygems/test_gem_commands_lock_command.rb +0 -1
  239. data/test/rubygems/test_gem_commands_open_command.rb +29 -0
  240. data/test/rubygems/test_gem_commands_outdated_command.rb +0 -1
  241. data/test/rubygems/test_gem_commands_owner_command.rb +93 -57
  242. data/test/rubygems/test_gem_commands_pristine_command.rb +65 -30
  243. data/test/rubygems/test_gem_commands_push_command.rb +54 -0
  244. data/test/rubygems/test_gem_commands_query_command.rb +102 -100
  245. data/test/rubygems/test_gem_commands_search_command.rb +0 -1
  246. data/test/rubygems/test_gem_commands_server_command.rb +0 -1
  247. data/test/rubygems/test_gem_commands_setup_command.rb +50 -15
  248. data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
  249. data/test/rubygems/test_gem_commands_sources_command.rb +0 -1
  250. data/test/rubygems/test_gem_commands_specification_command.rb +2 -3
  251. data/test/rubygems/test_gem_commands_stale_command.rb +3 -2
  252. data/test/rubygems/test_gem_commands_uninstall_command.rb +161 -8
  253. data/test/rubygems/test_gem_commands_unpack_command.rb +17 -1
  254. data/test/rubygems/test_gem_commands_update_command.rb +19 -2
  255. data/test/rubygems/test_gem_commands_which_command.rb +0 -1
  256. data/test/rubygems/test_gem_commands_yank_command.rb +0 -1
  257. data/test/rubygems/test_gem_config_file.rb +4 -2
  258. data/test/rubygems/test_gem_dependency.rb +0 -1
  259. data/test/rubygems/test_gem_dependency_installer.rb +8 -5
  260. data/test/rubygems/test_gem_dependency_list.rb +6 -7
  261. data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -1
  262. data/test/rubygems/test_gem_doctor.rb +1 -2
  263. data/test/rubygems/test_gem_ext_builder.rb +10 -23
  264. data/test/rubygems/test_gem_ext_cmake_builder.rb +5 -4
  265. data/test/rubygems/test_gem_ext_configure_builder.rb +3 -3
  266. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +8 -9
  267. data/test/rubygems/test_gem_ext_rake_builder.rb +20 -5
  268. data/test/rubygems/test_gem_gem_runner.rb +0 -1
  269. data/test/rubygems/test_gem_gemcutter_utilities.rb +32 -6
  270. data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -1
  271. data/test/rubygems/test_gem_indexer.rb +16 -10
  272. data/test/rubygems/test_gem_install_update_options.rb +1 -20
  273. data/test/rubygems/test_gem_installer.rb +154 -119
  274. data/test/rubygems/test_gem_local_remote_options.rb +3 -3
  275. data/test/rubygems/test_gem_name_tuple.rb +0 -1
  276. data/test/rubygems/test_gem_package.rb +77 -31
  277. data/test/rubygems/test_gem_package_old.rb +0 -1
  278. data/test/rubygems/test_gem_package_tar_header.rb +42 -2
  279. data/test/rubygems/test_gem_package_tar_reader.rb +0 -1
  280. data/test/rubygems/test_gem_package_tar_reader_entry.rb +11 -0
  281. data/test/rubygems/test_gem_package_tar_writer.rb +43 -7
  282. data/test/rubygems/test_gem_package_task.rb +2 -2
  283. data/test/rubygems/test_gem_path_support.rb +28 -11
  284. data/test/rubygems/test_gem_platform.rb +4 -5
  285. data/test/rubygems/test_gem_rdoc.rb +1 -136
  286. data/test/rubygems/test_gem_remote_fetcher.rb +241 -141
  287. data/test/rubygems/test_gem_request.rb +9 -9
  288. data/test/rubygems/test_gem_request_connection_pools.rb +24 -3
  289. data/test/rubygems/test_gem_request_set.rb +5 -5
  290. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +82 -64
  291. data/test/rubygems/test_gem_request_set_lockfile.rb +1 -2
  292. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +4 -9
  293. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
  294. data/test/rubygems/test_gem_requirement.rb +24 -4
  295. data/test/rubygems/test_gem_resolver.rb +13 -17
  296. data/test/rubygems/test_gem_resolver_activation_request.rb +0 -1
  297. data/test/rubygems/test_gem_resolver_api_set.rb +0 -1
  298. data/test/rubygems/test_gem_resolver_api_specification.rb +0 -1
  299. data/test/rubygems/test_gem_resolver_best_set.rb +0 -1
  300. data/test/rubygems/test_gem_resolver_composed_set.rb +0 -1
  301. data/test/rubygems/test_gem_resolver_conflict.rb +0 -1
  302. data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -1
  303. data/test/rubygems/test_gem_resolver_git_set.rb +0 -1
  304. data/test/rubygems/test_gem_resolver_git_specification.rb +0 -1
  305. data/test/rubygems/test_gem_resolver_index_set.rb +0 -1
  306. data/test/rubygems/test_gem_resolver_index_specification.rb +0 -1
  307. data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -1
  308. data/test/rubygems/test_gem_resolver_installer_set.rb +2 -3
  309. data/test/rubygems/test_gem_resolver_local_specification.rb +0 -1
  310. data/test/rubygems/test_gem_resolver_lock_set.rb +0 -1
  311. data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -1
  312. data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -1
  313. data/test/rubygems/test_gem_resolver_specification.rb +1 -2
  314. data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -1
  315. data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -1
  316. data/test/rubygems/test_gem_security.rb +1 -3
  317. data/test/rubygems/test_gem_security_policy.rb +5 -6
  318. data/test/rubygems/test_gem_security_signer.rb +4 -3
  319. data/test/rubygems/test_gem_security_trust_dir.rb +1 -2
  320. data/test/rubygems/test_gem_server.rb +4 -4
  321. data/test/rubygems/test_gem_source.rb +0 -13
  322. data/test/rubygems/test_gem_source_fetch_problem.rb +0 -1
  323. data/test/rubygems/test_gem_source_git.rb +0 -1
  324. data/test/rubygems/test_gem_source_installed.rb +0 -1
  325. data/test/rubygems/test_gem_source_lock.rb +0 -1
  326. data/test/rubygems/test_gem_source_vendor.rb +0 -1
  327. data/test/rubygems/test_gem_spec_fetcher.rb +0 -1
  328. data/test/rubygems/test_gem_specification.rb +366 -198
  329. data/test/rubygems/test_gem_stream_ui.rb +15 -32
  330. data/test/rubygems/test_gem_stub_specification.rb +0 -2
  331. data/test/rubygems/test_gem_text.rb +4 -0
  332. data/test/rubygems/test_gem_uninstaller.rb +42 -3
  333. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -1
  334. data/test/rubygems/test_gem_uri_formatter.rb +0 -1
  335. data/test/rubygems/test_gem_util.rb +31 -11
  336. data/test/rubygems/test_gem_validator.rb +0 -1
  337. data/test/rubygems/test_gem_version.rb +11 -11
  338. data/test/rubygems/test_gem_version_option.rb +0 -1
  339. data/test/rubygems/test_remote_fetch_error.rb +0 -1
  340. data/test/rubygems/test_require.rb +67 -52
  341. data/util/CL2notes +1 -2
  342. data/util/ci +20 -12
  343. data/util/cops/deprecations.rb +52 -0
  344. data/util/create_certs.rb +6 -7
  345. data/util/create_certs.sh +27 -0
  346. data/util/create_encrypted_key.rb +4 -5
  347. data/util/patch_with_prs.rb +1 -1
  348. data/util/rubocop +8 -0
  349. data/util/update_bundled_ca_certificates.rb +12 -13
  350. data/util/update_changelog.rb +1 -1
  351. metadata +61 -51
  352. data/.autotest +0 -71
  353. data/.document +0 -5
  354. data/CONTRIBUTING.rdoc +0 -130
  355. data/CVE-2013-4287.txt +0 -35
  356. data/CVE-2013-4363.txt +0 -45
  357. data/CVE-2015-3900.txt +0 -40
  358. data/POLICIES.rdoc +0 -74
  359. data/test/rubygems/fix_openssl_warnings.rb +0 -13
@@ -1,5 +1,5 @@
1
- # -*- coding: utf-8 -*-
2
1
  # frozen_string_literal: true
2
+ # -*- coding: utf-8 -*-
3
3
  #--
4
4
  # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
5
5
  # All rights reserved.
@@ -13,12 +13,12 @@ require 'rubygems/platform'
13
13
  require 'rubygems/deprecate'
14
14
  require 'rubygems/basic_specification'
15
15
  require 'rubygems/stub_specification'
16
+ require 'rubygems/specification_policy'
16
17
  require 'rubygems/util/list'
17
18
  require 'stringio'
18
- require 'uri'
19
19
 
20
20
  ##
21
- # The Specification class contains the information for a Gem. Typically
21
+ # The Specification class contains the information for a gem. Typically
22
22
  # defined in a .gemspec file or a Rakefile, and looks like this:
23
23
  #
24
24
  # Gem::Specification.new do |s|
@@ -89,13 +89,13 @@ class Gem::Specification < Gem::BasicSpecification
89
89
  'Added "required_rubygems_version"',
90
90
  'Now forward-compatible with future versions',
91
91
  ],
92
- 3 => [
93
- 'Added Fixnum validation to the specification_version'
92
+ 3 => [
93
+ 'Added Fixnum validation to the specification_version'
94
94
  ],
95
- 4 => [
95
+ 4 => [
96
96
  'Added sandboxed freeform metadata to the specification version.'
97
97
  ]
98
- }
98
+ }.freeze
99
99
 
100
100
  MARSHAL_FIELDS = { # :nodoc:
101
101
  -1 => 16,
@@ -103,16 +103,18 @@ class Gem::Specification < Gem::BasicSpecification
103
103
  2 => 16,
104
104
  3 => 17,
105
105
  4 => 18,
106
- }
106
+ }.freeze
107
107
 
108
108
  today = Time.now.utc
109
109
  TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
110
110
 
111
+ # rubocop:disable Style/MutableConstant
111
112
  LOAD_CACHE = {} # :nodoc:
113
+ # rubocop:enable Style/MutableConstant
112
114
 
113
115
  private_constant :LOAD_CACHE if defined? private_constant
114
116
 
115
- VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:
117
+ VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
116
118
 
117
119
  # :startdoc:
118
120
 
@@ -135,7 +137,7 @@ class Gem::Specification < Gem::BasicSpecification
135
137
  :autorequire => nil,
136
138
  :bindir => 'bin',
137
139
  :cert_chain => [],
138
- :date => TODAY,
140
+ :date => nil,
139
141
  :dependencies => [],
140
142
  :description => nil,
141
143
  :email => nil,
@@ -154,7 +156,6 @@ class Gem::Specification < Gem::BasicSpecification
154
156
  :required_ruby_version => Gem::Requirement.default,
155
157
  :required_rubygems_version => Gem::Requirement.default,
156
158
  :requirements => [],
157
- :rubyforge_project => nil,
158
159
  :rubygems_version => Gem::VERSION,
159
160
  :signing_key => nil,
160
161
  :specification_version => CURRENT_SPECIFICATION_VERSION,
@@ -163,19 +164,21 @@ class Gem::Specification < Gem::BasicSpecification
163
164
  :version => nil,
164
165
  }.freeze
165
166
 
167
+ # rubocop:disable Style/MutableConstant
166
168
  INITIALIZE_CODE_FOR_DEFAULTS = { } # :nodoc:
169
+ # rubocop:enable Style/MutableConstant
167
170
 
168
171
  @@default_value.each do |k,v|
169
172
  INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
170
- when [], {}, true, false, nil, Numeric, Symbol
171
- v.inspect
172
- when String
173
- v.dump
174
- when Numeric
175
- "default_value(:#{k})"
176
- else
177
- "default_value(:#{k}).dup"
178
- end
173
+ when [], {}, true, false, nil, Numeric, Symbol
174
+ v.inspect
175
+ when String
176
+ v.dump
177
+ when Numeric
178
+ "default_value(:#{k})"
179
+ else
180
+ "default_value(:#{k}).dup"
181
+ end
179
182
  end
180
183
 
181
184
  @@attributes = @@default_value.keys.sort_by { |s| s.to_s }
@@ -260,31 +263,23 @@ class Gem::Specification < Gem::BasicSpecification
260
263
  ].flatten.compact.uniq.sort
261
264
  end
262
265
 
263
- ######################################################################
264
- # :section: Recommended gemspec attributes
265
-
266
266
  ##
267
- # Singular writer for #authors
267
+ # A list of authors for this gem.
268
268
  #
269
- # Usage:
270
- #
271
- # spec.author = 'John Jones'
272
-
273
- def author= o
274
- self.authors = [o]
275
- end
276
-
277
- ##
278
- # Sets the list of authors, ensuring it is an array.
269
+ # Alternatively, a single author can be specified by assigning a string to
270
+ # `spec.author`
279
271
  #
280
272
  # Usage:
281
273
  #
282
274
  # spec.authors = ['John Jones', 'Mary Smith']
283
275
 
284
- def authors= value
276
+ def authors=(value)
285
277
  @authors = Array(value).flatten.grep(String)
286
278
  end
287
279
 
280
+ ######################################################################
281
+ # :section: Recommended gemspec attributes
282
+
288
283
  ##
289
284
  # A long description of this gem
290
285
  #
@@ -346,7 +341,7 @@ class Gem::Specification < Gem::BasicSpecification
346
341
  # Usage:
347
342
  # spec.license = 'MIT'
348
343
 
349
- def license=o
344
+ def license=(o)
350
345
  self.licenses = [o]
351
346
  end
352
347
 
@@ -363,14 +358,13 @@ class Gem::Specification < Gem::BasicSpecification
363
358
  # Usage:
364
359
  # spec.licenses = ['MIT', 'GPL-2.0']
365
360
 
366
- def licenses= licenses
361
+ def licenses=(licenses)
367
362
  @licenses = Array licenses
368
363
  end
369
364
 
370
365
  ##
371
366
  # The metadata holds extra data for this gem that may be useful to other
372
- # consumers and is settable by gem authors without requiring an update to
373
- # the rubygems software.
367
+ # consumers and is settable by gem authors.
374
368
  #
375
369
  # Metadata items have the following restrictions:
376
370
  #
@@ -403,6 +397,17 @@ class Gem::Specification < Gem::BasicSpecification
403
397
  ######################################################################
404
398
  # :section: Optional gemspec attributes
405
399
 
400
+ ##
401
+ # Singular (alternative) writer for #authors
402
+ #
403
+ # Usage:
404
+ #
405
+ # spec.author = 'John Jones'
406
+
407
+ def author=(o)
408
+ self.authors = [o]
409
+ end
410
+
406
411
  ##
407
412
  # The path in the gem for executable scripts. Usually 'bin'
408
413
  #
@@ -450,9 +455,9 @@ class Gem::Specification < Gem::BasicSpecification
450
455
  #
451
456
  # spec.platform = Gem::Platform.local
452
457
 
453
- def platform= platform
458
+ def platform=(platform)
454
459
  if @original_platform.nil? or
455
- @original_platform == Gem::Platform::RUBY then
460
+ @original_platform == Gem::Platform::RUBY
456
461
  @original_platform = platform
457
462
  end
458
463
 
@@ -618,7 +623,7 @@ class Gem::Specification < Gem::BasicSpecification
618
623
  # Sets the version of RubyGems that installed this gem. See also
619
624
  # #installed_by_version.
620
625
 
621
- def installed_by_version= version # :nodoc:
626
+ def installed_by_version=(version) # :nodoc:
622
627
  @installed_by_version = Gem::Version.new version
623
628
  end
624
629
 
@@ -643,29 +648,27 @@ class Gem::Specification < Gem::BasicSpecification
643
648
  # ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
644
649
  # #<Gem::Version "2.0.0.247">
645
650
  #
646
- # Because patch-level is taken into account, be very careful specifying using
647
- # `<=`: `<= 2.2.2` will not match any patch-level of 2.2.2 after the `p0`
648
- # release. It is much safer to specify `< 2.2.3` instead
651
+ # Prereleases can also be specified.
649
652
  #
650
653
  # Usage:
651
654
  #
652
655
  # # This gem will work with 1.8.6 or greater...
653
656
  # spec.required_ruby_version = '>= 1.8.6'
654
657
  #
655
- # # Only with ruby 2.0.x
656
- # spec.required_ruby_version = '~> 2.0'
658
+ # # Only with final releases of major version 2 where minor version is at least 3
659
+ # spec.required_ruby_version = '~> 2.3'
657
660
  #
658
- # # Only with ruby between 2.2.0 and 2.2.2
659
- # spec.required_ruby_version = ['>= 2.2.0', '< 2.2.3']
661
+ # # Only prereleases or final releases after 2.6.0.preview2
662
+ # spec.required_ruby_version = '> 2.6.0.preview2'
660
663
 
661
- def required_ruby_version= req
664
+ def required_ruby_version=(req)
662
665
  @required_ruby_version = Gem::Requirement.create req
663
666
  end
664
667
 
665
668
  ##
666
669
  # The RubyGems version required by this gem
667
670
 
668
- def required_rubygems_version= req
671
+ def required_rubygems_version=(req)
669
672
  @required_rubygems_version = Gem::Requirement.create req
670
673
  end
671
674
 
@@ -690,7 +693,7 @@ class Gem::Specification < Gem::BasicSpecification
690
693
  # spec.test_files = Dir.glob('test/tc_*.rb')
691
694
  # spec.test_files = ['tests/test-suite.rb']
692
695
 
693
- def test_files= files # :nodoc:
696
+ def test_files=(files) # :nodoc:
694
697
  @test_files = Array files
695
698
  end
696
699
 
@@ -725,12 +728,11 @@ class Gem::Specification < Gem::BasicSpecification
725
728
  attr_writer :original_platform # :nodoc:
726
729
 
727
730
  ##
728
- # The rubyforge project this gem lives under. i.e. RubyGems'
729
- # rubyforge_project is "rubygems".
731
+ # Deprecated and ignored.
730
732
  #
731
- # This option is deprecated.
733
+ # Formerly used to set rubyforge project.
732
734
 
733
- attr_accessor :rubyforge_project
735
+ attr_writer :rubyforge_project
734
736
 
735
737
  ##
736
738
  # The Gem::Specification version of this gemspec.
@@ -740,11 +742,8 @@ class Gem::Specification < Gem::BasicSpecification
740
742
  attr_accessor :specification_version
741
743
 
742
744
  def self._all # :nodoc:
743
- unless defined?(@@all) && @@all then
745
+ unless defined?(@@all) && @@all
744
746
  @@all = stubs.map(&:to_spec)
745
- if @@all.any?(&:nil?) # TODO: remove once we're happy
746
- raise "pid: #{$$} nil spec! included in #{stubs.inspect}"
747
- end
748
747
 
749
748
  # After a reset, make sure already loaded specs
750
749
  # are still marked as activated.
@@ -761,18 +760,18 @@ class Gem::Specification < Gem::BasicSpecification
761
760
 
762
761
  def self.each_gemspec(dirs) # :nodoc:
763
762
  dirs.each do |dir|
764
- Dir[File.join(dir, "*.gemspec")].each do |path|
763
+ Gem::Util.glob_files_in_dir("*.gemspec", dir).each do |path|
765
764
  yield path.untaint
766
765
  end
767
766
  end
768
767
  end
769
768
 
770
- def self.gemspec_stubs_in dir, pattern
771
- Dir[File.join(dir, pattern)].map { |path| yield path }.select(&:valid?)
769
+ def self.gemspec_stubs_in(dir, pattern)
770
+ Gem::Util.glob_files_in_dir(pattern, dir).map { |path| yield path }.select(&:valid?)
772
771
  end
773
772
  private_class_method :gemspec_stubs_in
774
773
 
775
- def self.default_stubs pattern
774
+ def self.default_stubs(pattern)
776
775
  base_dir = Gem.default_dir
777
776
  gems_dir = File.join base_dir, "gems"
778
777
  gemspec_stubs_in(default_specifications_dir, pattern) do |path|
@@ -781,59 +780,29 @@ class Gem::Specification < Gem::BasicSpecification
781
780
  end
782
781
  private_class_method :default_stubs
783
782
 
784
- def self.installed_stubs dirs, pattern
783
+ def self.installed_stubs(dirs, pattern)
785
784
  map_stubs(dirs, pattern) do |path, base_dir, gems_dir|
786
785
  Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir)
787
786
  end
788
787
  end
789
788
  private_class_method :installed_stubs
790
789
 
791
- if [].respond_to? :flat_map
792
- def self.map_stubs(dirs, pattern) # :nodoc:
793
- dirs.flat_map { |dir|
794
- base_dir = File.dirname dir
795
- gems_dir = File.join base_dir, "gems"
796
- gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
797
- }
798
- end
799
- else # FIXME: remove when 1.8 is dropped
800
- def self.map_stubs(dirs, pattern) # :nodoc:
801
- dirs.map { |dir|
802
- base_dir = File.dirname dir
803
- gems_dir = File.join base_dir, "gems"
804
- gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
805
- }.flatten 1
806
- end
790
+ def self.map_stubs(dirs, pattern) # :nodoc:
791
+ dirs.flat_map { |dir|
792
+ base_dir = File.dirname dir
793
+ gems_dir = File.join base_dir, "gems"
794
+ gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
795
+ }
807
796
  end
808
797
  private_class_method :map_stubs
809
798
 
810
- uniq_takes_a_block = false
811
- [1,2].uniq { uniq_takes_a_block = true }
812
-
813
- if uniq_takes_a_block
814
- def self.uniq_by(list, &block) # :nodoc:
815
- list.uniq(&block)
816
- end
817
- else # FIXME: remove when 1.8 is dropped
818
- def self.uniq_by(list) # :nodoc:
819
- values = {}
820
- list.each { |item|
821
- value = yield item
822
- values[value] ||= item
823
- }
824
- values.values
825
- end
799
+ def self.uniq_by(list, &block) # :nodoc:
800
+ list.uniq(&block)
826
801
  end
827
802
  private_class_method :uniq_by
828
803
 
829
- if [].respond_to? :sort_by!
830
- def self.sort_by! list, &block
831
- list.sort_by!(&block)
832
- end
833
- else # FIXME: remove when 1.8 is dropped
834
- def self.sort_by! list, &block
835
- list.replace list.sort_by(&block)
836
- end
804
+ def self.sort_by!(list, &block)
805
+ list.sort_by!(&block)
837
806
  end
838
807
  private_class_method :sort_by!
839
808
 
@@ -850,11 +819,11 @@ class Gem::Specification < Gem::BasicSpecification
850
819
  def self.stubs
851
820
  @@stubs ||= begin
852
821
  pattern = "*.gemspec"
853
- stubs = default_stubs(pattern).concat installed_stubs(dirs, pattern)
822
+ stubs = Gem.loaded_specs.values + default_stubs(pattern) + installed_stubs(dirs, pattern)
854
823
  stubs = uniq_by(stubs) { |stub| stub.full_name }
855
824
 
856
825
  _resort!(stubs)
857
- @@stubs_by_name = stubs.group_by(&:name)
826
+ @@stubs_by_name = stubs.select { |s| Gem::Platform.match s.platform }.group_by(&:name)
858
827
  stubs
859
828
  end
860
829
  end
@@ -863,13 +832,15 @@ class Gem::Specification < Gem::BasicSpecification
863
832
 
864
833
  ##
865
834
  # Returns a Gem::StubSpecification for installed gem named +name+
835
+ # only returns stubs that match Gem.platforms
866
836
 
867
- def self.stubs_for name
837
+ def self.stubs_for(name)
868
838
  if @@stubs
869
839
  @@stubs_by_name[name] || []
870
840
  else
871
841
  pattern = "#{name}-*.gemspec"
872
- stubs = default_stubs(pattern) + installed_stubs(dirs, pattern)
842
+ stubs = Gem.loaded_specs.values + default_stubs(pattern) +
843
+ installed_stubs(dirs, pattern).select { |s| Gem::Platform.match s.platform }
873
844
  stubs = uniq_by(stubs) { |stub| stub.full_name }.group_by(&:name)
874
845
  stubs.each_value { |v| _resort!(v) }
875
846
 
@@ -901,7 +872,7 @@ class Gem::Specification < Gem::BasicSpecification
901
872
  # Adds +spec+ to the known specifications, keeping the collection
902
873
  # properly sorted.
903
874
 
904
- def self.add_spec spec
875
+ def self.add_spec(spec)
905
876
  warn "Gem::Specification.add_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
906
877
  # TODO: find all extraneous adds
907
878
  # puts
@@ -926,7 +897,7 @@ class Gem::Specification < Gem::BasicSpecification
926
897
  ##
927
898
  # Adds multiple specs to the known specifications.
928
899
 
929
- def self.add_specs *specs
900
+ def self.add_specs(*specs)
930
901
  warn "Gem::Specification.add_specs is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
931
902
 
932
903
  raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
@@ -964,8 +935,7 @@ class Gem::Specification < Gem::BasicSpecification
964
935
  #
965
936
  # -- wilsonb
966
937
 
967
- def self.all= specs
968
- raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
938
+ def self.all=(specs)
969
939
  @@stubs_by_name = specs.group_by(&:name)
970
940
  @@all = @@stubs = specs
971
941
  end
@@ -1008,7 +978,7 @@ class Gem::Specification < Gem::BasicSpecification
1008
978
  # Set the directories that Specification uses to find specs. Setting
1009
979
  # this resets the list of known specs.
1010
980
 
1011
- def self.dirs= dirs
981
+ def self.dirs=(dirs)
1012
982
  self.reset
1013
983
 
1014
984
  @@dirs = Array(dirs).map { |dir| File.join dir, "specifications" }
@@ -1031,7 +1001,7 @@ class Gem::Specification < Gem::BasicSpecification
1031
1001
  ##
1032
1002
  # Returns every spec that matches +name+ and optional +requirements+.
1033
1003
 
1034
- def self.find_all_by_name name, *requirements
1004
+ def self.find_all_by_name(name, *requirements)
1035
1005
  requirements = Gem::Requirement.default if requirements.empty?
1036
1006
 
1037
1007
  # TODO: maybe try: find_all { |s| spec === dep }
@@ -1050,7 +1020,7 @@ class Gem::Specification < Gem::BasicSpecification
1050
1020
  # Find the best specification matching a +name+ and +requirements+. Raises
1051
1021
  # if the dependency doesn't resolve to a valid specification.
1052
1022
 
1053
- def self.find_by_name name, *requirements
1023
+ def self.find_by_name(name, *requirements)
1054
1024
  requirements = Gem::Requirement.default if requirements.empty?
1055
1025
 
1056
1026
  # TODO: maybe try: find { |s| spec === dep }
@@ -1061,7 +1031,7 @@ class Gem::Specification < Gem::BasicSpecification
1061
1031
  ##
1062
1032
  # Return the best specification that contains the file matching +path+.
1063
1033
 
1064
- def self.find_by_path path
1034
+ def self.find_by_path(path)
1065
1035
  path = path.dup.freeze
1066
1036
  spec = @@spec_with_requirable_file[path] ||= (stubs.find { |s|
1067
1037
  next unless Gem::BundlerVersionFinder.compatible?(s)
@@ -1074,7 +1044,7 @@ class Gem::Specification < Gem::BasicSpecification
1074
1044
  # Return the best specification that contains the file matching +path+
1075
1045
  # amongst the specs that are not activated.
1076
1046
 
1077
- def self.find_inactive_by_path path
1047
+ def self.find_inactive_by_path(path)
1078
1048
  stub = stubs.find { |s|
1079
1049
  next if s.activated?
1080
1050
  next unless Gem::BundlerVersionFinder.compatible?(s)
@@ -1083,7 +1053,7 @@ class Gem::Specification < Gem::BasicSpecification
1083
1053
  stub && stub.to_spec
1084
1054
  end
1085
1055
 
1086
- def self.find_active_stub_by_path path
1056
+ def self.find_active_stub_by_path(path)
1087
1057
  stub = @@active_stub_with_requirable_file[path] ||= (stubs.find { |s|
1088
1058
  s.activated? and s.contains_requirable_file? path
1089
1059
  } || NOT_FOUND)
@@ -1093,7 +1063,7 @@ class Gem::Specification < Gem::BasicSpecification
1093
1063
  ##
1094
1064
  # Return currently unresolved specs that contain the file matching +path+.
1095
1065
 
1096
- def self.find_in_unresolved path
1066
+ def self.find_in_unresolved(path)
1097
1067
  # TODO: do we need these?? Kill it
1098
1068
  specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
1099
1069
 
@@ -1104,7 +1074,7 @@ class Gem::Specification < Gem::BasicSpecification
1104
1074
  # Search through all unresolved deps and sub-dependencies and return
1105
1075
  # specs that contain the file matching +path+.
1106
1076
 
1107
- def self.find_in_unresolved_tree path
1077
+ def self.find_in_unresolved_tree(path)
1108
1078
  specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
1109
1079
 
1110
1080
  specs.each do |spec|
@@ -1134,11 +1104,11 @@ class Gem::Specification < Gem::BasicSpecification
1134
1104
  input = normalize_yaml_input input
1135
1105
  spec = Gem::SafeYAML.safe_load input
1136
1106
 
1137
- if spec && spec.class == FalseClass then
1107
+ if spec && spec.class == FalseClass
1138
1108
  raise Gem::EndOfYAMLException
1139
1109
  end
1140
1110
 
1141
- unless Gem::Specification === spec then
1111
+ unless Gem::Specification === spec
1142
1112
  raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
1143
1113
  end
1144
1114
 
@@ -1152,11 +1122,11 @@ class Gem::Specification < Gem::BasicSpecification
1152
1122
  # Return the latest specs, optionally including prerelease specs if
1153
1123
  # +prerelease+ is true.
1154
1124
 
1155
- def self.latest_specs prerelease = false
1125
+ def self.latest_specs(prerelease = false)
1156
1126
  _latest_specs Gem::Specification._all, prerelease
1157
1127
  end
1158
1128
 
1159
- def self._latest_specs specs, prerelease = false # :nodoc:
1129
+ def self._latest_specs(specs, prerelease = false) # :nodoc:
1160
1130
  result = Hash.new { |h,k| h[k] = {} }
1161
1131
  native = {}
1162
1132
 
@@ -1176,7 +1146,7 @@ class Gem::Specification < Gem::BasicSpecification
1176
1146
  ##
1177
1147
  # Loads Ruby format gemspec from +file+.
1178
1148
 
1179
- def self.load file
1149
+ def self.load(file)
1180
1150
  return unless file
1181
1151
 
1182
1152
  _spec = LOAD_CACHE[file]
@@ -1185,11 +1155,7 @@ class Gem::Specification < Gem::BasicSpecification
1185
1155
  file = file.dup.untaint
1186
1156
  return unless File.file?(file)
1187
1157
 
1188
- code = if defined? Encoding
1189
- File.read file, :mode => 'r:UTF-8:-'
1190
- else
1191
- File.read file
1192
- end
1158
+ code = File.read file, :mode => 'r:UTF-8:-'
1193
1159
 
1194
1160
  code.untaint
1195
1161
 
@@ -1276,7 +1242,7 @@ class Gem::Specification < Gem::BasicSpecification
1276
1242
  ##
1277
1243
  # Removes +spec+ from the known specs.
1278
1244
 
1279
- def self.remove_spec spec
1245
+ def self.remove_spec(spec)
1280
1246
  warn "Gem::Specification.remove_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
1281
1247
  _all.delete spec
1282
1248
  stubs.delete_if { |s| s.full_name == spec.full_name }
@@ -1312,13 +1278,19 @@ class Gem::Specification < Gem::BasicSpecification
1312
1278
  @@active_stub_with_requirable_file = {}
1313
1279
  _clear_load_cache
1314
1280
  unresolved = unresolved_deps
1315
- unless unresolved.empty? then
1281
+ unless unresolved.empty?
1316
1282
  w = "W" + "ARN"
1317
- warn "#{w}: Unresolved specs during Gem::Specification.reset:"
1283
+ warn "#{w}: Unresolved or ambigious specs during Gem::Specification.reset:"
1318
1284
  unresolved.values.each do |dep|
1319
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
1320
1292
  end
1321
- warn "#{w}: Clearing out unresolved specs."
1293
+ warn "#{w}: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
1322
1294
  warn "Please report a bug if this causes problems."
1323
1295
  unresolved.clear
1324
1296
  end
@@ -1334,6 +1306,8 @@ class Gem::Specification < Gem::BasicSpecification
1334
1306
  # Load custom marshal format, re-initializing defaults as needed
1335
1307
 
1336
1308
  def self._load(str)
1309
+ Gem.load_yaml
1310
+
1337
1311
  array = Marshal.load str
1338
1312
 
1339
1313
  spec = Gem::Specification.new
@@ -1341,7 +1315,7 @@ class Gem::Specification < Gem::BasicSpecification
1341
1315
 
1342
1316
  current_version = CURRENT_SPECIFICATION_VERSION
1343
1317
 
1344
- field_count = if spec.specification_version > current_version then
1318
+ field_count = if spec.specification_version > current_version
1345
1319
  spec.instance_variable_set :@specification_version,
1346
1320
  current_version
1347
1321
  MARSHAL_FIELDS[current_version]
@@ -1349,7 +1323,7 @@ class Gem::Specification < Gem::BasicSpecification
1349
1323
  MARSHAL_FIELDS[spec.specification_version]
1350
1324
  end
1351
1325
 
1352
- if array.size < field_count then
1326
+ if array.size < field_count
1353
1327
  raise TypeError, "invalid Gem::Specification format #{array.inspect}"
1354
1328
  end
1355
1329
 
@@ -1368,7 +1342,7 @@ class Gem::Specification < Gem::BasicSpecification
1368
1342
  spec.instance_variable_set :@required_rubygems_version, array[7]
1369
1343
  spec.instance_variable_set :@original_platform, array[8]
1370
1344
  spec.instance_variable_set :@dependencies, array[9]
1371
- spec.instance_variable_set :@rubyforge_project, array[10]
1345
+ # offset due to rubyforge_project removal
1372
1346
  spec.instance_variable_set :@email, array[11]
1373
1347
  spec.instance_variable_set :@authors, array[12]
1374
1348
  spec.instance_variable_set :@description, array[13]
@@ -1388,7 +1362,7 @@ class Gem::Specification < Gem::BasicSpecification
1388
1362
  sort_obj <=> other.sort_obj
1389
1363
  end
1390
1364
 
1391
- def == other # :nodoc:
1365
+ def ==(other) # :nodoc:
1392
1366
  self.class === other &&
1393
1367
  name == other.name &&
1394
1368
  version == other.version &&
@@ -1413,7 +1387,7 @@ class Gem::Specification < Gem::BasicSpecification
1413
1387
  @required_rubygems_version,
1414
1388
  @original_platform,
1415
1389
  @dependencies,
1416
- @rubyforge_project,
1390
+ '', # rubyforge_project
1417
1391
  @email,
1418
1392
  @authors,
1419
1393
  @description,
@@ -1433,7 +1407,7 @@ class Gem::Specification < Gem::BasicSpecification
1433
1407
 
1434
1408
  def activate
1435
1409
  other = Gem.loaded_specs[self.name]
1436
- if other then
1410
+ if other
1437
1411
  check_version_conflict other
1438
1412
  return false
1439
1413
  end
@@ -1471,7 +1445,7 @@ class Gem::Specification < Gem::BasicSpecification
1471
1445
 
1472
1446
  specs = spec_dep.to_specs
1473
1447
 
1474
- if specs.size == 1 then
1448
+ if specs.size == 1
1475
1449
  specs.first.activate
1476
1450
  else
1477
1451
  name = spec_dep.name
@@ -1533,7 +1507,7 @@ class Gem::Specification < Gem::BasicSpecification
1533
1507
  def add_bindir(executables)
1534
1508
  return nil if executables.nil?
1535
1509
 
1536
- if @bindir then
1510
+ if @bindir
1537
1511
  Array(executables).map { |e| File.join(@bindir, e) }
1538
1512
  else
1539
1513
  executables
@@ -1548,7 +1522,7 @@ class Gem::Specification < Gem::BasicSpecification
1548
1522
  # <tt>:development</tt>.
1549
1523
 
1550
1524
  def add_dependency_with_type(dependency, type, requirements)
1551
- requirements = if requirements.empty? then
1525
+ requirements = if requirements.empty?
1552
1526
  Gem::Requirement.default
1553
1527
  else
1554
1528
  requirements.flatten
@@ -1577,7 +1551,7 @@ class Gem::Specification < Gem::BasicSpecification
1577
1551
  # gem directories must come after -I and ENV['RUBYLIB']
1578
1552
  insert_index = Gem.load_path_insert_index
1579
1553
 
1580
- if insert_index then
1554
+ if insert_index
1581
1555
  # gem directories must come after -I and ENV['RUBYLIB']
1582
1556
  $LOAD_PATH.insert(insert_index, *paths)
1583
1557
  else
@@ -1615,7 +1589,7 @@ class Gem::Specification < Gem::BasicSpecification
1615
1589
  ##
1616
1590
  # Returns the full path to an executable named +name+ in this gem.
1617
1591
 
1618
- def bin_file name
1592
+ def bin_file(name)
1619
1593
  File.join bin_dir, name
1620
1594
  end
1621
1595
 
@@ -1681,16 +1655,6 @@ class Gem::Specification < Gem::BasicSpecification
1681
1655
  File.join build_info_dir, "#{full_name}.info"
1682
1656
  end
1683
1657
 
1684
- ##
1685
- # Used to detect if the gem is bundled in older version of Ruby, but not
1686
- # detectable as default gem (see BasicSpecification#default_gem?).
1687
-
1688
- def bundled_gem_in_old_ruby?
1689
- !default_gem? &&
1690
- RUBY_VERSION < "2.0.0" &&
1691
- summary == "This #{name} is bundled with Ruby"
1692
- end
1693
-
1694
1658
  ##
1695
1659
  # Returns the full path to the cache directory containing this
1696
1660
  # spec's cached gem.
@@ -1738,7 +1702,7 @@ class Gem::Specification < Gem::BasicSpecification
1738
1702
  def has_conflicts?
1739
1703
  return true unless Gem.env_requirement(name).satisfied_by?(version)
1740
1704
  self.dependencies.any? { |dep|
1741
- if dep.runtime? then
1705
+ if dep.runtime?
1742
1706
  spec = Gem.loaded_specs[dep.name]
1743
1707
  spec and not spec.satisfies_requirement? dep
1744
1708
  else
@@ -1747,13 +1711,16 @@ class Gem::Specification < Gem::BasicSpecification
1747
1711
  }
1748
1712
  end
1749
1713
 
1750
- ##
1751
- # The date this gem was created. Lazily defaults to the current UTC date.
1714
+ # The date this gem was created.
1752
1715
  #
1753
- # There is no need to set this in your gem specification.
1716
+ # If SOURCE_DATE_EPOCH is set as an environment variable, use that to support
1717
+ # reproducible builds; otherwise, default to the current UTC date.
1718
+ #
1719
+ # Details on SOURCE_DATE_EPOCH:
1720
+ # https://reproducible-builds.org/specs/source-date-epoch/
1754
1721
 
1755
1722
  def date
1756
- @date ||= TODAY
1723
+ @date ||= ENV["SOURCE_DATE_EPOCH"] ? Time.utc(*Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc.to_a[3..5].reverse) : TODAY
1757
1724
  end
1758
1725
 
1759
1726
  DateLike = Object.new # :nodoc:
@@ -1765,26 +1732,26 @@ class Gem::Specification < Gem::BasicSpecification
1765
1732
  /\A
1766
1733
  (\d{4})-(\d{2})-(\d{2})
1767
1734
  (\s+ \d{2}:\d{2}:\d{2}\.\d+ \s* (Z | [-+]\d\d:\d\d) )?
1768
- \Z/x
1735
+ \Z/x.freeze
1769
1736
 
1770
1737
  ##
1771
1738
  # The date this gem was created
1772
1739
  #
1773
1740
  # DO NOT set this, it is set automatically when the gem is packaged.
1774
1741
 
1775
- def date= date
1742
+ def date=(date)
1776
1743
  # We want to end up with a Time object with one-day resolution.
1777
1744
  # This is the cleanest, most-readable, faster-than-using-Date
1778
1745
  # way to do it.
1779
1746
  @date = case date
1780
1747
  when String then
1781
- if DateTimeFormat =~ date then
1748
+ if DateTimeFormat =~ date
1782
1749
  Time.utc($1.to_i, $2.to_i, $3.to_i)
1783
1750
 
1784
1751
  # Workaround for where the date format output from psych isn't
1785
1752
  # parsed as a Time object by syck and thus comes through as a
1786
1753
  # string.
1787
- elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date then
1754
+ elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date
1788
1755
  Time.utc($1.to_i, $2.to_i, $3.to_i)
1789
1756
  else
1790
1757
  raise(Gem::InvalidSpecificationException,
@@ -1818,7 +1785,7 @@ class Gem::Specification < Gem::BasicSpecification
1818
1785
  ##
1819
1786
  # The default value for specification attribute +name+
1820
1787
 
1821
- def default_value name
1788
+ def default_value(name)
1822
1789
  @@default_value[name]
1823
1790
  end
1824
1791
 
@@ -1842,7 +1809,7 @@ class Gem::Specification < Gem::BasicSpecification
1842
1809
  out = []
1843
1810
  Gem::Specification.each do |spec|
1844
1811
  spec.dependencies.each do |dep|
1845
- if self.satisfies_requirement?(dep) then
1812
+ if self.satisfies_requirement?(dep)
1846
1813
  sats = []
1847
1814
  find_all_satisfiers(dep) do |sat|
1848
1815
  sats << sat
@@ -1864,7 +1831,7 @@ class Gem::Specification < Gem::BasicSpecification
1864
1831
  ##
1865
1832
  # A detailed description of this gem. See also #summary
1866
1833
 
1867
- def description= str
1834
+ def description=(str)
1868
1835
  @description = str.to_s
1869
1836
  end
1870
1837
 
@@ -1883,17 +1850,17 @@ class Gem::Specification < Gem::BasicSpecification
1883
1850
  #
1884
1851
  # spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri"
1885
1852
 
1886
- def doc_dir type = nil
1853
+ def doc_dir(type = nil)
1887
1854
  @doc_dir ||= File.join base_dir, 'doc', full_name
1888
1855
 
1889
- if type then
1856
+ if type
1890
1857
  File.join @doc_dir, type
1891
1858
  else
1892
1859
  @doc_dir
1893
1860
  end
1894
1861
  end
1895
1862
 
1896
- def encode_with coder # :nodoc:
1863
+ def encode_with(coder) # :nodoc:
1897
1864
  mark_version
1898
1865
 
1899
1866
  coder.add 'name', @name
@@ -1914,7 +1881,7 @@ class Gem::Specification < Gem::BasicSpecification
1914
1881
  end
1915
1882
  end
1916
1883
 
1917
- def eql? other # :nodoc:
1884
+ def eql?(other) # :nodoc:
1918
1885
  self.class === other && same_attributes?(other)
1919
1886
  end
1920
1887
 
@@ -1928,7 +1895,7 @@ class Gem::Specification < Gem::BasicSpecification
1928
1895
  ##
1929
1896
  # Singular accessor for #executables
1930
1897
 
1931
- def executable=o
1898
+ def executable=(o)
1932
1899
  self.executables = [o]
1933
1900
  end
1934
1901
 
@@ -1936,7 +1903,7 @@ class Gem::Specification < Gem::BasicSpecification
1936
1903
  # Sets executables to +value+, ensuring it is an array. Don't
1937
1904
  # use this, push onto the array instead.
1938
1905
 
1939
- def executables= value
1906
+ def executables=(value)
1940
1907
  # TODO: warn about setting instead of pushing
1941
1908
  @executables = Array(value)
1942
1909
  end
@@ -1945,7 +1912,7 @@ class Gem::Specification < Gem::BasicSpecification
1945
1912
  # Sets extensions to +extensions+, ensuring it is an array. Don't
1946
1913
  # use this, push onto the array instead.
1947
1914
 
1948
- def extensions= extensions
1915
+ def extensions=(extensions)
1949
1916
  # TODO: warn about setting instead of pushing
1950
1917
  @extensions = Array extensions
1951
1918
  end
@@ -1954,7 +1921,7 @@ class Gem::Specification < Gem::BasicSpecification
1954
1921
  # Sets extra_rdoc_files to +files+, ensuring it is an array. Don't
1955
1922
  # use this, push onto the array instead.
1956
1923
 
1957
- def extra_rdoc_files= files
1924
+ def extra_rdoc_files=(files)
1958
1925
  # TODO: warn about setting instead of pushing
1959
1926
  @extra_rdoc_files = Array files
1960
1927
  end
@@ -1971,14 +1938,14 @@ class Gem::Specification < Gem::BasicSpecification
1971
1938
  ##
1972
1939
  # Sets files to +files+, ensuring it is an array.
1973
1940
 
1974
- def files= files
1941
+ def files=(files)
1975
1942
  @files = Array files
1976
1943
  end
1977
1944
 
1978
1945
  ##
1979
1946
  # Finds all gems that satisfy +dep+
1980
1947
 
1981
- def find_all_satisfiers dep
1948
+ def find_all_satisfiers(dep)
1982
1949
  Gem::Specification.each do |spec|
1983
1950
  yield spec if spec.satisfies_requirement? dep
1984
1951
  end
@@ -2029,7 +1996,7 @@ class Gem::Specification < Gem::BasicSpecification
2029
1996
  #
2030
1997
  # Formerly used to indicate this gem was RDoc-capable.
2031
1998
 
2032
- def has_rdoc= ignored # :nodoc:
1999
+ def has_rdoc=(ignored) # :nodoc:
2033
2000
  @has_rdoc = true
2034
2001
  end
2035
2002
  deprecate :has_rdoc=, :none, 2018, 12
@@ -2052,7 +2019,7 @@ class Gem::Specification < Gem::BasicSpecification
2052
2019
  name.hash ^ version.hash
2053
2020
  end
2054
2021
 
2055
- def init_with coder # :nodoc:
2022
+ def init_with(coder) # :nodoc:
2056
2023
  @installed_by_version ||= nil
2057
2024
  yaml_initialize coder.tag, coder.map
2058
2025
  end
@@ -2076,7 +2043,7 @@ class Gem::Specification < Gem::BasicSpecification
2076
2043
  # and yields itself for further initialization. Optionally takes +name+ and
2077
2044
  # +version+.
2078
2045
 
2079
- def initialize name = nil, version = nil
2046
+ def initialize(name = nil, version = nil)
2080
2047
  super()
2081
2048
  @gems_dir = nil
2082
2049
  @base_dir = nil
@@ -2100,14 +2067,14 @@ class Gem::Specification < Gem::BasicSpecification
2100
2067
  ##
2101
2068
  # Duplicates array_attributes from +other_spec+ so state isn't shared.
2102
2069
 
2103
- def initialize_copy other_spec
2070
+ def initialize_copy(other_spec)
2104
2071
  self.class.array_attributes.each do |name|
2105
2072
  name = :"@#{name}"
2106
2073
  next unless other_spec.instance_variable_defined? name
2107
2074
 
2108
2075
  begin
2109
2076
  val = other_spec.instance_variable_get(name)
2110
- if val then
2077
+ if val
2111
2078
  instance_variable_set name, val.dup
2112
2079
  elsif Gem.configuration.really_verbose
2113
2080
  warn "WARNING: #{full_name} has an invalid nil value for #{name}"
@@ -2124,7 +2091,7 @@ class Gem::Specification < Gem::BasicSpecification
2124
2091
 
2125
2092
  def base_dir
2126
2093
  return Gem.dir unless loaded_from
2127
- @base_dir ||= if default_gem? then
2094
+ @base_dir ||= if default_gem?
2128
2095
  File.dirname File.dirname File.dirname loaded_from
2129
2096
  else
2130
2097
  File.dirname File.dirname loaded_from
@@ -2200,7 +2167,7 @@ class Gem::Specification < Gem::BasicSpecification
2200
2167
 
2201
2168
  def method_missing(sym, *a, &b) # :nodoc:
2202
2169
  if @specification_version > CURRENT_SPECIFICATION_VERSION and
2203
- sym.to_s =~ /=$/ then
2170
+ sym.to_s =~ /=$/
2204
2171
  warn "ignoring #{sym} loading #{full_name}" if $DEBUG
2205
2172
  else
2206
2173
  super
@@ -2227,7 +2194,7 @@ class Gem::Specification < Gem::BasicSpecification
2227
2194
  # file list.
2228
2195
 
2229
2196
  def normalize
2230
- if defined?(@extra_rdoc_files) and @extra_rdoc_files then
2197
+ if defined?(@extra_rdoc_files) and @extra_rdoc_files
2231
2198
  @extra_rdoc_files.uniq!
2232
2199
  @files ||= []
2233
2200
  @files.concat(@extra_rdoc_files)
@@ -2252,7 +2219,7 @@ class Gem::Specification < Gem::BasicSpecification
2252
2219
  # platform. For use with legacy gems.
2253
2220
 
2254
2221
  def original_name # :nodoc:
2255
- if platform == Gem::Platform::RUBY or platform.nil? then
2222
+ if platform == Gem::Platform::RUBY or platform.nil?
2256
2223
  "#{@name}-#{@version}"
2257
2224
  else
2258
2225
  "#{@name}-#{@version}-#{@original_platform}"
@@ -2285,11 +2252,11 @@ class Gem::Specification < Gem::BasicSpecification
2285
2252
  attributes.each do |attr_name|
2286
2253
  current_value = self.send attr_name
2287
2254
  if current_value != default_value(attr_name) or
2288
- self.class.required_attribute? attr_name then
2255
+ self.class.required_attribute? attr_name
2289
2256
 
2290
2257
  q.text "s.#{attr_name} = "
2291
2258
 
2292
- if attr_name == :date then
2259
+ if attr_name == :date
2293
2260
  current_value = current_value.utc
2294
2261
 
2295
2262
  q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
@@ -2307,7 +2274,7 @@ class Gem::Specification < Gem::BasicSpecification
2307
2274
  # Raise an exception if the version of this spec conflicts with the one
2308
2275
  # that is already loaded (+other+)
2309
2276
 
2310
- def check_version_conflict other # :nodoc:
2277
+ def check_version_conflict(other) # :nodoc:
2311
2278
  return if self.version == other.version
2312
2279
 
2313
2280
  # This gem is already loaded. If the currently loaded gem is not in the
@@ -2317,7 +2284,6 @@ class Gem::Specification < Gem::BasicSpecification
2317
2284
 
2318
2285
  e = Gem::LoadError.new msg
2319
2286
  e.name = self.name
2320
- # TODO: e.requirement = dep.requirement
2321
2287
 
2322
2288
  raise e
2323
2289
  end
@@ -2328,7 +2294,7 @@ class Gem::Specification < Gem::BasicSpecification
2328
2294
  # Check the spec for possible conflicts and freak out if there are any.
2329
2295
 
2330
2296
  def raise_if_conflicts # :nodoc:
2331
- if has_conflicts? then
2297
+ if has_conflicts?
2332
2298
  raise Gem::ConflictError.new self, conflicts
2333
2299
  end
2334
2300
  end
@@ -2337,7 +2303,7 @@ class Gem::Specification < Gem::BasicSpecification
2337
2303
  # Sets rdoc_options to +value+, ensuring it is an array. Don't
2338
2304
  # use this, push onto the array instead.
2339
2305
 
2340
- def rdoc_options= options
2306
+ def rdoc_options=(options)
2341
2307
  # TODO: warn about setting instead of pushing
2342
2308
  @rdoc_options = Array options
2343
2309
  end
@@ -2352,7 +2318,7 @@ class Gem::Specification < Gem::BasicSpecification
2352
2318
  ##
2353
2319
  # Singular accessor for #require_paths
2354
2320
 
2355
- def require_path= path
2321
+ def require_path=(path)
2356
2322
  self.require_paths = Array(path)
2357
2323
  end
2358
2324
 
@@ -2360,12 +2326,12 @@ class Gem::Specification < Gem::BasicSpecification
2360
2326
  # Set requirements to +req+, ensuring it is an array. Don't
2361
2327
  # use this, push onto the array instead.
2362
2328
 
2363
- def requirements= req
2329
+ def requirements=(req)
2364
2330
  # TODO: warn about setting instead of pushing
2365
2331
  @requirements = Array req
2366
2332
  end
2367
2333
 
2368
- def respond_to_missing? m, include_private = false # :nodoc:
2334
+ def respond_to_missing?(m, include_private = false) # :nodoc:
2369
2335
  false
2370
2336
  end
2371
2337
 
@@ -2382,18 +2348,18 @@ class Gem::Specification < Gem::BasicSpecification
2382
2348
 
2383
2349
  def ruby_code(obj)
2384
2350
  case obj
2385
- when String then obj.dump + ".freeze"
2386
- when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
2387
- when Hash then
2351
+ when String then obj.dump + ".freeze"
2352
+ when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
2353
+ when Hash then
2388
2354
  seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
2389
2355
  "{ #{seg.join(', ')} }"
2390
- when Gem::Version then obj.to_s.dump
2391
- when DateLike then obj.strftime('%Y-%m-%d').dump
2392
- when Time then obj.strftime('%Y-%m-%d').dump
2393
- when Numeric then obj.inspect
2394
- when true, false, nil then obj.inspect
2395
- when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
2396
- when Gem::Requirement then
2356
+ when Gem::Version then obj.to_s.dump
2357
+ when DateLike then obj.strftime('%Y-%m-%d').dump
2358
+ when Time then obj.strftime('%Y-%m-%d').dump
2359
+ when Numeric then obj.inspect
2360
+ when true, false, nil then obj.inspect
2361
+ when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
2362
+ when Gem::Requirement then
2397
2363
  list = obj.as_list
2398
2364
  "Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
2399
2365
  else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
@@ -2412,7 +2378,7 @@ class Gem::Specification < Gem::BasicSpecification
2412
2378
  ##
2413
2379
  # True if this gem has the same attributes as +other+.
2414
2380
 
2415
- def same_attributes? spec
2381
+ def same_attributes?(spec)
2416
2382
  @@attributes.all? { |name, default| self.send(name) == spec.send(name) }
2417
2383
  end
2418
2384
 
@@ -2421,7 +2387,7 @@ class Gem::Specification < Gem::BasicSpecification
2421
2387
  ##
2422
2388
  # Checks if this specification meets the requirement of +dependency+.
2423
2389
 
2424
- def satisfies_requirement? dependency
2390
+ def satisfies_requirement?(dependency)
2425
2391
  return @name == dependency.name &&
2426
2392
  dependency.requirement.satisfied_by?(@version)
2427
2393
  end
@@ -2468,7 +2434,7 @@ class Gem::Specification < Gem::BasicSpecification
2468
2434
  ##
2469
2435
  # A short summary of this gem's description.
2470
2436
 
2471
- def summary= str
2437
+ def summary=(str)
2472
2438
  @summary = str.to_s.strip.
2473
2439
  gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').gsub(/\n[ \t]*/, " ") # so. weird.
2474
2440
  end
@@ -2483,7 +2449,7 @@ class Gem::Specification < Gem::BasicSpecification
2483
2449
  ##
2484
2450
  # Singular mutator for #test_files
2485
2451
 
2486
- def test_file= file # :nodoc:
2452
+ def test_file=(file) # :nodoc:
2487
2453
  self.test_files = [file]
2488
2454
  end
2489
2455
 
@@ -2495,11 +2461,11 @@ class Gem::Specification < Gem::BasicSpecification
2495
2461
  # Handle the possibility that we have @test_suite_file but not
2496
2462
  # @test_files. This will happen when an old gem is loaded via
2497
2463
  # YAML.
2498
- if defined? @test_suite_file then
2464
+ if defined? @test_suite_file
2499
2465
  @test_files = [@test_suite_file].flatten
2500
2466
  @test_suite_file = nil
2501
2467
  end
2502
- if defined?(@test_files) and @test_files then
2468
+ if defined?(@test_files) and @test_files
2503
2469
  @test_files
2504
2470
  else
2505
2471
  @test_files = []
@@ -2512,6 +2478,7 @@ class Gem::Specification < Gem::BasicSpecification
2512
2478
  # still have their default values are omitted.
2513
2479
 
2514
2480
  def to_ruby
2481
+ require 'openssl'
2515
2482
  mark_version
2516
2483
  result = []
2517
2484
  result << "# -*- encoding: utf-8 -*-"
@@ -2523,7 +2490,7 @@ class Gem::Specification < Gem::BasicSpecification
2523
2490
 
2524
2491
  result << " s.name = #{ruby_code name}"
2525
2492
  result << " s.version = #{ruby_code version}"
2526
- unless platform.nil? or platform == Gem::Platform::RUBY then
2493
+ unless platform.nil? or platform == Gem::Platform::RUBY
2527
2494
  result << " s.platform = #{ruby_code original_platform}"
2528
2495
  end
2529
2496
  result << ""
@@ -2550,18 +2517,17 @@ class Gem::Specification < Gem::BasicSpecification
2550
2517
  @@attributes.each do |attr_name|
2551
2518
  next if handled.include? attr_name
2552
2519
  current_value = self.send(attr_name)
2553
- if current_value != default_value(attr_name) or
2554
- self.class.required_attribute? attr_name then
2555
- result << " s.#{attr_name} = #{ruby_code current_value}"
2520
+ if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name)
2521
+ result << " s.#{attr_name} = #{ruby_code current_value}" unless current_value.is_a?(OpenSSL::PKey::RSA)
2556
2522
  end
2557
2523
  end
2558
2524
 
2559
- if @installed_by_version then
2525
+ if @installed_by_version
2560
2526
  result << nil
2561
2527
  result << " s.installed_by_version = \"#{Gem::VERSION}\" if s.respond_to? :installed_by_version"
2562
2528
  end
2563
2529
 
2564
- unless dependencies.empty? then
2530
+ unless dependencies.empty?
2565
2531
  result << nil
2566
2532
  result << " if s.respond_to? :specification_version then"
2567
2533
  result << " s.specification_version = #{specification_version}"
@@ -2620,39 +2586,32 @@ class Gem::Specification < Gem::BasicSpecification
2620
2586
  end
2621
2587
 
2622
2588
  def to_yaml(opts = {}) # :nodoc:
2623
- if (YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?) ||
2624
- (defined?(Psych) && YAML == Psych) then
2625
- # Because the user can switch the YAML engine behind our
2626
- # back, we have to check again here to make sure that our
2627
- # psych code was properly loaded, and load it if not.
2628
- unless Gem.const_defined?(:NoAliasYAMLTree)
2629
- require 'rubygems/psych_tree'
2630
- end
2589
+ Gem.load_yaml
2631
2590
 
2632
- builder = Gem::NoAliasYAMLTree.create
2633
- builder << self
2634
- ast = builder.tree
2591
+ # Because the user can switch the YAML engine behind our
2592
+ # back, we have to check again here to make sure that our
2593
+ # psych code was properly loaded, and load it if not.
2594
+ unless Gem.const_defined?(:NoAliasYAMLTree)
2595
+ require 'rubygems/psych_tree'
2596
+ end
2635
2597
 
2636
- io = StringIO.new
2637
- io.set_encoding Encoding::UTF_8 if Object.const_defined? :Encoding
2598
+ builder = Gem::NoAliasYAMLTree.create
2599
+ builder << self
2600
+ ast = builder.tree
2638
2601
 
2639
- Psych::Visitors::Emitter.new(io).accept(ast)
2602
+ io = StringIO.new
2603
+ io.set_encoding Encoding::UTF_8
2640
2604
 
2641
- io.string.gsub(/ !!null \n/, " \n")
2642
- else
2643
- YAML.quick_emit object_id, opts do |out|
2644
- out.map taguri, to_yaml_style do |map|
2645
- encode_with map
2646
- end
2647
- end
2648
- end
2605
+ Psych::Visitors::Emitter.new(io).accept(ast)
2606
+
2607
+ io.string.gsub(/ !!null \n/, " \n")
2649
2608
  end
2650
2609
 
2651
2610
  ##
2652
2611
  # Recursively walk dependencies of this spec, executing the +block+ for each
2653
2612
  # hop.
2654
2613
 
2655
- def traverse trail = [], visited = {}, &block
2614
+ def traverse(trail = [], visited = {}, &block)
2656
2615
  trail.push(self)
2657
2616
  begin
2658
2617
  dependencies.each do |dep|
@@ -2685,336 +2644,40 @@ class Gem::Specification < Gem::BasicSpecification
2685
2644
  # Raises InvalidSpecificationException if the spec does not pass the
2686
2645
  # checks..
2687
2646
 
2688
- def validate packaging = true
2689
- @warnings = 0
2647
+ def validate(packaging = true, strict = false)
2690
2648
  require 'rubygems/user_interaction'
2691
2649
  extend Gem::UserInteraction
2692
2650
  normalize
2693
2651
 
2694
- nil_attributes = self.class.non_nil_attributes.find_all do |attrname|
2695
- instance_variable_get("@#{attrname}").nil?
2696
- end
2697
-
2698
- unless nil_attributes.empty? then
2699
- raise Gem::InvalidSpecificationException,
2700
- "#{nil_attributes.join ', '} must not be nil"
2701
- end
2702
-
2703
- if packaging and rubygems_version != Gem::VERSION then
2704
- raise Gem::InvalidSpecificationException,
2705
- "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
2706
- end
2707
-
2708
- @@required_attributes.each do |symbol|
2709
- unless self.send symbol then
2710
- raise Gem::InvalidSpecificationException,
2711
- "missing value for attribute #{symbol}"
2712
- end
2713
- end
2714
-
2715
- if !name.is_a?(String) then
2716
- raise Gem::InvalidSpecificationException,
2717
- "invalid value for attribute name: \"#{name.inspect}\" must be a string"
2718
- elsif name !~ /[a-zA-Z]/ then
2719
- raise Gem::InvalidSpecificationException,
2720
- "invalid value for attribute name: #{name.dump} must include at least one letter"
2721
- elsif name !~ VALID_NAME_PATTERN then
2722
- raise Gem::InvalidSpecificationException,
2723
- "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
2724
- end
2725
-
2726
- if raw_require_paths.empty? then
2727
- raise Gem::InvalidSpecificationException,
2728
- 'specification must have at least one require_path'
2729
- end
2652
+ validation_policy = Gem::SpecificationPolicy.new(self)
2653
+ validation_policy.packaging = packaging
2654
+ validation_policy.validate(strict)
2655
+ end
2730
2656
 
2731
- @files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2732
- @test_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2657
+ def keep_only_files_and_directories
2733
2658
  @executables.delete_if { |x| File.directory?(File.join(@bindir, x)) }
2734
- @extra_rdoc_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2735
2659
  @extensions.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
2736
-
2737
- non_files = files.reject { |x| File.file?(x) || File.symlink?(x) }
2738
-
2739
- unless not packaging or non_files.empty? then
2740
- raise Gem::InvalidSpecificationException,
2741
- "[\"#{non_files.join "\", \""}\"] are not files"
2742
- end
2743
-
2744
- if files.include? file_name then
2745
- raise Gem::InvalidSpecificationException,
2746
- "#{full_name} contains itself (#{file_name}), check your files list"
2747
- end
2748
-
2749
- unless specification_version.is_a?(Integer)
2750
- raise Gem::InvalidSpecificationException,
2751
- 'specification_version must be an Integer (did you mean version?)'
2752
- end
2753
-
2754
- case platform
2755
- when Gem::Platform, Gem::Platform::RUBY then # ok
2756
- else
2757
- raise Gem::InvalidSpecificationException,
2758
- "invalid platform #{platform.inspect}, see Gem::Platform"
2759
- end
2760
-
2761
- self.class.array_attributes.each do |field|
2762
- val = self.send field
2763
- klass = case field
2764
- when :dependencies
2765
- Gem::Dependency
2766
- else
2767
- String
2768
- end
2769
-
2770
- unless Array === val and val.all? { |x| x.kind_of?(klass) } then
2771
- raise(Gem::InvalidSpecificationException,
2772
- "#{field} must be an Array of #{klass}")
2773
- end
2774
- end
2775
-
2776
- [:authors].each do |field|
2777
- val = self.send field
2778
- raise Gem::InvalidSpecificationException, "#{field} may not be empty" if
2779
- val.empty?
2780
- end
2781
-
2782
- unless Hash === metadata
2783
- raise Gem::InvalidSpecificationException,
2784
- 'metadata must be a hash'
2785
- end
2786
-
2787
- validate_metadata
2788
-
2789
- licenses.each { |license|
2790
- if license.length > 64
2791
- raise Gem::InvalidSpecificationException,
2792
- "each license must be 64 characters or less"
2793
- end
2794
-
2795
- if !Gem::Licenses.match?(license)
2796
- suggestions = Gem::Licenses.suggestions(license)
2797
- message = <<-warning
2798
- license value '#{license}' is invalid. Use a license identifier from
2799
- http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
2800
- warning
2801
- message += "Did you mean #{suggestions.map { |s| "'#{s}'"}.join(', ')}?\n" unless suggestions.nil?
2802
- warning(message)
2803
- end
2804
- }
2805
-
2806
- warning <<-warning if licenses.empty?
2807
- licenses is empty, but is recommended. Use a license identifier from
2808
- http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
2809
- warning
2810
-
2811
- validate_permissions
2812
-
2813
- # reject lazy developers:
2814
-
2815
- lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
2816
-
2817
- unless authors.grep(/FI XME|TO DO/x).empty? then
2818
- raise Gem::InvalidSpecificationException, "#{lazy} is not an author"
2819
- end
2820
-
2821
- unless Array(email).grep(/FI XME|TO DO/x).empty? then
2822
- raise Gem::InvalidSpecificationException, "#{lazy} is not an email"
2823
- end
2824
-
2825
- if description =~ /FI XME|TO DO/x then
2826
- raise Gem::InvalidSpecificationException, "#{lazy} is not a description"
2827
- end
2828
-
2829
- if summary =~ /FI XME|TO DO/x then
2830
- raise Gem::InvalidSpecificationException, "#{lazy} is not a summary"
2831
- end
2832
-
2833
- # Make sure a homepage is valid HTTP/HTTPS URI
2834
- if homepage and not homepage.empty?
2835
- begin
2836
- homepage_uri = URI.parse(homepage)
2837
- unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class
2838
- raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI"
2839
- end
2840
- rescue URI::InvalidURIError
2841
- raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI"
2842
- end
2843
- end
2844
-
2845
- # Warnings
2846
-
2847
- %w[author homepage summary files].each do |attribute|
2848
- value = self.send attribute
2849
- warning "no #{attribute} specified" if value.nil? or value.empty?
2850
- end
2851
-
2852
- if description == summary then
2853
- warning 'description and summary are identical'
2854
- end
2855
-
2856
- # TODO: raise at some given date
2857
- warning "deprecated autorequire specified" if autorequire
2858
-
2859
- executables.each do |executable|
2860
- executable_path = File.join(bindir, executable)
2861
- shebang = File.read(executable_path, 2) == '#!'
2862
-
2863
- warning "#{executable_path} is missing #! line" unless shebang
2864
- end
2865
-
2866
- files.each do |file|
2867
- next unless File.symlink?(file)
2868
- warning "#{file} is a symlink, which is not supported on all platforms"
2869
- end
2870
-
2871
- validate_dependencies
2872
-
2873
- true
2874
- ensure
2875
- if $! or @warnings > 0 then
2876
- alert_warning "See http://guides.rubygems.org/specification-reference/ for help"
2877
- end
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) }
2878
2663
  end
2879
2664
 
2880
2665
  def validate_metadata
2881
- url_validation_regex = %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z}
2882
- link_keys = %w(
2883
- bug_tracker_uri
2884
- changelog_uri
2885
- documentation_uri
2886
- homepage_uri
2887
- mailing_list_uri
2888
- source_code_uri
2889
- wiki_uri
2890
- )
2891
-
2892
- metadata.each do|key, value|
2893
- if !key.kind_of?(String)
2894
- raise Gem::InvalidSpecificationException,
2895
- "metadata keys must be a String"
2896
- end
2897
-
2898
- if key.size > 128
2899
- raise Gem::InvalidSpecificationException,
2900
- "metadata key too large (#{key.size} > 128)"
2901
- end
2902
-
2903
- if !value.kind_of?(String)
2904
- raise Gem::InvalidSpecificationException,
2905
- "metadata values must be a String"
2906
- end
2907
-
2908
- if value.size > 1024
2909
- raise Gem::InvalidSpecificationException,
2910
- "metadata value too large (#{value.size} > 1024)"
2911
- end
2912
-
2913
- if link_keys.include? key
2914
- if value !~ url_validation_regex
2915
- raise Gem::InvalidSpecificationException,
2916
- "metadata['#{key}'] has invalid link: #{value.inspect}"
2917
- end
2918
- end
2919
- end
2666
+ Gem::SpecificationPolicy.new(self).validate_metadata
2920
2667
  end
2921
2668
 
2922
2669
  ##
2923
2670
  # Checks that dependencies use requirements as we recommend. Warnings are
2924
2671
  # issued when dependencies are open-ended or overly strict for semantic
2925
2672
  # versioning.
2926
-
2927
- def validate_dependencies # :nodoc:
2928
- # NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
2929
- seen = Gem::Dependency::TYPES.inject({}) { |types, type| types.merge({ type => {}}) }
2930
-
2931
- error_messages = []
2932
- warning_messages = []
2933
- dependencies.each do |dep|
2934
- if prev = seen[dep.type][dep.name] then
2935
- error_messages << <<-MESSAGE
2936
- duplicate dependency on #{dep}, (#{prev.requirement}) use:
2937
- add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
2938
- MESSAGE
2939
- end
2940
-
2941
- seen[dep.type][dep.name] = dep
2942
-
2943
- prerelease_dep = dep.requirements_list.any? do |req|
2944
- Gem::Requirement.new(req).prerelease?
2945
- end
2946
-
2947
- warning_messages << "prerelease dependency on #{dep} is not recommended" if
2948
- prerelease_dep && !version.prerelease?
2949
-
2950
- overly_strict = dep.requirement.requirements.length == 1 &&
2951
- dep.requirement.requirements.any? do |op, version|
2952
- op == '~>' and
2953
- not version.prerelease? and
2954
- version.segments.length > 2 and
2955
- version.segments.first != 0
2956
- end
2957
-
2958
- if overly_strict then
2959
- _, dep_version = dep.requirement.requirements.first
2960
-
2961
- base = dep_version.segments.first 2
2962
-
2963
- warning_messages << <<-WARNING
2964
- pessimistic dependency on #{dep} may be overly strict
2965
- if #{dep.name} is semantically versioned, use:
2966
- add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}', '>= #{dep_version}'
2967
- WARNING
2968
- end
2969
-
2970
- open_ended = dep.requirement.requirements.all? do |op, version|
2971
- not version.prerelease? and (op == '>' or op == '>=')
2972
- end
2973
-
2974
- if open_ended then
2975
- op, dep_version = dep.requirement.requirements.first
2976
-
2977
- base = dep_version.segments.first 2
2978
-
2979
- bugfix = if op == '>' then
2980
- ", '> #{dep_version}'"
2981
- elsif op == '>=' and base != dep_version.segments then
2982
- ", '>= #{dep_version}'"
2983
- end
2984
-
2985
- warning_messages << <<-WARNING
2986
- open-ended dependency on #{dep} is not recommended
2987
- if #{dep.name} is semantically versioned, use:
2988
- add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}
2989
- WARNING
2990
- end
2991
- end
2992
- if error_messages.any?
2993
- raise Gem::InvalidSpecificationException, error_messages.join
2994
- end
2995
- if warning_messages.any?
2996
- warning_messages.each { |warning_message| warning warning_message }
2997
- end
2673
+ def validate_dependencies
2674
+ Gem::SpecificationPolicy.new(self).validate_dependencies
2998
2675
  end
2999
2676
 
3000
2677
  ##
3001
2678
  # Checks to see if the files to be packaged are world-readable.
3002
-
3003
2679
  def validate_permissions
3004
- return if Gem.win_platform?
3005
-
3006
- files.each do |file|
3007
- next unless File.file?(file)
3008
- next if File.stat(file).mode & 0444 == 0444
3009
- warning "#{file} is not world-readable"
3010
- end
3011
-
3012
- executables.each do |name|
3013
- exec = File.join @bindir, name
3014
- next unless File.file?(exec)
3015
- next if File.stat(exec).executable?
3016
- warning "#{exec} is not executable"
3017
- end
2680
+ Gem::SpecificationPolicy.new(self).validate_permissions
3018
2681
  end
3019
2682
 
3020
2683
  ##
@@ -3022,9 +2685,13 @@ open-ended dependency on #{dep} is not recommended
3022
2685
  # required_rubygems_version if +version+ indicates it is a
3023
2686
  # prerelease.
3024
2687
 
3025
- def version= version
2688
+ def version=(version)
3026
2689
  @version = Gem::Version.create(version)
3027
- self.required_rubygems_version = '> 1.3.1' if @version.prerelease?
2690
+ # skip to set required_ruby_version when pre-released rubygems.
2691
+ # It caused to raise CircularDependencyError
2692
+ if @version.prerelease? && (@name.nil? || @name.strip != "rubygems")
2693
+ self.required_rubygems_version = '> 1.3.1'
2694
+ end
3028
2695
  invalidate_memoized_attributes
3029
2696
 
3030
2697
  return @version
@@ -3071,12 +2738,6 @@ open-ended dependency on #{dep} is not recommended
3071
2738
  @installed_by_version ||= nil
3072
2739
  end
3073
2740
 
3074
- def warning statement # :nodoc:
3075
- @warnings += 1
3076
-
3077
- alert_warning statement
3078
- end
3079
-
3080
2741
  def raw_require_paths # :nodoc:
3081
2742
  @require_paths
3082
2743
  end