rubygems-update 2.6.4 → 2.6.5

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

Potentially problematic release.


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

Files changed (288) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -24
  3. data/CODE_OF_CONDUCT.md +2 -2
  4. data/CONTRIBUTING.rdoc +1 -1
  5. data/History.txt +30 -1
  6. data/Manifest.txt +233 -3
  7. data/Rakefile +30 -1
  8. data/appveyor.yml +0 -2
  9. data/bundler/CHANGELOG.md +2407 -0
  10. data/bundler/CODE_OF_CONDUCT.md +42 -0
  11. data/bundler/CONTRIBUTING.md +36 -0
  12. data/bundler/DEVELOPMENT.md +148 -0
  13. data/bundler/ISSUES.md +100 -0
  14. data/bundler/LICENSE.md +23 -0
  15. data/bundler/README.md +40 -0
  16. data/bundler/exe/bundle +35 -0
  17. data/bundler/exe/bundle_ruby +61 -0
  18. data/bundler/exe/bundler +22 -0
  19. data/bundler/lib/bundler.rb +455 -0
  20. data/bundler/lib/bundler/capistrano.rb +17 -0
  21. data/bundler/lib/bundler/cli.rb +497 -0
  22. data/bundler/lib/bundler/cli/binstubs.rb +40 -0
  23. data/bundler/lib/bundler/cli/cache.rb +35 -0
  24. data/bundler/lib/bundler/cli/check.rb +40 -0
  25. data/bundler/lib/bundler/cli/clean.rb +26 -0
  26. data/bundler/lib/bundler/cli/common.rb +56 -0
  27. data/bundler/lib/bundler/cli/config.rb +100 -0
  28. data/bundler/lib/bundler/cli/console.rb +39 -0
  29. data/bundler/lib/bundler/cli/exec.rb +82 -0
  30. data/bundler/lib/bundler/cli/gem.rb +214 -0
  31. data/bundler/lib/bundler/cli/init.rb +33 -0
  32. data/bundler/lib/bundler/cli/inject.rb +33 -0
  33. data/bundler/lib/bundler/cli/install.rb +225 -0
  34. data/bundler/lib/bundler/cli/lock.rb +48 -0
  35. data/bundler/lib/bundler/cli/open.rb +25 -0
  36. data/bundler/lib/bundler/cli/outdated.rb +151 -0
  37. data/bundler/lib/bundler/cli/package.rb +46 -0
  38. data/bundler/lib/bundler/cli/platform.rb +45 -0
  39. data/bundler/lib/bundler/cli/plugin.rb +23 -0
  40. data/bundler/lib/bundler/cli/show.rb +75 -0
  41. data/bundler/lib/bundler/cli/update.rb +72 -0
  42. data/bundler/lib/bundler/cli/viz.rb +27 -0
  43. data/bundler/lib/bundler/constants.rb +6 -0
  44. data/bundler/lib/bundler/current_ruby.rb +84 -0
  45. data/bundler/lib/bundler/definition.rb +744 -0
  46. data/bundler/lib/bundler/dep_proxy.rb +46 -0
  47. data/bundler/lib/bundler/dependency.rb +127 -0
  48. data/bundler/lib/bundler/deployment.rb +63 -0
  49. data/bundler/lib/bundler/deprecate.rb +16 -0
  50. data/bundler/lib/bundler/dsl.rb +512 -0
  51. data/bundler/lib/bundler/endpoint_specification.rb +129 -0
  52. data/bundler/lib/bundler/env.rb +83 -0
  53. data/bundler/lib/bundler/environment.rb +42 -0
  54. data/bundler/lib/bundler/environment_preserver.rb +38 -0
  55. data/bundler/lib/bundler/errors.rb +124 -0
  56. data/bundler/lib/bundler/fetcher.rb +304 -0
  57. data/bundler/lib/bundler/fetcher/base.rb +41 -0
  58. data/bundler/lib/bundler/fetcher/compact_index.rb +103 -0
  59. data/bundler/lib/bundler/fetcher/dependency.rb +92 -0
  60. data/bundler/lib/bundler/fetcher/downloader.rb +66 -0
  61. data/bundler/lib/bundler/fetcher/index.rb +51 -0
  62. data/bundler/lib/bundler/friendly_errors.rb +103 -0
  63. data/bundler/lib/bundler/gem_helper.rb +188 -0
  64. data/bundler/lib/bundler/gem_helpers.rb +32 -0
  65. data/bundler/lib/bundler/gem_remote_fetcher.rb +42 -0
  66. data/bundler/lib/bundler/gem_tasks.rb +6 -0
  67. data/bundler/lib/bundler/graph.rb +172 -0
  68. data/bundler/lib/bundler/index.rb +191 -0
  69. data/bundler/lib/bundler/injector.rb +63 -0
  70. data/bundler/lib/bundler/inline.rb +74 -0
  71. data/bundler/lib/bundler/installer.rb +217 -0
  72. data/bundler/lib/bundler/installer/gem_installer.rb +77 -0
  73. data/bundler/lib/bundler/installer/parallel_installer.rb +126 -0
  74. data/bundler/lib/bundler/installer/standalone.rb +52 -0
  75. data/bundler/lib/bundler/lazy_specification.rb +85 -0
  76. data/bundler/lib/bundler/lockfile_parser.rb +233 -0
  77. data/bundler/lib/bundler/match_platform.rb +14 -0
  78. data/bundler/lib/bundler/mirror.rb +218 -0
  79. data/bundler/lib/bundler/plugin.rb +156 -0
  80. data/bundler/lib/bundler/plugin/api.rb +56 -0
  81. data/bundler/lib/bundler/plugin/dsl.rb +29 -0
  82. data/bundler/lib/bundler/plugin/index.rb +88 -0
  83. data/bundler/lib/bundler/plugin/installer.rb +99 -0
  84. data/bundler/lib/bundler/plugin/installer/git.rb +38 -0
  85. data/bundler/lib/bundler/plugin/installer/rubygems.rb +27 -0
  86. data/bundler/lib/bundler/plugin/source_list.rb +24 -0
  87. data/bundler/lib/bundler/postit_trampoline.rb +57 -0
  88. data/bundler/lib/bundler/psyched_yaml.rb +27 -0
  89. data/bundler/lib/bundler/remote_specification.rb +85 -0
  90. data/bundler/lib/bundler/resolver.rb +368 -0
  91. data/bundler/lib/bundler/retry.rb +61 -0
  92. data/bundler/lib/bundler/ruby_dsl.rb +17 -0
  93. data/bundler/lib/bundler/ruby_version.rb +140 -0
  94. data/bundler/lib/bundler/rubygems_ext.rb +178 -0
  95. data/bundler/lib/bundler/rubygems_gem_installer.rb +10 -0
  96. data/bundler/lib/bundler/rubygems_integration.rb +710 -0
  97. data/bundler/lib/bundler/runtime.rb +282 -0
  98. data/bundler/lib/bundler/settings.rb +259 -0
  99. data/bundler/lib/bundler/setup.rb +28 -0
  100. data/bundler/lib/bundler/shared_helpers.rb +212 -0
  101. data/bundler/lib/bundler/similarity_detector.rb +62 -0
  102. data/bundler/lib/bundler/source.rb +37 -0
  103. data/bundler/lib/bundler/source/gemspec.rb +13 -0
  104. data/bundler/lib/bundler/source/git.rb +297 -0
  105. data/bundler/lib/bundler/source/git/git_proxy.rb +218 -0
  106. data/bundler/lib/bundler/source/path.rb +245 -0
  107. data/bundler/lib/bundler/source/path/installer.rb +44 -0
  108. data/bundler/lib/bundler/source/rubygems.rb +450 -0
  109. data/bundler/lib/bundler/source/rubygems/remote.rb +59 -0
  110. data/bundler/lib/bundler/source_list.rb +106 -0
  111. data/bundler/lib/bundler/spec_set.rb +157 -0
  112. data/bundler/lib/bundler/ssl_certs/.document +1 -0
  113. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +65 -0
  114. data/bundler/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  115. data/bundler/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  116. data/{lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot-2048.pem → bundler/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem} +0 -0
  117. data/bundler/lib/bundler/stub_specification.rb +24 -0
  118. data/bundler/lib/bundler/templates/Executable +17 -0
  119. data/bundler/lib/bundler/templates/Executable.standalone +12 -0
  120. data/bundler/lib/bundler/templates/Gemfile +5 -0
  121. data/bundler/lib/bundler/templates/newgem/.travis.yml.tt +5 -0
  122. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
  123. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  124. data/bundler/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
  125. data/bundler/lib/bundler/templates/newgem/README.md.tt +41 -0
  126. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +29 -0
  127. data/bundler/lib/bundler/templates/newgem/bin/console.tt +14 -0
  128. data/bundler/lib/bundler/templates/newgem/bin/setup.tt +8 -0
  129. data/bundler/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  130. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
  131. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  132. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  133. data/bundler/lib/bundler/templates/newgem/gitignore.tt +16 -0
  134. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
  135. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  136. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +46 -0
  137. data/bundler/lib/bundler/templates/newgem/rspec.tt +2 -0
  138. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
  139. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
  140. data/bundler/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
  141. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
  142. data/bundler/lib/bundler/ui.rb +8 -0
  143. data/bundler/lib/bundler/ui/rg_proxy.rb +18 -0
  144. data/bundler/lib/bundler/ui/shell.rb +114 -0
  145. data/bundler/lib/bundler/ui/silent.rb +48 -0
  146. data/bundler/lib/bundler/uri_credentials_filter.rb +36 -0
  147. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +79 -0
  148. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +98 -0
  149. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +80 -0
  150. data/bundler/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +4 -0
  151. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +10 -0
  152. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +50 -0
  153. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +80 -0
  154. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +203 -0
  155. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +35 -0
  156. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +58 -0
  157. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +61 -0
  158. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +53 -0
  159. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +114 -0
  160. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +45 -0
  161. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +35 -0
  162. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +123 -0
  163. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -0
  164. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +5 -0
  165. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +100 -0
  166. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +65 -0
  167. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +460 -0
  168. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +45 -0
  169. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +54 -0
  170. data/bundler/lib/bundler/vendor/net/http/faster.rb +26 -0
  171. data/bundler/lib/bundler/vendor/net/http/persistent.rb +1230 -0
  172. data/bundler/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
  173. data/bundler/lib/bundler/vendor/postit/lib/postit.rb +15 -0
  174. data/bundler/lib/bundler/vendor/postit/lib/postit/environment.rb +44 -0
  175. data/bundler/lib/bundler/vendor/postit/lib/postit/installer.rb +28 -0
  176. data/bundler/lib/bundler/vendor/postit/lib/postit/parser.rb +21 -0
  177. data/bundler/lib/bundler/vendor/postit/lib/postit/setup.rb +12 -0
  178. data/bundler/lib/bundler/vendor/postit/lib/postit/version.rb +3 -0
  179. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +484 -0
  180. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +319 -0
  181. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  182. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +59 -0
  183. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
  184. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
  185. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
  186. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
  187. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +656 -0
  188. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +133 -0
  189. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  190. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
  191. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
  192. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +32 -0
  193. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
  194. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
  195. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
  196. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
  197. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  198. data/bundler/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  199. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +73 -0
  200. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  201. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +125 -0
  202. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +218 -0
  203. data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
  204. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +322 -0
  205. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
  206. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +421 -0
  207. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
  208. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
  209. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +267 -0
  210. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
  211. data/bundler/lib/bundler/vendored_molinillo.rb +3 -0
  212. data/bundler/lib/bundler/vendored_persistent.rb +12 -0
  213. data/bundler/lib/bundler/vendored_thor.rb +4 -0
  214. data/bundler/lib/bundler/version.rb +11 -0
  215. data/bundler/lib/bundler/vlad.rb +12 -0
  216. data/bundler/lib/bundler/worker.rb +82 -0
  217. data/bundler/lib/bundler/yaml_serializer.rb +67 -0
  218. data/bundler/man/bundle-config.ronn +193 -0
  219. data/bundler/man/bundle-exec.ronn +136 -0
  220. data/bundler/man/bundle-gem.ronn +77 -0
  221. data/bundler/man/bundle-install.ronn +404 -0
  222. data/bundler/man/bundle-lock.ronn +47 -0
  223. data/bundler/man/bundle-package.ronn +67 -0
  224. data/bundler/man/bundle-platform.ronn +42 -0
  225. data/bundler/man/bundle-update.ronn +194 -0
  226. data/bundler/man/bundle.ronn +98 -0
  227. data/bundler/man/gemfile.5.ronn +499 -0
  228. data/bundler/man/index.txt +8 -0
  229. data/lib/rubygems.rb +42 -2
  230. data/lib/rubygems/config_file.rb +1 -1
  231. data/lib/rubygems/defaults.rb +18 -0
  232. data/lib/rubygems/installer.rb +1 -0
  233. data/lib/rubygems/package.rb +3 -1
  234. data/lib/rubygems/package/tar_writer.rb +10 -16
  235. data/lib/rubygems/remote_fetcher.rb +1 -15
  236. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +50 -0
  237. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +80 -0
  238. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +57 -145
  239. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +35 -0
  240. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +58 -0
  241. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +61 -0
  242. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +53 -0
  243. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +114 -0
  244. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +45 -0
  245. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +35 -0
  246. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +123 -0
  247. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +1 -1
  248. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  249. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +55 -54
  250. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +4 -2
  251. data/lib/rubygems/security/signer.rb +2 -0
  252. data/lib/rubygems/specification.rb +4 -4
  253. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  254. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  255. data/test/rubygems/alternate_cert.pem +10 -9
  256. data/test/rubygems/alternate_cert_32.pem +10 -9
  257. data/test/rubygems/child_cert.pem +11 -9
  258. data/test/rubygems/child_cert_32.pem +11 -9
  259. data/test/rubygems/encrypted_private_key.pem +26 -26
  260. data/test/rubygems/expired_cert.pem +9 -8
  261. data/test/rubygems/future_cert.pem +9 -8
  262. data/test/rubygems/future_cert_32.pem +9 -8
  263. data/test/rubygems/grandchild_cert.pem +11 -9
  264. data/test/rubygems/grandchild_cert_32.pem +11 -9
  265. data/test/rubygems/invalid_issuer_cert.pem +11 -9
  266. data/test/rubygems/invalid_issuer_cert_32.pem +11 -9
  267. data/test/rubygems/invalid_signer_cert.pem +10 -9
  268. data/test/rubygems/invalid_signer_cert_32.pem +10 -9
  269. data/test/rubygems/invalidchild_cert.pem +11 -9
  270. data/test/rubygems/invalidchild_cert_32.pem +11 -9
  271. data/test/rubygems/public_cert.pem +11 -9
  272. data/test/rubygems/public_cert_32.pem +10 -9
  273. data/test/rubygems/test_bundled_ca.rb +1 -1
  274. data/test/rubygems/test_gem.rb +7 -0
  275. data/test/rubygems/test_gem_installer.rb +119 -0
  276. data/test/rubygems/test_gem_package.rb +9 -3
  277. data/test/rubygems/test_gem_package_tar_writer.rb +24 -0
  278. data/test/rubygems/test_gem_remote_fetcher.rb +0 -12
  279. data/test/rubygems/test_gem_security_signer.rb +8 -0
  280. data/test/rubygems/test_gem_specification.rb +1 -1
  281. data/test/rubygems/wrong_key_cert.pem +10 -9
  282. data/test/rubygems/wrong_key_cert_32.pem +10 -9
  283. data/util/ci +73 -0
  284. data/util/create_certs.rb +64 -49
  285. data/util/update_bundled_ca_certificates.rb +23 -2
  286. metadata +257 -19
  287. data/lib/gauntlet_rubygems.rb +0 -51
  288. data/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRoot.pem +0 -18
@@ -0,0 +1,81 @@
1
+ require "rbconfig"
2
+
3
+ class Bundler::Thor
4
+ module Base
5
+ class << self
6
+ attr_writer :shell
7
+
8
+ # Returns the shell used in all Bundler::Thor classes. If you are in a Unix platform
9
+ # it will use a colored log, otherwise it will use a basic one without color.
10
+ #
11
+ def shell
12
+ @shell ||= if ENV["THOR_SHELL"] && ENV["THOR_SHELL"].size > 0
13
+ Bundler::Thor::Shell.const_get(ENV["THOR_SHELL"])
14
+ elsif RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ && !ENV["ANSICON"]
15
+ Bundler::Thor::Shell::Basic
16
+ else
17
+ Bundler::Thor::Shell::Color
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ module Shell
24
+ SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
25
+ attr_writer :shell
26
+
27
+ autoload :Basic, "bundler/vendor/thor/lib/thor/shell/basic"
28
+ autoload :Color, "bundler/vendor/thor/lib/thor/shell/color"
29
+ autoload :HTML, "bundler/vendor/thor/lib/thor/shell/html"
30
+
31
+ # Add shell to initialize config values.
32
+ #
33
+ # ==== Configuration
34
+ # shell<Object>:: An instance of the shell to be used.
35
+ #
36
+ # ==== Examples
37
+ #
38
+ # class MyScript < Bundler::Thor
39
+ # argument :first, :type => :numeric
40
+ # end
41
+ #
42
+ # MyScript.new [1.0], { :foo => :bar }, :shell => Bundler::Thor::Shell::Basic.new
43
+ #
44
+ def initialize(args = [], options = {}, config = {})
45
+ super
46
+ self.shell = config[:shell]
47
+ shell.base ||= self if shell.respond_to?(:base)
48
+ end
49
+
50
+ # Holds the shell for the given Bundler::Thor instance. If no shell is given,
51
+ # it gets a default shell from Bundler::Thor::Base.shell.
52
+ def shell
53
+ @shell ||= Bundler::Thor::Base.shell.new
54
+ end
55
+
56
+ # Common methods that are delegated to the shell.
57
+ SHELL_DELEGATED_METHODS.each do |method|
58
+ module_eval <<-METHOD, __FILE__, __LINE__
59
+ def #{method}(*args,&block)
60
+ shell.#{method}(*args,&block)
61
+ end
62
+ METHOD
63
+ end
64
+
65
+ # Yields the given block with padding.
66
+ def with_padding
67
+ shell.padding += 1
68
+ yield
69
+ ensure
70
+ shell.padding -= 1
71
+ end
72
+
73
+ protected
74
+
75
+ # Allow shell to be shared between invocations.
76
+ #
77
+ def _shared_configuration #:nodoc:
78
+ super.merge!(:shell => shell)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,421 @@
1
+ require "tempfile"
2
+ require "io/console" if RUBY_VERSION > "1.9.2"
3
+
4
+ class Bundler::Thor
5
+ module Shell
6
+ class Basic # rubocop:disable ClassLength
7
+ attr_accessor :base
8
+ attr_reader :padding
9
+
10
+ # Initialize base, mute and padding to nil.
11
+ #
12
+ def initialize #:nodoc:
13
+ @base, @mute, @padding, @always_force = nil, false, 0, false
14
+ end
15
+
16
+ # Mute everything that's inside given block
17
+ #
18
+ def mute
19
+ @mute = true
20
+ yield
21
+ ensure
22
+ @mute = false
23
+ end
24
+
25
+ # Check if base is muted
26
+ #
27
+ def mute? # rubocop:disable TrivialAccessors
28
+ @mute
29
+ end
30
+
31
+ # Sets the output padding, not allowing less than zero values.
32
+ #
33
+ def padding=(value)
34
+ @padding = [0, value].max
35
+ end
36
+
37
+ # Asks something to the user and receives a response.
38
+ #
39
+ # If asked to limit the correct responses, you can pass in an
40
+ # array of acceptable answers. If one of those is not supplied,
41
+ # they will be shown a message stating that one of those answers
42
+ # must be given and re-asked the question.
43
+ #
44
+ # If asking for sensitive information, the :echo option can be set
45
+ # to false to mask user input from $stdin.
46
+ #
47
+ # If the required input is a path, then set the path option to
48
+ # true. This will enable tab completion for file paths relative
49
+ # to the current working directory on systems that support
50
+ # Readline.
51
+ #
52
+ # ==== Example
53
+ # ask("What is your name?")
54
+ #
55
+ # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
56
+ #
57
+ # ask("What is your password?", :echo => false)
58
+ #
59
+ # ask("Where should the file be saved?", :path => true)
60
+ #
61
+ def ask(statement, *args)
62
+ options = args.last.is_a?(Hash) ? args.pop : {}
63
+ color = args.first
64
+
65
+ if options[:limited_to]
66
+ ask_filtered(statement, color, options)
67
+ else
68
+ ask_simply(statement, color, options)
69
+ end
70
+ end
71
+
72
+ # Say (print) something to the user. If the sentence ends with a whitespace
73
+ # or tab character, a new line is not appended (print + flush). Otherwise
74
+ # are passed straight to puts (behavior got from Highline).
75
+ #
76
+ # ==== Example
77
+ # say("I know you knew that.")
78
+ #
79
+ def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
80
+ buffer = prepare_message(message, *color)
81
+ buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
82
+
83
+ stdout.print(buffer)
84
+ stdout.flush
85
+ end
86
+
87
+ # Say a status with the given color and appends the message. Since this
88
+ # method is used frequently by actions, it allows nil or false to be given
89
+ # in log_status, avoiding the message from being shown. If a Symbol is
90
+ # given in log_status, it's used as the color.
91
+ #
92
+ def say_status(status, message, log_status = true)
93
+ return if quiet? || log_status == false
94
+ spaces = " " * (padding + 1)
95
+ color = log_status.is_a?(Symbol) ? log_status : :green
96
+
97
+ status = status.to_s.rjust(12)
98
+ status = set_color status, color, true if color
99
+
100
+ buffer = "#{status}#{spaces}#{message}"
101
+ buffer << "\n" unless buffer.end_with?("\n")
102
+
103
+ stdout.print(buffer)
104
+ stdout.flush
105
+ end
106
+
107
+ # Make a question the to user and returns true if the user replies "y" or
108
+ # "yes".
109
+ #
110
+ def yes?(statement, color = nil)
111
+ !!(ask(statement, color, :add_to_history => false) =~ is?(:yes))
112
+ end
113
+
114
+ # Make a question the to user and returns true if the user replies "n" or
115
+ # "no".
116
+ #
117
+ def no?(statement, color = nil)
118
+ !!(ask(statement, color, :add_to_history => false) =~ is?(:no))
119
+ end
120
+
121
+ # Prints values in columns
122
+ #
123
+ # ==== Parameters
124
+ # Array[String, String, ...]
125
+ #
126
+ def print_in_columns(array)
127
+ return if array.empty?
128
+ colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
129
+ array.each_with_index do |value, index|
130
+ # Don't output trailing spaces when printing the last column
131
+ if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
132
+ stdout.puts value
133
+ else
134
+ stdout.printf("%-#{colwidth}s", value)
135
+ end
136
+ end
137
+ end
138
+
139
+ # Prints a table.
140
+ #
141
+ # ==== Parameters
142
+ # Array[Array[String, String, ...]]
143
+ #
144
+ # ==== Options
145
+ # indent<Integer>:: Indent the first column by indent value.
146
+ # colwidth<Integer>:: Force the first column to colwidth spaces wide.
147
+ #
148
+ def print_table(array, options = {}) # rubocop:disable MethodLength
149
+ return if array.empty?
150
+
151
+ formats, indent, colwidth = [], options[:indent].to_i, options[:colwidth]
152
+ options[:truncate] = terminal_width if options[:truncate] == true
153
+
154
+ formats << "%-#{colwidth + 2}s" if colwidth
155
+ start = colwidth ? 1 : 0
156
+
157
+ colcount = array.max { |a, b| a.size <=> b.size }.size
158
+
159
+ maximas = []
160
+
161
+ start.upto(colcount - 1) do |index|
162
+ maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
163
+ maximas << maxima
164
+ if index == colcount - 1
165
+ # Don't output 2 trailing spaces when printing the last column
166
+ formats << "%-s"
167
+ else
168
+ formats << "%-#{maxima + 2}s"
169
+ end
170
+ end
171
+
172
+ formats[0] = formats[0].insert(0, " " * indent)
173
+ formats << "%s"
174
+
175
+ array.each do |row|
176
+ sentence = ""
177
+
178
+ row.each_with_index do |column, index|
179
+ maxima = maximas[index]
180
+
181
+ if column.is_a?(Numeric)
182
+ if index == row.size - 1
183
+ # Don't output 2 trailing spaces when printing the last column
184
+ f = "%#{maxima}s"
185
+ else
186
+ f = "%#{maxima}s "
187
+ end
188
+ else
189
+ f = formats[index]
190
+ end
191
+ sentence << f % column.to_s
192
+ end
193
+
194
+ sentence = truncate(sentence, options[:truncate]) if options[:truncate]
195
+ stdout.puts sentence
196
+ end
197
+ end
198
+
199
+ # Prints a long string, word-wrapping the text to the current width of the
200
+ # terminal display. Ideal for printing heredocs.
201
+ #
202
+ # ==== Parameters
203
+ # String
204
+ #
205
+ # ==== Options
206
+ # indent<Integer>:: Indent each line of the printed paragraph by indent value.
207
+ #
208
+ def print_wrapped(message, options = {})
209
+ indent = options[:indent] || 0
210
+ width = terminal_width - indent
211
+ paras = message.split("\n\n")
212
+
213
+ paras.map! do |unwrapped|
214
+ unwrapped.strip.gsub(/\n/, " ").squeeze(" ").gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }
215
+ end
216
+
217
+ paras.each do |para|
218
+ para.split("\n").each do |line|
219
+ stdout.puts line.insert(0, " " * indent)
220
+ end
221
+ stdout.puts unless para == paras.last
222
+ end
223
+ end
224
+
225
+ # Deals with file collision and returns true if the file should be
226
+ # overwritten and false otherwise. If a block is given, it uses the block
227
+ # response as the content for the diff.
228
+ #
229
+ # ==== Parameters
230
+ # destination<String>:: the destination file to solve conflicts
231
+ # block<Proc>:: an optional block that returns the value to be used in diff
232
+ #
233
+ def file_collision(destination) # rubocop:disable MethodLength
234
+ return true if @always_force
235
+ options = block_given? ? "[Ynaqdh]" : "[Ynaqh]"
236
+
237
+ loop do
238
+ answer = ask(
239
+ %[Overwrite #{destination}? (enter "h" for help) #{options}],
240
+ :add_to_history => false
241
+ )
242
+
243
+ case answer
244
+ when is?(:yes), is?(:force), ""
245
+ return true
246
+ when is?(:no), is?(:skip)
247
+ return false
248
+ when is?(:always)
249
+ return @always_force = true
250
+ when is?(:quit)
251
+ say "Aborting..."
252
+ fail SystemExit
253
+ when is?(:diff)
254
+ show_diff(destination, yield) if block_given?
255
+ say "Retrying..."
256
+ else
257
+ say file_collision_help
258
+ end
259
+ end
260
+ end
261
+
262
+ # This code was copied from Rake, available under MIT-LICENSE
263
+ # Copyright (c) 2003, 2004 Jim Weirich
264
+ def terminal_width
265
+ if ENV["THOR_COLUMNS"]
266
+ result = ENV["THOR_COLUMNS"].to_i
267
+ else
268
+ result = unix? ? dynamic_width : 80
269
+ end
270
+ result < 10 ? 80 : result
271
+ rescue
272
+ 80
273
+ end
274
+
275
+ # Called if something goes wrong during the execution. This is used by Bundler::Thor
276
+ # internally and should not be used inside your scripts. If something went
277
+ # wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
278
+ # will be rescued and wrapped in the method below.
279
+ #
280
+ def error(statement)
281
+ stderr.puts statement
282
+ end
283
+
284
+ # Apply color to the given string with optional bold. Disabled in the
285
+ # Bundler::Thor::Shell::Basic class.
286
+ #
287
+ def set_color(string, *args) #:nodoc:
288
+ string
289
+ end
290
+
291
+ protected
292
+
293
+ def prepare_message(message, *color)
294
+ spaces = " " * padding
295
+ spaces + set_color(message.to_s, *color)
296
+ end
297
+
298
+ def can_display_colors?
299
+ false
300
+ end
301
+
302
+ def lookup_color(color)
303
+ return color unless color.is_a?(Symbol)
304
+ self.class.const_get(color.to_s.upcase)
305
+ end
306
+
307
+ def stdout
308
+ $stdout
309
+ end
310
+
311
+ def stderr
312
+ $stderr
313
+ end
314
+
315
+ def is?(value) #:nodoc:
316
+ value = value.to_s
317
+
318
+ if value.size == 1
319
+ /\A#{value}\z/i
320
+ else
321
+ /\A(#{value}|#{value[0, 1]})\z/i
322
+ end
323
+ end
324
+
325
+ def file_collision_help #:nodoc:
326
+ <<-HELP
327
+ Y - yes, overwrite
328
+ n - no, do not overwrite
329
+ a - all, overwrite this and all others
330
+ q - quit, abort
331
+ d - diff, show the differences between the old and the new
332
+ h - help, show this help
333
+ HELP
334
+ end
335
+
336
+ def show_diff(destination, content) #:nodoc:
337
+ diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
338
+
339
+ Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
340
+ temp.write content
341
+ temp.rewind
342
+ system %(#{diff_cmd} "#{destination}" "#{temp.path}")
343
+ end
344
+ end
345
+
346
+ def quiet? #:nodoc:
347
+ mute? || (base && base.options[:quiet])
348
+ end
349
+
350
+ # Calculate the dynamic width of the terminal
351
+ def dynamic_width
352
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
353
+ end
354
+
355
+ def dynamic_width_stty
356
+ %x(stty size 2>/dev/null).split[1].to_i
357
+ end
358
+
359
+ def dynamic_width_tput
360
+ %x(tput cols 2>/dev/null).to_i
361
+ end
362
+
363
+ def unix?
364
+ RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
365
+ end
366
+
367
+ def truncate(string, width)
368
+ as_unicode do
369
+ chars = string.chars.to_a
370
+ if chars.length <= width
371
+ chars.join
372
+ else
373
+ ( chars[0, width - 3].join) + "..."
374
+ end
375
+ end
376
+ end
377
+
378
+ if "".respond_to?(:encode)
379
+ def as_unicode
380
+ yield
381
+ end
382
+ else
383
+ def as_unicode
384
+ old, $KCODE = $KCODE, "U"
385
+ yield
386
+ ensure
387
+ $KCODE = old
388
+ end
389
+ end
390
+
391
+ def ask_simply(statement, color, options)
392
+ default = options[:default]
393
+ message = [statement, ("(#{default})" if default), nil].uniq.join(" ")
394
+ message = prepare_message(message, color)
395
+ result = Bundler::Thor::LineEditor.readline(message, options)
396
+
397
+ return unless result
398
+
399
+ result.strip!
400
+
401
+ if default && result == ""
402
+ default
403
+ else
404
+ result
405
+ end
406
+ end
407
+
408
+ def ask_filtered(statement, color, options)
409
+ answer_set = options[:limited_to]
410
+ correct_answer = nil
411
+ until correct_answer
412
+ answers = answer_set.join(", ")
413
+ answer = ask_simply("#{statement} [#{answers}]", color, options)
414
+ correct_answer = answer_set.include?(answer) ? answer : nil
415
+ say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
416
+ end
417
+ correct_answer
418
+ end
419
+ end
420
+ end
421
+ end