bundler 2.1.4 → 2.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2164 -1430
  3. data/README.md +7 -9
  4. data/bundler.gemspec +5 -6
  5. data/exe/bundle +10 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -11
  9. data/lib/bundler/cli/add.rb +1 -1
  10. data/lib/bundler/cli/binstubs.rb +6 -2
  11. data/lib/bundler/cli/cache.rb +3 -8
  12. data/lib/bundler/cli/check.rb +4 -2
  13. data/lib/bundler/cli/clean.rb +1 -1
  14. data/lib/bundler/cli/common.rb +30 -3
  15. data/lib/bundler/cli/config.rb +10 -1
  16. data/lib/bundler/cli/console.rb +1 -1
  17. data/lib/bundler/cli/doctor.rb +25 -6
  18. data/lib/bundler/cli/exec.rb +5 -10
  19. data/lib/bundler/cli/fund.rb +36 -0
  20. data/lib/bundler/cli/gem.rb +219 -28
  21. data/lib/bundler/cli/info.rb +38 -6
  22. data/lib/bundler/cli/init.rb +3 -3
  23. data/lib/bundler/cli/inject.rb +1 -1
  24. data/lib/bundler/cli/install.rb +20 -52
  25. data/lib/bundler/cli/issue.rb +5 -4
  26. data/lib/bundler/cli/list.rb +19 -11
  27. data/lib/bundler/cli/lock.rb +5 -1
  28. data/lib/bundler/cli/open.rb +1 -2
  29. data/lib/bundler/cli/outdated.rb +95 -75
  30. data/lib/bundler/cli/platform.rb +1 -1
  31. data/lib/bundler/cli/plugin.rb +10 -0
  32. data/lib/bundler/cli/pristine.rb +5 -0
  33. data/lib/bundler/cli/remove.rb +1 -2
  34. data/lib/bundler/cli/show.rb +2 -2
  35. data/lib/bundler/cli/update.rb +20 -9
  36. data/lib/bundler/cli.rb +101 -81
  37. data/lib/bundler/compact_index_client/cache.rb +6 -23
  38. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  39. data/lib/bundler/compact_index_client/updater.rb +13 -22
  40. data/lib/bundler/compact_index_client.rb +3 -9
  41. data/lib/bundler/current_ruby.rb +6 -4
  42. data/lib/bundler/definition.rb +201 -385
  43. data/lib/bundler/dep_proxy.rb +16 -9
  44. data/lib/bundler/dependency.rb +23 -14
  45. data/lib/bundler/digest.rb +71 -0
  46. data/lib/bundler/dsl.rb +71 -74
  47. data/lib/bundler/endpoint_specification.rb +22 -12
  48. data/lib/bundler/env.rb +2 -2
  49. data/lib/bundler/environment_preserver.rb +29 -2
  50. data/lib/bundler/errors.rb +20 -3
  51. data/lib/bundler/feature_flag.rb +0 -8
  52. data/lib/bundler/fetcher/base.rb +1 -1
  53. data/lib/bundler/fetcher/compact_index.rb +11 -16
  54. data/lib/bundler/fetcher/downloader.rb +10 -7
  55. data/lib/bundler/fetcher/index.rb +2 -30
  56. data/lib/bundler/fetcher.rb +18 -23
  57. data/lib/bundler/friendly_errors.rb +25 -43
  58. data/lib/bundler/gem_helper.rb +53 -31
  59. data/lib/bundler/gem_helpers.rb +36 -25
  60. data/lib/bundler/gem_version_promoter.rb +4 -4
  61. data/lib/bundler/graph.rb +1 -1
  62. data/lib/bundler/index.rb +9 -9
  63. data/lib/bundler/injector.rb +33 -6
  64. data/lib/bundler/inline.rb +3 -2
  65. data/lib/bundler/installer/gem_installer.rb +7 -25
  66. data/lib/bundler/installer/parallel_installer.rb +46 -25
  67. data/lib/bundler/installer/standalone.rb +30 -10
  68. data/lib/bundler/installer.rb +36 -59
  69. data/lib/bundler/lazy_specification.rb +62 -26
  70. data/lib/bundler/lockfile_generator.rb +2 -2
  71. data/lib/bundler/lockfile_parser.rb +17 -46
  72. data/lib/bundler/man/.document +1 -0
  73. data/{man → lib/bundler/man}/bundle-add.1 +10 -2
  74. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +7 -1
  75. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  76. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  77. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  78. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  79. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  80. data/{man → lib/bundler/man}/bundle-config.1 +44 -45
  81. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +59 -60
  82. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  83. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  84. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  85. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  86. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  87. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  88. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  89. data/{man → lib/bundler/man}/bundle-install.1 +31 -4
  90. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +27 -5
  91. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  92. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  93. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  94. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  95. data/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  96. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  97. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  98. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  99. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  100. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  101. data/{man → lib/bundler/man}/bundle-update.1 +5 -5
  102. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +5 -4
  103. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  104. data/{man → lib/bundler/man}/bundle.1 +1 -1
  105. data/{man → lib/bundler/man}/gemfile.5 +31 -5
  106. data/{man → lib/bundler/man}/gemfile.5.ronn +13 -5
  107. data/lib/bundler/mirror.rb +2 -2
  108. data/lib/bundler/plugin/api/source.rb +23 -7
  109. data/lib/bundler/plugin/dsl.rb +1 -1
  110. data/lib/bundler/plugin/index.rb +13 -1
  111. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  112. data/lib/bundler/plugin/installer.rb +11 -11
  113. data/lib/bundler/plugin/source_list.rb +5 -1
  114. data/lib/bundler/plugin.rb +56 -11
  115. data/lib/bundler/process_lock.rb +1 -1
  116. data/lib/bundler/remote_specification.rb +12 -2
  117. data/lib/bundler/resolver/spec_group.rb +58 -55
  118. data/lib/bundler/resolver.rb +176 -177
  119. data/lib/bundler/retry.rb +2 -2
  120. data/lib/bundler/ruby_version.rb +2 -15
  121. data/lib/bundler/rubygems_ext.rb +137 -28
  122. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  123. data/lib/bundler/rubygems_integration.rb +69 -133
  124. data/lib/bundler/runtime.rb +22 -25
  125. data/lib/bundler/self_manager.rb +168 -0
  126. data/lib/bundler/settings.rb +144 -65
  127. data/lib/bundler/setup.rb +2 -2
  128. data/lib/bundler/shared_helpers.rb +12 -27
  129. data/lib/bundler/similarity_detector.rb +1 -1
  130. data/lib/bundler/source/git/git_proxy.rb +88 -84
  131. data/lib/bundler/source/git.rb +43 -23
  132. data/lib/bundler/source/metadata.rb +3 -7
  133. data/lib/bundler/source/path/installer.rb +10 -10
  134. data/lib/bundler/source/path.rb +10 -4
  135. data/lib/bundler/source/rubygems/remote.rb +1 -1
  136. data/lib/bundler/source/rubygems.rb +126 -116
  137. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  138. data/lib/bundler/source.rb +22 -1
  139. data/lib/bundler/source_list.rb +101 -63
  140. data/lib/bundler/source_map.rb +71 -0
  141. data/lib/bundler/spec_set.rb +26 -41
  142. data/lib/bundler/stub_specification.rb +25 -7
  143. data/lib/bundler/templates/Executable +2 -4
  144. data/lib/bundler/templates/Executable.bundler +8 -8
  145. data/lib/bundler/templates/Executable.standalone +2 -4
  146. data/lib/bundler/templates/Gemfile +0 -2
  147. data/lib/bundler/templates/gems.rb +0 -3
  148. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  149. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  150. data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  151. data/lib/bundler/templates/newgem/README.md.tt +9 -14
  152. data/lib/bundler/templates/newgem/Rakefile.tt +32 -5
  153. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  154. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  155. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  156. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  157. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  158. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  159. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  160. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  161. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  162. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  163. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  164. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  165. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  166. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  167. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  168. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  169. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  170. data/lib/bundler/ui/shell.rb +6 -6
  171. data/lib/bundler/uri_credentials_filter.rb +3 -1
  172. data/lib/bundler/vendor/.document +1 -0
  173. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  174. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  175. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  176. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  177. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  178. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  179. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  180. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  181. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  182. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  183. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +37 -5
  184. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +34 -28
  185. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  186. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  187. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  188. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  189. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  190. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  191. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  192. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  193. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +9 -7
  194. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  195. data/lib/bundler/vendor/thor/lib/thor/actions.rb +7 -3
  196. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  197. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  198. data/lib/bundler/vendor/thor/lib/thor/error.rb +10 -5
  199. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  200. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +28 -9
  201. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +27 -6
  202. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  203. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  204. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  205. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  206. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  207. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  208. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  209. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  210. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  211. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  212. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  213. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  214. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  215. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  216. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  217. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  218. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  219. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  220. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  221. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  222. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  223. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  224. data/lib/bundler/vendored_persistent.rb +0 -7
  225. data/lib/bundler/vendored_tmpdir.rb +4 -0
  226. data/lib/bundler/vendored_tsort.rb +4 -0
  227. data/lib/bundler/version.rb +1 -1
  228. data/lib/bundler/worker.rb +20 -5
  229. data/lib/bundler/yaml_serializer.rb +1 -1
  230. data/lib/bundler.rb +64 -43
  231. metadata +94 -91
  232. data/lib/bundler/gemdeps.rb +0 -29
  233. data/lib/bundler/psyched_yaml.rb +0 -37
  234. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  235. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  236. data/man/bundle-add.1.txt +0 -58
  237. data/man/bundle-binstubs.1.txt +0 -48
  238. data/man/bundle-cache.1.txt +0 -78
  239. data/man/bundle-check.1.txt +0 -33
  240. data/man/bundle-clean.1.txt +0 -26
  241. data/man/bundle-config.1.txt +0 -528
  242. data/man/bundle-doctor.1.txt +0 -44
  243. data/man/bundle-exec.1.txt +0 -178
  244. data/man/bundle-gem.1.txt +0 -91
  245. data/man/bundle-info.1.txt +0 -21
  246. data/man/bundle-init.1.txt +0 -34
  247. data/man/bundle-inject.1.txt +0 -32
  248. data/man/bundle-install.1.txt +0 -401
  249. data/man/bundle-list.1.txt +0 -43
  250. data/man/bundle-lock.1.txt +0 -93
  251. data/man/bundle-open.1.txt +0 -29
  252. data/man/bundle-outdated.1.txt +0 -131
  253. data/man/bundle-platform.1.txt +0 -57
  254. data/man/bundle-pristine.1.txt +0 -44
  255. data/man/bundle-remove.1.txt +0 -34
  256. data/man/bundle-show.1.txt +0 -27
  257. data/man/bundle-update.1.txt +0 -390
  258. data/man/bundle-viz.1.txt +0 -39
  259. data/man/bundle.1.txt +0 -116
  260. data/man/gemfile.5.txt +0 -649
  261. /data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  262. /data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  263. /data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  264. /data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  265. /data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  266. /data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  267. /data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  268. /data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  269. /data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  270. /data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  271. /data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  272. /data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  273. /data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  274. /data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  275. /data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  276. /data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  277. /data/{man → lib/bundler/man}/index.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  class Bundler::Thor
2
- Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
2
+ Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName
3
3
  # In order to support versions of Ruby that don't have keyword
4
4
  # arguments, we need our own spell checker class that doesn't take key
5
5
  # words. Even though this code wouldn't be hit because of the check
@@ -102,9 +102,14 @@ class Bundler::Thor
102
102
  end
103
103
 
104
104
  if Correctable
105
- DidYouMean::SPELL_CHECKERS.merge!(
106
- 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
107
- 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
108
- )
105
+ if DidYouMean.respond_to?(:correct_error)
106
+ DidYouMean.correct_error(Bundler::Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
107
+ DidYouMean.correct_error(Bundler::Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
108
+ else
109
+ DidYouMean::SPELL_CHECKERS.merge!(
110
+ 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
111
+ 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
112
+ )
113
+ end
109
114
  end
110
115
  end
@@ -30,7 +30,11 @@ class Bundler::Thor
30
30
 
31
31
  arguments.each do |argument|
32
32
  if !argument.default.nil?
33
- @assigns[argument.human_name] = argument.default
33
+ begin
34
+ @assigns[argument.human_name] = argument.default.dup
35
+ rescue TypeError # Compatibility shim for un-dup-able Fixnum in Ruby < 2.4
36
+ @assigns[argument.human_name] = argument.default
37
+ end
34
38
  elsif argument.required?
35
39
  @non_assigned_required << argument
36
40
  end
@@ -45,6 +45,7 @@ class Bundler::Thor
45
45
  @switches = {}
46
46
  @extra = []
47
47
  @stopped_parsing_after_extra_index = nil
48
+ @is_treated_as_value = false
48
49
 
49
50
  options.each do |option|
50
51
  @switches[option.switch_name] = option
@@ -74,8 +75,19 @@ class Bundler::Thor
74
75
  end
75
76
  end
76
77
 
78
+ def shift
79
+ @is_treated_as_value = false
80
+ super
81
+ end
82
+
83
+ def unshift(arg, is_value: false)
84
+ @is_treated_as_value = is_value
85
+ super(arg)
86
+ end
87
+
77
88
  def parse(args) # rubocop:disable MethodLength
78
89
  @pile = args.dup
90
+ @is_treated_as_value = false
79
91
  @parsing_options = true
80
92
 
81
93
  while peek
@@ -88,7 +100,10 @@ class Bundler::Thor
88
100
  when SHORT_SQ_RE
89
101
  unshift($1.split("").map { |f| "-#{f}" })
90
102
  next
91
- when EQ_RE, SHORT_NUM
103
+ when EQ_RE
104
+ unshift($2, is_value: true)
105
+ switch = $1
106
+ when SHORT_NUM
92
107
  unshift($2)
93
108
  switch = $1
94
109
  when LONG_RE, SHORT_RE
@@ -133,20 +148,22 @@ class Bundler::Thor
133
148
 
134
149
  protected
135
150
 
136
- def assign_result!(option, result)
137
- if option.repeatable && option.type == :hash
138
- (@assigns[option.human_name] ||= {}).merge!(result)
139
- elsif option.repeatable
140
- (@assigns[option.human_name] ||= []) << result
141
- else
142
- @assigns[option.human_name] = result
151
+ def assign_result!(option, result)
152
+ if option.repeatable && option.type == :hash
153
+ (@assigns[option.human_name] ||= {}).merge!(result)
154
+ elsif option.repeatable
155
+ (@assigns[option.human_name] ||= []) << result
156
+ else
157
+ @assigns[option.human_name] = result
158
+ end
143
159
  end
144
- end
160
+
145
161
  # Check if the current value in peek is a registered switch.
146
162
  #
147
163
  # Two booleans are returned. The first is true if the current value
148
164
  # starts with a hyphen; the second is true if it is a registered switch.
149
165
  def current_is_switch?
166
+ return [false, false] if @is_treated_as_value
150
167
  case peek
151
168
  when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM
152
169
  [true, switch?($1)]
@@ -158,6 +175,7 @@ class Bundler::Thor
158
175
  end
159
176
 
160
177
  def current_is_switch_formatted?
178
+ return false if @is_treated_as_value
161
179
  case peek
162
180
  when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE
163
181
  true
@@ -167,6 +185,7 @@ class Bundler::Thor
167
185
  end
168
186
 
169
187
  def current_is_value?
188
+ return true if @is_treated_as_value
170
189
  peek && (!parsing_options? || super)
171
190
  end
172
191
 
@@ -94,6 +94,8 @@ class Bundler::Thor
94
94
  # say("I know you knew that.")
95
95
  #
96
96
  def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
97
+ return if quiet?
98
+
97
99
  buffer = prepare_message(message, *color)
98
100
  buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
99
101
 
@@ -101,6 +103,23 @@ class Bundler::Thor
101
103
  stdout.flush
102
104
  end
103
105
 
106
+ # Say (print) an error to the user. If the sentence ends with a whitespace
107
+ # or tab character, a new line is not appended (print + flush). Otherwise
108
+ # are passed straight to puts (behavior got from Highline).
109
+ #
110
+ # ==== Example
111
+ # say_error("error: something went wrong")
112
+ #
113
+ def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
114
+ return if quiet?
115
+
116
+ buffer = prepare_message(message, *color)
117
+ buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
118
+
119
+ stderr.print(buffer)
120
+ stderr.flush
121
+ end
122
+
104
123
  # Say a status with the given color and appends the message. Since this
105
124
  # method is used frequently by actions, it allows nil or false to be given
106
125
  # in log_status, avoiding the message from being shown. If a Symbol is
@@ -109,13 +128,14 @@ class Bundler::Thor
109
128
  def say_status(status, message, log_status = true)
110
129
  return if quiet? || log_status == false
111
130
  spaces = " " * (padding + 1)
112
- color = log_status.is_a?(Symbol) ? log_status : :green
113
-
114
131
  status = status.to_s.rjust(12)
132
+ margin = " " * status.length + spaces
133
+
134
+ color = log_status.is_a?(Symbol) ? log_status : :green
115
135
  status = set_color status, color, true if color
116
136
 
117
- buffer = "#{status}#{spaces}#{message}"
118
- buffer = "#{buffer}\n" unless buffer.end_with?("\n")
137
+ message = message.to_s.chomp.gsub(/(?<!\A)^/, margin)
138
+ buffer = "#{status}#{spaces}#{message}\n"
119
139
 
120
140
  stdout.print(buffer)
121
141
  stdout.flush
@@ -230,8 +250,9 @@ class Bundler::Thor
230
250
  paras = message.split("\n\n")
231
251
 
232
252
  paras.map! do |unwrapped|
233
- counter = 0
234
- unwrapped.split(" ").inject do |memo, word|
253
+ words = unwrapped.split(" ")
254
+ counter = words.first.length
255
+ words.inject do |memo, word|
235
256
  word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
236
257
  counter = 0 if word.include? "\n"
237
258
  if (counter + word.length + 1) < width
@@ -97,7 +97,11 @@ class Bundler::Thor
97
97
  protected
98
98
 
99
99
  def can_display_colors?
100
- stdout.tty? && !are_colors_disabled?
100
+ are_colors_supported? && !are_colors_disabled?
101
+ end
102
+
103
+ def are_colors_supported?
104
+ stdout.tty? && ENV["TERM"] != "dumb"
101
105
  end
102
106
 
103
107
  def are_colors_disabled?
@@ -21,7 +21,7 @@ class Bundler::Thor
21
21
  end
22
22
 
23
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]
24
+ SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_error, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
25
25
  attr_writer :shell
26
26
 
27
27
  autoload :Basic, File.expand_path("shell/basic", __dir__)
@@ -211,7 +211,7 @@ class Bundler::Thor
211
211
  #
212
212
  def globs_for(path)
213
213
  path = escape_globs(path)
214
- ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
214
+ ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/**/*.thor"]
215
215
  end
216
216
 
217
217
  # Return the path to the ruby interpreter taking into account multiple
@@ -1,3 +1,3 @@
1
1
  class Bundler::Thor
2
- VERSION = "1.0.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -1,7 +1,7 @@
1
- require "set"
2
1
  require_relative "thor/base"
3
2
 
4
3
  class Bundler::Thor
4
+ $thor_runner ||= false
5
5
  class << self
6
6
  # Allows for custom "Command" package naming.
7
7
  #
@@ -323,7 +323,7 @@ class Bundler::Thor
323
323
  # ==== Parameters
324
324
  # Symbol ...:: A list of commands that should be affected.
325
325
  def stop_on_unknown_option!(*command_names)
326
- stop_on_unknown_option.merge(command_names)
326
+ @stop_on_unknown_option = stop_on_unknown_option | command_names
327
327
  end
328
328
 
329
329
  def stop_on_unknown_option?(command) #:nodoc:
@@ -337,29 +337,22 @@ class Bundler::Thor
337
337
  # ==== Parameters
338
338
  # Symbol ...:: A list of commands that should be affected.
339
339
  def disable_required_check!(*command_names)
340
- disable_required_check.merge(command_names)
340
+ @disable_required_check = disable_required_check | command_names
341
341
  end
342
342
 
343
343
  def disable_required_check?(command) #:nodoc:
344
344
  command && disable_required_check.include?(command.name.to_sym)
345
345
  end
346
346
 
347
- def deprecation_warning(message) #:nodoc:
348
- unless ENV['THOR_SILENCE_DEPRECATION']
349
- warn "Deprecation warning: #{message}\n" +
350
- 'You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.'
351
- end
352
- end
353
-
354
347
  protected
355
348
 
356
349
  def stop_on_unknown_option #:nodoc:
357
- @stop_on_unknown_option ||= Set.new
350
+ @stop_on_unknown_option ||= []
358
351
  end
359
352
 
360
353
  # help command has the required check disabled by default.
361
354
  def disable_required_check #:nodoc:
362
- @disable_required_check ||= Set.new([:help])
355
+ @disable_required_check ||= [:help]
363
356
  end
364
357
 
365
358
  # The method responsible for dispatching given the args.
@@ -405,7 +398,6 @@ class Bundler::Thor
405
398
  # the namespace should be displayed as arguments.
406
399
  #
407
400
  def banner(command, namespace = nil, subcommand = false)
408
- $thor_runner ||= false
409
401
  command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
410
402
  "#{basename} #{formatted_usage}"
411
403
  end.join("\n")
@@ -0,0 +1,154 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # tmpdir - retrieve temporary directory path
4
+ #
5
+ # $Id$
6
+ #
7
+
8
+ require_relative '../../fileutils/lib/fileutils'
9
+ begin
10
+ require 'etc.so'
11
+ rescue LoadError # rescue LoadError for miniruby
12
+ end
13
+
14
+ class Bundler::Dir < Dir
15
+
16
+ @systmpdir ||= defined?(Etc.systmpdir) ? Etc.systmpdir : '/tmp'
17
+
18
+ ##
19
+ # Returns the operating system's temporary file path.
20
+
21
+ def self.tmpdir
22
+ tmp = nil
23
+ ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @systmpdir], ['/tmp']*2, ['.']*2].each do |name, dir = ENV[name]|
24
+ next if !dir
25
+ dir = File.expand_path(dir)
26
+ stat = File.stat(dir) rescue next
27
+ case
28
+ when !stat.directory?
29
+ warn "#{name} is not a directory: #{dir}"
30
+ when !stat.writable?
31
+ warn "#{name} is not writable: #{dir}"
32
+ when stat.world_writable? && !stat.sticky?
33
+ warn "#{name} is world-writable: #{dir}"
34
+ else
35
+ tmp = dir
36
+ break
37
+ end
38
+ end
39
+ raise ArgumentError, "could not find a temporary directory" unless tmp
40
+ tmp
41
+ end
42
+
43
+ # Bundler::Dir.mktmpdir creates a temporary directory.
44
+ #
45
+ # The directory is created with 0700 permission.
46
+ # Application should not change the permission to make the temporary directory accessible from other users.
47
+ #
48
+ # The prefix and suffix of the name of the directory is specified by
49
+ # the optional first argument, <i>prefix_suffix</i>.
50
+ # - If it is not specified or nil, "d" is used as the prefix and no suffix is used.
51
+ # - If it is a string, it is used as the prefix and no suffix is used.
52
+ # - If it is an array, first element is used as the prefix and second element is used as a suffix.
53
+ #
54
+ # Bundler::Dir.mktmpdir {|dir| dir is ".../d..." }
55
+ # Bundler::Dir.mktmpdir("foo") {|dir| dir is ".../foo..." }
56
+ # Bundler::Dir.mktmpdir(["foo", "bar"]) {|dir| dir is ".../foo...bar" }
57
+ #
58
+ # The directory is created under Bundler::Dir.tmpdir or
59
+ # the optional second argument <i>tmpdir</i> if non-nil value is given.
60
+ #
61
+ # Bundler::Dir.mktmpdir {|dir| dir is "#{Bundler::Dir.tmpdir}/d..." }
62
+ # Bundler::Dir.mktmpdir(nil, "/var/tmp") {|dir| dir is "/var/tmp/d..." }
63
+ #
64
+ # If a block is given,
65
+ # it is yielded with the path of the directory.
66
+ # The directory and its contents are removed
67
+ # using Bundler::FileUtils.remove_entry before Bundler::Dir.mktmpdir returns.
68
+ # The value of the block is returned.
69
+ #
70
+ # Bundler::Dir.mktmpdir {|dir|
71
+ # # use the directory...
72
+ # open("#{dir}/foo", "w") { ... }
73
+ # }
74
+ #
75
+ # If a block is not given,
76
+ # The path of the directory is returned.
77
+ # In this case, Bundler::Dir.mktmpdir doesn't remove the directory.
78
+ #
79
+ # dir = Bundler::Dir.mktmpdir
80
+ # begin
81
+ # # use the directory...
82
+ # open("#{dir}/foo", "w") { ... }
83
+ # ensure
84
+ # # remove the directory.
85
+ # Bundler::FileUtils.remove_entry dir
86
+ # end
87
+ #
88
+ def self.mktmpdir(prefix_suffix=nil, *rest, **options)
89
+ base = nil
90
+ path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|p, _, _, d|
91
+ base = d
92
+ mkdir(p, 0700)
93
+ }
94
+ if block_given?
95
+ begin
96
+ yield path.dup
97
+ ensure
98
+ unless base
99
+ stat = File.stat(File.dirname(path))
100
+ if stat.world_writable? and !stat.sticky?
101
+ raise ArgumentError, "parent directory is world writable but not sticky"
102
+ end
103
+ end
104
+ Bundler::FileUtils.remove_entry path
105
+ end
106
+ else
107
+ path
108
+ end
109
+ end
110
+
111
+ module Tmpname # :nodoc:
112
+ module_function
113
+
114
+ def tmpdir
115
+ Bundler::Dir.tmpdir
116
+ end
117
+
118
+ UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
119
+
120
+ class << (RANDOM = Random.new)
121
+ MAX = 36**6 # < 0x100000000
122
+ def next
123
+ rand(MAX).to_s(36)
124
+ end
125
+ end
126
+ private_constant :RANDOM
127
+
128
+ def create(basename, tmpdir=nil, max_try: nil, **opts)
129
+ origdir = tmpdir
130
+ tmpdir ||= tmpdir()
131
+ n = nil
132
+ prefix, suffix = basename
133
+ prefix = (String.try_convert(prefix) or
134
+ raise ArgumentError, "unexpected prefix: #{prefix.inspect}")
135
+ prefix = prefix.delete(UNUSABLE_CHARS)
136
+ suffix &&= (String.try_convert(suffix) or
137
+ raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
138
+ suffix &&= suffix.delete(UNUSABLE_CHARS)
139
+ begin
140
+ t = Time.now.strftime("%Y%m%d")
141
+ path = "#{prefix}#{t}-#{$$}-#{RANDOM.next}"\
142
+ "#{n ? %[-#{n}] : ''}#{suffix||''}"
143
+ path = File.join(tmpdir, path)
144
+ yield(path, n, opts, origdir)
145
+ rescue Errno::EEXIST
146
+ n ||= 0
147
+ n += 1
148
+ retry if !max_try or n < max_try
149
+ raise "cannot generate temporary name using `#{basename}' under `#{tmpdir}'"
150
+ end
151
+ path
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.