bundler 1.17.3 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (426) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3354 -1258
  3. data/LICENSE.md +18 -19
  4. data/README.md +10 -15
  5. data/bundler.gemspec +15 -33
  6. data/exe/bundle +8 -10
  7. data/exe/bundler +1 -1
  8. data/lib/bundler/.document +1 -0
  9. data/lib/bundler/build_metadata.rb +5 -13
  10. data/lib/bundler/capistrano.rb +5 -5
  11. data/lib/bundler/checksum.rb +254 -0
  12. data/lib/bundler/ci_detector.rb +75 -0
  13. data/lib/bundler/cli/add.rb +29 -15
  14. data/lib/bundler/cli/binstubs.rb +13 -5
  15. data/lib/bundler/cli/cache.rb +24 -17
  16. data/lib/bundler/cli/check.rb +7 -5
  17. data/lib/bundler/cli/clean.rb +1 -1
  18. data/lib/bundler/cli/common.rb +50 -14
  19. data/lib/bundler/cli/config.rb +171 -86
  20. data/lib/bundler/cli/console.rb +3 -6
  21. data/lib/bundler/cli/doctor.rb +29 -12
  22. data/lib/bundler/cli/exec.rb +9 -25
  23. data/lib/bundler/cli/fund.rb +36 -0
  24. data/lib/bundler/cli/gem.rb +268 -53
  25. data/lib/bundler/cli/info.rb +51 -18
  26. data/lib/bundler/cli/init.rb +7 -3
  27. data/lib/bundler/cli/inject.rb +2 -2
  28. data/lib/bundler/cli/install.rb +55 -73
  29. data/lib/bundler/cli/issue.rb +9 -8
  30. data/lib/bundler/cli/list.rb +19 -11
  31. data/lib/bundler/cli/lock.rb +56 -26
  32. data/lib/bundler/cli/open.rb +10 -7
  33. data/lib/bundler/cli/outdated.rb +159 -128
  34. data/lib/bundler/cli/platform.rb +8 -6
  35. data/lib/bundler/cli/plugin.rb +23 -12
  36. data/lib/bundler/cli/pristine.rb +39 -26
  37. data/lib/bundler/cli/remove.rb +1 -2
  38. data/lib/bundler/cli/show.rb +7 -7
  39. data/lib/bundler/cli/update.rb +51 -19
  40. data/lib/bundler/cli/viz.rb +1 -1
  41. data/lib/bundler/cli.rb +399 -390
  42. data/lib/bundler/compact_index_client/cache.rb +55 -77
  43. data/lib/bundler/compact_index_client/cache_file.rb +148 -0
  44. data/lib/bundler/compact_index_client/gem_parser.rb +32 -0
  45. data/lib/bundler/compact_index_client/parser.rb +84 -0
  46. data/lib/bundler/compact_index_client/updater.rb +72 -84
  47. data/lib/bundler/compact_index_client.rb +61 -73
  48. data/lib/bundler/constants.rb +9 -2
  49. data/lib/bundler/current_ruby.rb +20 -21
  50. data/lib/bundler/definition.rb +663 -505
  51. data/lib/bundler/dependency.rb +38 -71
  52. data/lib/bundler/deployment.rb +1 -1
  53. data/lib/bundler/digest.rb +71 -0
  54. data/lib/bundler/dsl.rb +171 -152
  55. data/lib/bundler/endpoint_specification.rb +43 -17
  56. data/lib/bundler/env.rb +11 -18
  57. data/lib/bundler/environment_preserver.rb +17 -8
  58. data/lib/bundler/errors.rb +115 -14
  59. data/lib/bundler/feature_flag.rb +15 -39
  60. data/lib/bundler/fetcher/base.rb +12 -12
  61. data/lib/bundler/fetcher/compact_index.rb +41 -47
  62. data/lib/bundler/fetcher/dependency.rb +4 -8
  63. data/lib/bundler/fetcher/downloader.rb +27 -20
  64. data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  65. data/lib/bundler/fetcher/index.rb +6 -33
  66. data/lib/bundler/fetcher.rb +109 -90
  67. data/lib/bundler/force_platform.rb +16 -0
  68. data/lib/bundler/friendly_errors.rb +50 -55
  69. data/lib/bundler/gem_helper.rb +81 -46
  70. data/lib/bundler/gem_helpers.rb +78 -29
  71. data/lib/bundler/gem_tasks.rb +1 -1
  72. data/lib/bundler/gem_version_promoter.rb +68 -109
  73. data/lib/bundler/graph.rb +11 -11
  74. data/lib/bundler/index.rb +74 -82
  75. data/lib/bundler/injector.rb +58 -26
  76. data/lib/bundler/inline.rb +59 -35
  77. data/lib/bundler/installer/gem_installer.rb +29 -29
  78. data/lib/bundler/installer/parallel_installer.rb +38 -68
  79. data/lib/bundler/installer/standalone.rb +76 -16
  80. data/lib/bundler/installer.rb +60 -135
  81. data/lib/bundler/lazy_specification.rb +161 -63
  82. data/lib/bundler/lockfile_generator.rb +14 -5
  83. data/lib/bundler/lockfile_parser.rb +150 -109
  84. data/lib/bundler/man/bundle-add.1 +76 -0
  85. data/lib/bundler/man/bundle-add.1.ronn +87 -0
  86. data/{man → lib/bundler/man}/bundle-binstubs.1 +15 -22
  87. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +8 -7
  88. data/lib/bundler/man/bundle-cache.1 +68 -0
  89. data/lib/bundler/man/bundle-cache.1.ronn +108 -0
  90. data/{man → lib/bundler/man}/bundle-check.1 +7 -14
  91. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +7 -2
  92. data/{man → lib/bundler/man}/bundle-clean.1 +4 -11
  93. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  94. data/{man → lib/bundler/man}/bundle-config.1 +80 -260
  95. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +104 -98
  96. data/lib/bundler/man/bundle-console.1 +33 -0
  97. data/lib/bundler/man/bundle-console.1.ronn +39 -0
  98. data/{man → lib/bundler/man}/bundle-doctor.1 +5 -19
  99. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +1 -1
  100. data/lib/bundler/man/bundle-env.1 +9 -0
  101. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  102. data/{man → lib/bundler/man}/bundle-exec.1 +20 -78
  103. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +12 -10
  104. data/lib/bundler/man/bundle-fund.1 +22 -0
  105. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  106. data/lib/bundler/man/bundle-gem.1 +87 -0
  107. data/lib/bundler/man/bundle-gem.1.ronn +149 -0
  108. data/lib/bundler/man/bundle-help.1 +9 -0
  109. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  110. data/lib/bundler/man/bundle-info.1 +17 -0
  111. data/lib/bundler/man/bundle-info.1.ronn +21 -0
  112. data/{man → lib/bundler/man}/bundle-init.1 +8 -13
  113. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +5 -2
  114. data/lib/bundler/man/bundle-inject.1 +31 -0
  115. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +12 -2
  116. data/{man → lib/bundler/man}/bundle-install.1 +65 -155
  117. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +66 -57
  118. data/lib/bundler/man/bundle-issue.1 +45 -0
  119. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  120. data/lib/bundler/man/bundle-licenses.1 +9 -0
  121. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  122. data/{man → lib/bundler/man}/bundle-list.1 +9 -24
  123. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +10 -7
  124. data/{man → lib/bundler/man}/bundle-lock.1 +25 -34
  125. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +25 -4
  126. data/lib/bundler/man/bundle-open.1 +32 -0
  127. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +10 -1
  128. data/{man → lib/bundler/man}/bundle-outdated.1 +23 -75
  129. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +21 -22
  130. data/lib/bundler/man/bundle-platform.1 +49 -0
  131. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  132. data/lib/bundler/man/bundle-plugin.1 +58 -0
  133. data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
  134. data/{man → lib/bundler/man}/bundle-pristine.1 +5 -16
  135. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +1 -1
  136. data/{man → lib/bundler/man}/bundle-remove.1 +4 -14
  137. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +1 -1
  138. data/{man → lib/bundler/man}/bundle-show.1 +7 -11
  139. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +4 -0
  140. data/{man → lib/bundler/man}/bundle-update.1 +35 -148
  141. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +21 -12
  142. data/lib/bundler/man/bundle-version.1 +22 -0
  143. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  144. data/{man → lib/bundler/man}/bundle-viz.1 +9 -18
  145. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +9 -3
  146. data/{man → lib/bundler/man}/bundle.1 +19 -53
  147. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
  148. data/{man → lib/bundler/man}/gemfile.5 +139 -356
  149. data/{man → lib/bundler/man}/gemfile.5.ronn +134 -97
  150. data/{man → lib/bundler/man}/index.txt +9 -1
  151. data/lib/bundler/match_metadata.rb +17 -0
  152. data/lib/bundler/match_platform.rb +2 -3
  153. data/lib/bundler/match_remote_metadata.rb +29 -0
  154. data/lib/bundler/materialization.rb +59 -0
  155. data/lib/bundler/mirror.rb +10 -12
  156. data/lib/bundler/plugin/api/source.rb +34 -18
  157. data/lib/bundler/plugin/api.rb +1 -1
  158. data/lib/bundler/plugin/dsl.rb +1 -1
  159. data/lib/bundler/plugin/events.rb +24 -0
  160. data/lib/bundler/plugin/index.rb +44 -9
  161. data/lib/bundler/plugin/installer/git.rb +0 -4
  162. data/lib/bundler/plugin/installer/path.rb +18 -0
  163. data/lib/bundler/plugin/installer/rubygems.rb +1 -9
  164. data/lib/bundler/plugin/installer.rb +63 -27
  165. data/lib/bundler/plugin/source_list.rb +5 -1
  166. data/lib/bundler/plugin.rb +131 -45
  167. data/lib/bundler/process_lock.rb +10 -14
  168. data/lib/bundler/remote_specification.rb +22 -10
  169. data/lib/bundler/resolver/base.rb +118 -0
  170. data/lib/bundler/resolver/candidate.rb +82 -0
  171. data/lib/bundler/resolver/incompatibility.rb +15 -0
  172. data/lib/bundler/resolver/package.rb +90 -0
  173. data/lib/bundler/resolver/root.rb +25 -0
  174. data/lib/bundler/resolver/spec_group.rb +60 -68
  175. data/lib/bundler/resolver.rb +454 -303
  176. data/lib/bundler/retry.rb +6 -6
  177. data/lib/bundler/ruby_dsl.rb +51 -7
  178. data/lib/bundler/ruby_version.rb +23 -38
  179. data/lib/bundler/rubygems_ext.rb +357 -98
  180. data/lib/bundler/rubygems_gem_installer.rb +131 -65
  181. data/lib/bundler/rubygems_integration.rb +149 -591
  182. data/lib/bundler/runtime.rb +51 -51
  183. data/lib/bundler/safe_marshal.rb +31 -0
  184. data/lib/bundler/self_manager.rb +206 -0
  185. data/lib/bundler/settings.rb +271 -135
  186. data/lib/bundler/setup.rb +23 -12
  187. data/lib/bundler/shared_helpers.rb +127 -117
  188. data/lib/bundler/similarity_detector.rb +3 -3
  189. data/lib/bundler/source/git/git_proxy.rb +326 -127
  190. data/lib/bundler/source/git.rb +207 -88
  191. data/lib/bundler/source/metadata.rb +19 -18
  192. data/lib/bundler/source/path/installer.rb +11 -32
  193. data/lib/bundler/source/path.rb +39 -38
  194. data/lib/bundler/source/rubygems/remote.rb +3 -4
  195. data/lib/bundler/source/rubygems.rb +223 -255
  196. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  197. data/lib/bundler/source.rb +33 -11
  198. data/lib/bundler/source_list.rb +131 -66
  199. data/lib/bundler/source_map.rb +71 -0
  200. data/lib/bundler/spec_set.rb +239 -94
  201. data/lib/bundler/stub_specification.rb +77 -39
  202. data/lib/bundler/templates/Executable +3 -5
  203. data/lib/bundler/templates/Executable.bundler +23 -19
  204. data/lib/bundler/templates/Executable.standalone +4 -4
  205. data/lib/bundler/templates/Gemfile +0 -2
  206. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  207. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +104 -46
  208. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  209. data/lib/bundler/templates/newgem/Gemfile.tt +19 -2
  210. data/lib/bundler/templates/newgem/README.md.tt +18 -16
  211. data/lib/bundler/templates/newgem/Rakefile.tt +44 -6
  212. data/lib/bundler/templates/newgem/bin/console.tt +1 -4
  213. data/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  214. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  215. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  216. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  217. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  218. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  219. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  220. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  221. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  222. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  223. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  224. data/lib/bundler/templates/newgem/newgem.gemspec.tt +37 -40
  225. data/lib/bundler/templates/newgem/rubocop.yml.tt +8 -0
  226. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  227. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  228. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  229. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  230. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  231. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  232. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  233. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  234. data/lib/bundler/ui/rg_proxy.rb +2 -2
  235. data/lib/bundler/ui/shell.rb +64 -23
  236. data/lib/bundler/ui/silent.rb +33 -6
  237. data/lib/bundler/ui.rb +3 -3
  238. data/lib/bundler/uri_credentials_filter.rb +11 -5
  239. data/lib/bundler/uri_normalizer.rb +23 -0
  240. data/lib/bundler/vendor/.document +1 -0
  241. data/lib/bundler/vendor/connection_pool/.document +1 -0
  242. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  243. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  244. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  245. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  246. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +175 -0
  247. data/lib/bundler/vendor/fileutils/.document +1 -0
  248. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  249. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1490 -432
  250. data/lib/bundler/vendor/net-http-persistent/.document +1 -0
  251. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  252. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
  253. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
  254. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  255. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +362 -484
  256. data/lib/bundler/vendor/pub_grub/.document +1 -0
  257. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  258. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  259. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  260. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  261. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  262. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  263. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  264. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  265. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  266. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  267. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  268. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  269. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  270. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  271. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  272. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  273. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  274. data/lib/bundler/vendor/securerandom/.document +1 -0
  275. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  276. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  277. data/lib/bundler/vendor/thor/.document +1 -0
  278. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  279. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +4 -3
  280. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  281. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +8 -18
  282. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  283. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +27 -20
  284. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +34 -13
  285. data/lib/bundler/vendor/thor/lib/thor/actions.rb +47 -28
  286. data/lib/bundler/vendor/thor/lib/thor/base.rb +200 -54
  287. data/lib/bundler/vendor/thor/lib/thor/command.rb +34 -18
  288. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
  289. data/lib/bundler/vendor/thor/lib/thor/error.rb +74 -0
  290. data/lib/bundler/vendor/thor/lib/thor/group.rb +15 -4
  291. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +2 -1
  292. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  293. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  294. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  295. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  296. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +17 -1
  297. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +35 -15
  298. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +45 -13
  299. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +86 -13
  300. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  301. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +3 -2
  302. data/lib/bundler/vendor/thor/lib/thor/runner.rb +51 -40
  303. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +99 -148
  304. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -43
  305. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  306. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -49
  307. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
  308. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  309. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  310. data/lib/bundler/vendor/thor/lib/thor/shell.rb +6 -6
  311. data/lib/bundler/vendor/thor/lib/thor/util.rb +26 -9
  312. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  313. data/lib/bundler/vendor/thor/lib/thor.rb +182 -17
  314. data/lib/bundler/vendor/tsort/.document +1 -0
  315. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  316. data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
  317. data/lib/bundler/vendor/uri/.document +1 -0
  318. data/lib/bundler/vendor/uri/COPYING +56 -0
  319. data/lib/bundler/vendor/uri/lib/uri/common.rb +876 -0
  320. data/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  321. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  322. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1578 -0
  323. data/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  324. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  325. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  326. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  327. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  328. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  329. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
  330. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  331. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  332. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  333. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  334. data/lib/bundler/vendored_fileutils.rb +1 -6
  335. data/lib/bundler/vendored_net_http.rb +23 -0
  336. data/lib/bundler/vendored_persistent.rb +1 -42
  337. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  338. data/lib/bundler/vendored_securerandom.rb +12 -0
  339. data/lib/bundler/vendored_thor.rb +2 -2
  340. data/lib/bundler/vendored_timeout.rb +12 -0
  341. data/lib/bundler/vendored_tsort.rb +4 -0
  342. data/lib/bundler/vendored_uri.rb +21 -0
  343. data/lib/bundler/version.rb +5 -20
  344. data/lib/bundler/vlad.rb +3 -3
  345. data/lib/bundler/worker.rb +26 -15
  346. data/lib/bundler/yaml_serializer.rb +21 -13
  347. data/lib/bundler.rb +364 -230
  348. metadata +186 -218
  349. data/exe/bundle_ruby +0 -60
  350. data/lib/bundler/cli/package.rb +0 -49
  351. data/lib/bundler/compatibility_guard.rb +0 -14
  352. data/lib/bundler/dep_proxy.rb +0 -48
  353. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  354. data/lib/bundler/gemdeps.rb +0 -29
  355. data/lib/bundler/psyched_yaml.rb +0 -37
  356. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  357. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  358. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  359. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  360. data/lib/bundler/templates/gems.rb +0 -8
  361. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -3
  362. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  363. data/lib/bundler/templates/newgem/travis.yml.tt +0 -7
  364. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  365. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  366. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
  367. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  368. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  369. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  370. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  371. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  372. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  373. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  374. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  375. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
  376. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
  377. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  378. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  379. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
  380. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  381. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
  382. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  383. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  384. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
  385. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  386. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  387. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  388. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  389. data/lib/bundler/version_ranges.rb +0 -76
  390. data/man/bundle-add.1 +0 -58
  391. data/man/bundle-add.1.txt +0 -52
  392. data/man/bundle-add.ronn +0 -40
  393. data/man/bundle-binstubs.1.txt +0 -48
  394. data/man/bundle-check.1.txt +0 -33
  395. data/man/bundle-clean.1.txt +0 -26
  396. data/man/bundle-config.1.txt +0 -529
  397. data/man/bundle-doctor.1.txt +0 -44
  398. data/man/bundle-exec.1.txt +0 -178
  399. data/man/bundle-gem.1 +0 -80
  400. data/man/bundle-gem.1.txt +0 -91
  401. data/man/bundle-gem.ronn +0 -78
  402. data/man/bundle-info.1 +0 -20
  403. data/man/bundle-info.1.txt +0 -21
  404. data/man/bundle-info.ronn +0 -17
  405. data/man/bundle-init.1.txt +0 -34
  406. data/man/bundle-inject.1 +0 -33
  407. data/man/bundle-inject.1.txt +0 -32
  408. data/man/bundle-install.1.txt +0 -396
  409. data/man/bundle-list.1.txt +0 -43
  410. data/man/bundle-lock.1.txt +0 -93
  411. data/man/bundle-open.1 +0 -32
  412. data/man/bundle-open.1.txt +0 -29
  413. data/man/bundle-outdated.1.txt +0 -131
  414. data/man/bundle-package.1 +0 -55
  415. data/man/bundle-package.1.txt +0 -79
  416. data/man/bundle-package.ronn +0 -72
  417. data/man/bundle-platform.1 +0 -61
  418. data/man/bundle-platform.1.txt +0 -57
  419. data/man/bundle-pristine.1.txt +0 -44
  420. data/man/bundle-remove.1.txt +0 -34
  421. data/man/bundle-show.1.txt +0 -27
  422. data/man/bundle-update.1.txt +0 -391
  423. data/man/bundle-viz.1.txt +0 -39
  424. data/man/bundle.1.txt +0 -116
  425. data/man/gemfile.5.txt +0 -653
  426. /data/lib/bundler/{ssl_certs → man}/.document +0 -0
@@ -1,12 +1,11 @@
1
- require "bundler/vendor/thor/lib/thor"
2
- require "bundler/vendor/thor/lib/thor/group"
3
- require "bundler/vendor/thor/lib/thor/core_ext/io_binary_read"
1
+ require_relative "../thor"
2
+ require_relative "group"
4
3
 
5
4
  require "yaml"
6
- require "digest"
5
+ require "digest/sha2"
7
6
  require "pathname"
8
7
 
9
- class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
8
+ class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
10
9
  map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
11
10
 
12
11
  def self.banner(command, all = false, subcommand = false)
@@ -24,7 +23,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
24
23
  initialize_thorfiles(meth)
25
24
  klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
26
25
  self.class.handle_no_command_error(command, false) if klass.nil?
27
- klass.start(["-h", command].compact, :shell => shell)
26
+ klass.start(["-h", command].compact, shell: shell)
28
27
  else
29
28
  super
30
29
  end
@@ -39,33 +38,45 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
39
38
  klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
40
39
  self.class.handle_no_command_error(command, false) if klass.nil?
41
40
  args.unshift(command) if command
42
- klass.start(args, :shell => shell)
41
+ klass.start(args, shell: shell)
43
42
  end
44
43
 
45
44
  desc "install NAME", "Install an optionally named Bundler::Thor file into your system commands"
46
- method_options :as => :string, :relative => :boolean, :force => :boolean
47
- def install(name) # rubocop:disable MethodLength
45
+ method_options as: :string, relative: :boolean, force: :boolean
46
+ def install(name) # rubocop:disable Metrics/MethodLength
48
47
  initialize_thorfiles
49
48
 
50
- # If a directory name is provided as the argument, look for a 'main.thor'
51
- # command in said directory.
52
- begin
53
- if File.directory?(File.expand_path(name))
54
- base = File.join(name, "main.thor")
55
- package = :directory
56
- contents = open(base, &:read)
57
- else
58
- base = name
59
- package = :file
60
- contents = open(name, &:read)
49
+ is_uri = name =~ %r{^https?\://}
50
+
51
+ if is_uri
52
+ base = name
53
+ package = :file
54
+ require "open-uri"
55
+ begin
56
+ contents = URI.open(name, &:read)
57
+ rescue OpenURI::HTTPError
58
+ raise Error, "Error opening URI '#{name}'"
59
+ end
60
+ else
61
+ # If a directory name is provided as the argument, look for a 'main.thor'
62
+ # command in said directory.
63
+ begin
64
+ if File.directory?(File.expand_path(name))
65
+ base = File.join(name, "main.thor")
66
+ package = :directory
67
+ contents = File.open(base, &:read)
68
+ else
69
+ base = name
70
+ package = :file
71
+ require "open-uri"
72
+ contents = URI.open(name, &:read)
73
+ end
74
+ rescue Errno::ENOENT
75
+ raise Error, "Error opening file '#{name}'"
61
76
  end
62
- rescue OpenURI::HTTPError
63
- raise Error, "Error opening URI '#{name}'"
64
- rescue Errno::ENOENT
65
- raise Error, "Error opening file '#{name}'"
66
77
  end
67
78
 
68
- say "Your Bundler::Thorfile contains:"
79
+ say "Your Thorfile contains:"
69
80
  say contents
70
81
 
71
82
  unless options["force"]
@@ -83,16 +94,16 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
83
94
  as = basename if as.empty?
84
95
  end
85
96
 
86
- location = if options[:relative] || name =~ %r{^https?://}
97
+ location = if options[:relative] || is_uri
87
98
  name
88
99
  else
89
100
  File.expand_path(name)
90
101
  end
91
102
 
92
103
  thor_yaml[as] = {
93
- :filename => Digest(:MD5).hexdigest(name + as),
94
- :location => location,
95
- :namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
104
+ filename: Digest::SHA256.hexdigest(name + as),
105
+ location: location,
106
+ namespaces: Bundler::Thor::Util.namespaces_in_content(contents, base)
96
107
  }
97
108
 
98
109
  save_yaml(thor_yaml)
@@ -111,7 +122,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
111
122
 
112
123
  desc "version", "Show Bundler::Thor version"
113
124
  def version
114
- require "bundler/vendor/thor/lib/thor/version"
125
+ require_relative "version"
115
126
  say "Bundler::Thor #{Bundler::Thor::VERSION}"
116
127
  end
117
128
 
@@ -153,14 +164,14 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
153
164
  end
154
165
 
155
166
  desc "installed", "List the installed Bundler::Thor modules and commands"
156
- method_options :internal => :boolean
167
+ method_options internal: :boolean
157
168
  def installed
158
169
  initialize_thorfiles(nil, true)
159
170
  display_klasses(true, options["internal"])
160
171
  end
161
172
 
162
173
  desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)"
163
- method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean
174
+ method_options substring: :boolean, group: :string, all: :boolean, debug: :boolean
164
175
  def list(search = "")
165
176
  initialize_thorfiles
166
177
 
@@ -204,7 +215,7 @@ private
204
215
  File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
205
216
  end
206
217
 
207
- # Load the Bundler::Thorfiles. If relevant_to is supplied, looks for specific files
218
+ # Load the Thorfiles. If relevant_to is supplied, looks for specific files
208
219
  # in the thor_root instead of loading them all.
209
220
  #
210
221
  # By default, it also traverses the current path until find Bundler::Thor files, as
@@ -217,11 +228,11 @@ private
217
228
  end
218
229
  end
219
230
 
220
- # Finds Bundler::Thorfiles by traversing from your current directory down to the root
231
+ # Finds Thorfiles by traversing from your current directory down to the root
221
232
  # directory of your system. If at any time we find a Bundler::Thor file, we stop.
222
233
  #
223
- # We also ensure that system-wide Bundler::Thorfiles are loaded first, so local
224
- # Bundler::Thorfiles can override them.
234
+ # We also ensure that system-wide Thorfiles are loaded first, so local
235
+ # Thorfiles can override them.
225
236
  #
226
237
  # ==== Example
227
238
  #
@@ -229,7 +240,7 @@ private
229
240
  #
230
241
  # 1. /Users/wycats/dev/thor
231
242
  # 2. /Users/wycats/dev
232
- # 3. /Users/wycats <-- we find a Bundler::Thorfile here, so we stop
243
+ # 3. /Users/wycats <-- we find a Thorfile here, so we stop
233
244
  #
234
245
  # Suppose we start at c:\Documents and Settings\james\dev\thor ...
235
246
  #
@@ -237,7 +248,7 @@ private
237
248
  # 2. c:\Documents and Settings\james\dev
238
249
  # 3. c:\Documents and Settings\james
239
250
  # 4. c:\Documents and Settings
240
- # 5. c:\ <-- no Bundler::Thorfiles found!
251
+ # 5. c:\ <-- no Thorfiles found!
241
252
  #
242
253
  def thorfiles(relevant_to = nil, skip_lookup = false)
243
254
  thorfiles = []
@@ -258,7 +269,7 @@ private
258
269
  end
259
270
  end
260
271
 
261
- # Load Bundler::Thorfiles relevant to the given method. If you provide "foo:bar" it
272
+ # Load Thorfiles relevant to the given method. If you provide "foo:bar" it
262
273
  # will load all thor files in the thor.yaml that has "foo" e "foo:bar"
263
274
  # namespaces registered.
264
275
  #
@@ -302,7 +313,7 @@ private
302
313
  say shell.set_color(namespace, :blue, true)
303
314
  say "-" * namespace.size
304
315
 
305
- print_table(list, :truncate => true)
316
+ print_table(list, truncate: true)
306
317
  say
307
318
  end
308
319
  alias_method :display_tasks, :display_commands
@@ -1,3 +1,7 @@
1
+ require_relative "column_printer"
2
+ require_relative "table_printer"
3
+ require_relative "wrapped_printer"
4
+
1
5
  class Bundler::Thor
2
6
  module Shell
3
7
  class Basic
@@ -45,6 +49,10 @@ class Bundler::Thor
45
49
 
46
50
  # Asks something to the user and receives a response.
47
51
  #
52
+ # If a default value is specified it will be presented to the user
53
+ # and allows them to select that value with an empty response. This
54
+ # option is ignored when limited answers are supplied.
55
+ #
48
56
  # If asked to limit the correct responses, you can pass in an
49
57
  # array of acceptable answers. If one of those is not supplied,
50
58
  # they will be shown a message stating that one of those answers
@@ -59,13 +67,15 @@ class Bundler::Thor
59
67
  # Readline.
60
68
  #
61
69
  # ==== Example
62
- # ask("What is your name?")
70
+ # ask("What is your name?")
71
+ #
72
+ # ask("What is the planet furthest from the sun?", :default => "Neptune")
63
73
  #
64
- # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
74
+ # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
65
75
  #
66
- # ask("What is your password?", :echo => false)
76
+ # ask("What is your password?", :echo => false)
67
77
  #
68
- # ask("Where should the file be saved?", :path => true)
78
+ # ask("Where should the file be saved?", :path => true)
69
79
  #
70
80
  def ask(statement, *args)
71
81
  options = args.last.is_a?(Hash) ? args.pop : {}
@@ -83,9 +93,11 @@ class Bundler::Thor
83
93
  # are passed straight to puts (behavior got from Highline).
84
94
  #
85
95
  # ==== Example
86
- # say("I know you knew that.")
96
+ # say("I know you knew that.")
87
97
  #
88
98
  def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
99
+ return if quiet?
100
+
89
101
  buffer = prepare_message(message, *color)
90
102
  buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
91
103
 
@@ -93,6 +105,23 @@ class Bundler::Thor
93
105
  stdout.flush
94
106
  end
95
107
 
108
+ # Say (print) an error to the user. If the sentence ends with a whitespace
109
+ # or tab character, a new line is not appended (print + flush). Otherwise
110
+ # are passed straight to puts (behavior got from Highline).
111
+ #
112
+ # ==== Example
113
+ # say_error("error: something went wrong")
114
+ #
115
+ def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
116
+ return if quiet?
117
+
118
+ buffer = prepare_message(message, *color)
119
+ buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
120
+
121
+ stderr.print(buffer)
122
+ stderr.flush
123
+ end
124
+
96
125
  # Say a status with the given color and appends the message. Since this
97
126
  # method is used frequently by actions, it allows nil or false to be given
98
127
  # in log_status, avoiding the message from being shown. If a Symbol is
@@ -101,30 +130,31 @@ class Bundler::Thor
101
130
  def say_status(status, message, log_status = true)
102
131
  return if quiet? || log_status == false
103
132
  spaces = " " * (padding + 1)
104
- color = log_status.is_a?(Symbol) ? log_status : :green
105
-
106
133
  status = status.to_s.rjust(12)
134
+ margin = " " * status.length + spaces
135
+
136
+ color = log_status.is_a?(Symbol) ? log_status : :green
107
137
  status = set_color status, color, true if color
108
138
 
109
- buffer = "#{status}#{spaces}#{message}"
110
- buffer = "#{buffer}\n" unless buffer.end_with?("\n")
139
+ message = message.to_s.chomp.gsub(/(?<!\A)^/, margin)
140
+ buffer = "#{status}#{spaces}#{message}\n"
111
141
 
112
142
  stdout.print(buffer)
113
143
  stdout.flush
114
144
  end
115
145
 
116
- # Make a question the to user and returns true if the user replies "y" or
146
+ # Asks the user a question and returns true if the user replies "y" or
117
147
  # "yes".
118
148
  #
119
149
  def yes?(statement, color = nil)
120
- !!(ask(statement, color, :add_to_history => false) =~ is?(:yes))
150
+ !!(ask(statement, color, add_to_history: false) =~ is?(:yes))
121
151
  end
122
152
 
123
- # Make a question the to user and returns true if the user replies "n" or
153
+ # Asks the user a question and returns true if the user replies "n" or
124
154
  # "no".
125
155
  #
126
156
  def no?(statement, color = nil)
127
- !!(ask(statement, color, :add_to_history => false) =~ is?(:no))
157
+ !!(ask(statement, color, add_to_history: false) =~ is?(:no))
128
158
  end
129
159
 
130
160
  # Prints values in columns
@@ -133,16 +163,8 @@ class Bundler::Thor
133
163
  # Array[String, String, ...]
134
164
  #
135
165
  def print_in_columns(array)
136
- return if array.empty?
137
- colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
138
- array.each_with_index do |value, index|
139
- # Don't output trailing spaces when printing the last column
140
- if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
141
- stdout.puts value
142
- else
143
- stdout.printf("%-#{colwidth}s", value)
144
- end
145
- end
166
+ printer = ColumnPrinter.new(stdout)
167
+ printer.print(array)
146
168
  end
147
169
 
148
170
  # Prints a table.
@@ -153,58 +175,11 @@ class Bundler::Thor
153
175
  # ==== Options
154
176
  # indent<Integer>:: Indent the first column by indent value.
155
177
  # colwidth<Integer>:: Force the first column to colwidth spaces wide.
178
+ # borders<Boolean>:: Adds ascii borders.
156
179
  #
157
- def print_table(array, options = {}) # rubocop:disable MethodLength
158
- return if array.empty?
159
-
160
- formats = []
161
- indent = options[:indent].to_i
162
- colwidth = options[:colwidth]
163
- options[:truncate] = terminal_width if options[:truncate] == true
164
-
165
- formats << "%-#{colwidth + 2}s".dup if colwidth
166
- start = colwidth ? 1 : 0
167
-
168
- colcount = array.max { |a, b| a.size <=> b.size }.size
169
-
170
- maximas = []
171
-
172
- start.upto(colcount - 1) do |index|
173
- maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
174
- maximas << maxima
175
- formats << if index == colcount - 1
176
- # Don't output 2 trailing spaces when printing the last column
177
- "%-s".dup
178
- else
179
- "%-#{maxima + 2}s".dup
180
- end
181
- end
182
-
183
- formats[0] = formats[0].insert(0, " " * indent)
184
- formats << "%s"
185
-
186
- array.each do |row|
187
- sentence = "".dup
188
-
189
- row.each_with_index do |column, index|
190
- maxima = maximas[index]
191
-
192
- f = if column.is_a?(Numeric)
193
- if index == row.size - 1
194
- # Don't output 2 trailing spaces when printing the last column
195
- "%#{maxima}s"
196
- else
197
- "%#{maxima}s "
198
- end
199
- else
200
- formats[index]
201
- end
202
- sentence << f % column.to_s
203
- end
204
-
205
- sentence = truncate(sentence, options[:truncate]) if options[:truncate]
206
- stdout.puts sentence
207
- end
180
+ def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
181
+ printer = TablePrinter.new(stdout, options)
182
+ printer.print(array)
208
183
  end
209
184
 
210
185
  # Prints a long string, word-wrapping the text to the current width of the
@@ -217,20 +192,8 @@ class Bundler::Thor
217
192
  # indent<Integer>:: Indent each line of the printed paragraph by indent value.
218
193
  #
219
194
  def print_wrapped(message, options = {})
220
- indent = options[:indent] || 0
221
- width = terminal_width - indent
222
- paras = message.split("\n\n")
223
-
224
- paras.map! do |unwrapped|
225
- unwrapped.strip.tr("\n", " ").squeeze(" ").gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }
226
- end
227
-
228
- paras.each do |para|
229
- para.split("\n").each do |line|
230
- stdout.puts line.insert(0, " " * indent)
231
- end
232
- stdout.puts unless para == paras.last
233
- end
195
+ printer = WrappedPrinter.new(stdout, options)
196
+ printer.print(message)
234
197
  end
235
198
 
236
199
  # Deals with file collision and returns true if the file should be
@@ -239,16 +202,16 @@ class Bundler::Thor
239
202
  #
240
203
  # ==== Parameters
241
204
  # destination<String>:: the destination file to solve conflicts
242
- # block<Proc>:: an optional block that returns the value to be used in diff
205
+ # block<Proc>:: an optional block that returns the value to be used in diff and merge
243
206
  #
244
207
  def file_collision(destination)
245
208
  return true if @always_force
246
- options = block_given? ? "[Ynaqdh]" : "[Ynaqh]"
209
+ options = block_given? ? "[Ynaqdhm]" : "[Ynaqh]"
247
210
 
248
211
  loop do
249
212
  answer = ask(
250
213
  %[Overwrite #{destination}? (enter "h" for help) #{options}],
251
- :add_to_history => false
214
+ add_to_history: false
252
215
  )
253
216
 
254
217
  case answer
@@ -267,25 +230,19 @@ class Bundler::Thor
267
230
  when is?(:diff)
268
231
  show_diff(destination, yield) if block_given?
269
232
  say "Retrying..."
233
+ when is?(:merge)
234
+ if block_given? && !merge_tool.empty?
235
+ merge(destination, yield)
236
+ return nil
237
+ end
238
+
239
+ say "Please specify merge tool to `THOR_MERGE` env."
270
240
  else
271
- say file_collision_help
241
+ say file_collision_help(block_given?)
272
242
  end
273
243
  end
274
244
  end
275
245
 
276
- # This code was copied from Rake, available under MIT-LICENSE
277
- # Copyright (c) 2003, 2004 Jim Weirich
278
- def terminal_width
279
- result = if ENV["THOR_COLUMNS"]
280
- ENV["THOR_COLUMNS"].to_i
281
- else
282
- unix? ? dynamic_width : 80
283
- end
284
- result < 10 ? 80 : result
285
- rescue
286
- 80
287
- end
288
-
289
246
  # Called if something goes wrong during the execution. This is used by Bundler::Thor
290
247
  # internally and should not be used inside your scripts. If something went
291
248
  # wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
@@ -336,15 +293,21 @@ class Bundler::Thor
336
293
  end
337
294
  end
338
295
 
339
- def file_collision_help #:nodoc:
340
- <<-HELP
296
+ def file_collision_help(block_given) #:nodoc:
297
+ help = <<-HELP
341
298
  Y - yes, overwrite
342
299
  n - no, do not overwrite
343
300
  a - all, overwrite this and all others
344
301
  q - quit, abort
345
- d - diff, show the differences between the old and the new
346
302
  h - help, show this help
347
303
  HELP
304
+ if block_given
305
+ help << <<-HELP
306
+ d - diff, show the differences between the old and the new
307
+ m - merge, run merge tool
308
+ HELP
309
+ end
310
+ help
348
311
  end
349
312
 
350
313
  def show_diff(destination, content) #:nodoc:
@@ -362,46 +325,8 @@ class Bundler::Thor
362
325
  mute? || (base && base.options[:quiet])
363
326
  end
364
327
 
365
- # Calculate the dynamic width of the terminal
366
- def dynamic_width
367
- @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
368
- end
369
-
370
- def dynamic_width_stty
371
- `stty size 2>/dev/null`.split[1].to_i
372
- end
373
-
374
- def dynamic_width_tput
375
- `tput cols 2>/dev/null`.to_i
376
- end
377
-
378
328
  def unix?
379
- RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
380
- end
381
-
382
- def truncate(string, width)
383
- as_unicode do
384
- chars = string.chars.to_a
385
- if chars.length <= width
386
- chars.join
387
- else
388
- chars[0, width - 3].join + "..."
389
- end
390
- end
391
- end
392
-
393
- if "".respond_to?(:encode)
394
- def as_unicode
395
- yield
396
- end
397
- else
398
- def as_unicode
399
- old = $KCODE
400
- $KCODE = "U"
401
- yield
402
- ensure
403
- $KCODE = old
404
- end
329
+ Terminal.unix?
405
330
  end
406
331
 
407
332
  def ask_simply(statement, color, options)
@@ -423,15 +348,41 @@ class Bundler::Thor
423
348
 
424
349
  def ask_filtered(statement, color, options)
425
350
  answer_set = options[:limited_to]
351
+ case_insensitive = options.fetch(:case_insensitive, false)
426
352
  correct_answer = nil
427
353
  until correct_answer
428
354
  answers = answer_set.join(", ")
429
355
  answer = ask_simply("#{statement} [#{answers}]", color, options)
430
- correct_answer = answer_set.include?(answer) ? answer : nil
356
+ correct_answer = answer_match(answer_set, answer, case_insensitive)
431
357
  say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
432
358
  end
433
359
  correct_answer
434
360
  end
361
+
362
+ def answer_match(possibilities, answer, case_insensitive)
363
+ if case_insensitive
364
+ possibilities.detect{ |possibility| possibility.downcase == answer.downcase }
365
+ else
366
+ possibilities.detect{ |possibility| possibility == answer }
367
+ end
368
+ end
369
+
370
+ def merge(destination, content) #:nodoc:
371
+ require "tempfile"
372
+ Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
373
+ temp.write content
374
+ temp.rewind
375
+ system %(#{merge_tool} "#{temp.path}" "#{destination}")
376
+ end
377
+ end
378
+
379
+ def merge_tool #:nodoc:
380
+ @merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
381
+ end
382
+
383
+ def git_merge_tool #:nodoc:
384
+ `git config merge.tool`.rstrip rescue ""
385
+ end
435
386
  end
436
387
  end
437
388
  end
@@ -1,4 +1,4 @@
1
- require "bundler/vendor/thor/lib/thor/shell/basic"
1
+ require_relative "basic"
2
2
 
3
3
  class Bundler::Thor
4
4
  module Shell
@@ -97,52 +97,15 @@ class Bundler::Thor
97
97
  protected
98
98
 
99
99
  def can_display_colors?
100
- stdout.tty?
100
+ are_colors_supported? && !are_colors_disabled?
101
101
  end
102
102
 
103
- # Overwrite show_diff to show diff with colors if Diff::LCS is
104
- # available.
105
- #
106
- def show_diff(destination, content) #:nodoc:
107
- if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
108
- actual = File.binread(destination).to_s.split("\n")
109
- content = content.to_s.split("\n")
110
-
111
- Diff::LCS.sdiff(actual, content).each do |diff|
112
- output_diff_line(diff)
113
- end
114
- else
115
- super
116
- end
103
+ def are_colors_supported?
104
+ stdout.tty? && ENV["TERM"] != "dumb"
117
105
  end
118
106
 
119
- def output_diff_line(diff) #:nodoc:
120
- case diff.action
121
- when "-"
122
- say "- #{diff.old_element.chomp}", :red, true
123
- when "+"
124
- say "+ #{diff.new_element.chomp}", :green, true
125
- when "!"
126
- say "- #{diff.old_element.chomp}", :red, true
127
- say "+ #{diff.new_element.chomp}", :green, true
128
- else
129
- say " #{diff.old_element.chomp}", nil, true
130
- end
131
- end
132
-
133
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
134
- # for diff.
135
- #
136
- def diff_lcs_loaded? #:nodoc:
137
- return true if defined?(Diff::LCS)
138
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
139
-
140
- @diff_lcs_loaded = begin
141
- require "diff/lcs"
142
- true
143
- rescue LoadError
144
- false
145
- end
107
+ def are_colors_disabled?
108
+ !ENV["NO_COLOR"].nil? && !ENV["NO_COLOR"].empty?
146
109
  end
147
110
  end
148
111
  end
@@ -0,0 +1,29 @@
1
+ require_relative "terminal"
2
+
3
+ class Bundler::Thor
4
+ module Shell
5
+ class ColumnPrinter
6
+ attr_reader :stdout, :options
7
+
8
+ def initialize(stdout, options = {})
9
+ @stdout = stdout
10
+ @options = options
11
+ @indent = options[:indent].to_i
12
+ end
13
+
14
+ def print(array)
15
+ return if array.empty?
16
+ colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
17
+ array.each_with_index do |value, index|
18
+ # Don't output trailing spaces when printing the last column
19
+ if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
20
+ stdout.puts value
21
+ else
22
+ stdout.printf("%-#{colwidth}s", value)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+