bundler 2.0.2 → 2.1.0

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

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (249) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +735 -574
  3. data/LICENSE.md +18 -19
  4. data/README.md +8 -7
  5. data/bundler.gemspec +5 -23
  6. data/exe/bundle +19 -3
  7. data/lib/bundler.rb +202 -87
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/capistrano.rb +5 -5
  10. data/lib/bundler/cli.rb +179 -143
  11. data/lib/bundler/cli/add.rb +28 -16
  12. data/lib/bundler/cli/cache.rb +25 -13
  13. data/lib/bundler/cli/common.rb +10 -11
  14. data/lib/bundler/cli/config.rb +161 -86
  15. data/lib/bundler/cli/console.rb +2 -2
  16. data/lib/bundler/cli/doctor.rb +4 -4
  17. data/lib/bundler/cli/exec.rb +15 -18
  18. data/lib/bundler/cli/gem.rb +5 -5
  19. data/lib/bundler/cli/info.rb +17 -5
  20. data/lib/bundler/cli/init.rb +1 -1
  21. data/lib/bundler/cli/install.rb +3 -3
  22. data/lib/bundler/cli/issue.rb +1 -1
  23. data/lib/bundler/cli/open.rb +10 -6
  24. data/lib/bundler/cli/outdated.rb +85 -81
  25. data/lib/bundler/cli/plugin.rb +9 -2
  26. data/lib/bundler/cli/pristine.rb +1 -1
  27. data/lib/bundler/cli/show.rb +1 -1
  28. data/lib/bundler/cli/update.rb +31 -11
  29. data/lib/bundler/compact_index_client.rb +25 -9
  30. data/lib/bundler/compact_index_client/updater.rb +2 -6
  31. data/lib/bundler/current_ruby.rb +8 -7
  32. data/lib/bundler/definition.rb +33 -26
  33. data/lib/bundler/dependency.rb +16 -4
  34. data/lib/bundler/deployment.rb +2 -2
  35. data/lib/bundler/dsl.rb +19 -43
  36. data/lib/bundler/env.rb +6 -5
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +1 -13
  39. data/lib/bundler/fetcher.rb +16 -13
  40. data/lib/bundler/fetcher/compact_index.rb +26 -12
  41. data/lib/bundler/fetcher/dependency.rb +1 -1
  42. data/lib/bundler/fetcher/downloader.rb +4 -1
  43. data/lib/bundler/fetcher/index.rb +5 -3
  44. data/lib/bundler/friendly_errors.rb +6 -7
  45. data/lib/bundler/gem_helper.rb +14 -14
  46. data/lib/bundler/gem_helpers.rb +2 -4
  47. data/lib/bundler/gem_tasks.rb +1 -1
  48. data/lib/bundler/gem_version_promoter.rb +3 -3
  49. data/lib/bundler/graph.rb +2 -2
  50. data/lib/bundler/injector.rb +3 -1
  51. data/lib/bundler/inline.rb +40 -30
  52. data/lib/bundler/installer.rb +7 -14
  53. data/lib/bundler/installer/gem_installer.rb +5 -1
  54. data/lib/bundler/installer/parallel_installer.rb +4 -4
  55. data/lib/bundler/installer/standalone.rb +1 -2
  56. data/lib/bundler/lazy_specification.rb +2 -3
  57. data/lib/bundler/lockfile_parser.rb +14 -21
  58. data/lib/bundler/match_platform.rb +1 -1
  59. data/lib/bundler/mirror.rb +3 -3
  60. data/lib/bundler/plugin.rb +29 -18
  61. data/lib/bundler/plugin/api.rb +1 -1
  62. data/lib/bundler/plugin/api/source.rb +4 -6
  63. data/lib/bundler/plugin/index.rb +10 -2
  64. data/lib/bundler/plugin/installer.rb +28 -15
  65. data/lib/bundler/psyched_yaml.rb +1 -1
  66. data/lib/bundler/remote_specification.rb +0 -2
  67. data/lib/bundler/resolver.rb +72 -24
  68. data/lib/bundler/resolver/spec_group.rb +3 -2
  69. data/lib/bundler/retry.rb +2 -2
  70. data/lib/bundler/ruby_version.rb +4 -19
  71. data/lib/bundler/rubygems_ext.rb +11 -66
  72. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  73. data/lib/bundler/rubygems_integration.rb +133 -410
  74. data/lib/bundler/runtime.rb +2 -9
  75. data/lib/bundler/settings.rb +22 -52
  76. data/lib/bundler/setup.rb +7 -13
  77. data/lib/bundler/shared_helpers.rb +46 -74
  78. data/lib/bundler/similarity_detector.rb +2 -2
  79. data/lib/bundler/source.rb +5 -5
  80. data/lib/bundler/source/git.rb +24 -17
  81. data/lib/bundler/source/git/git_proxy.rb +38 -41
  82. data/lib/bundler/source/metadata.rb +7 -2
  83. data/lib/bundler/source/path.rb +13 -8
  84. data/lib/bundler/source/rubygems.rb +14 -8
  85. data/lib/bundler/source/rubygems/remote.rb +2 -3
  86. data/lib/bundler/source_list.rb +9 -12
  87. data/lib/bundler/spec_set.rb +1 -6
  88. data/lib/bundler/stub_specification.rb +18 -30
  89. data/lib/bundler/templates/Executable.bundler +22 -13
  90. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
  91. data/lib/bundler/templates/newgem/Gemfile.tt +8 -0
  92. data/lib/bundler/templates/newgem/README.md.tt +4 -3
  93. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -18
  94. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  95. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  96. data/lib/bundler/ui.rb +3 -3
  97. data/lib/bundler/ui/rg_proxy.rb +1 -1
  98. data/lib/bundler/ui/shell.rb +4 -8
  99. data/lib/bundler/uri_credentials_filter.rb +7 -3
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  101. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  102. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  103. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  104. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +134 -111
  105. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  111. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  112. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  116. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
  117. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  118. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +273 -304
  119. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  120. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  121. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  122. data/lib/bundler/vendor/thor/lib/thor.rb +19 -4
  123. data/lib/bundler/vendor/thor/lib/thor/actions.rb +17 -12
  124. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  125. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  126. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  127. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  128. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
  129. data/lib/bundler/vendor/thor/lib/thor/base.rb +51 -39
  130. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  131. data/lib/bundler/vendor/thor/lib/thor/error.rb +14 -18
  132. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  133. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  134. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  135. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  136. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  137. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  138. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  139. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +2 -2
  140. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  141. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -3
  142. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  143. data/lib/bundler/vendor/thor/lib/thor/runner.rb +13 -12
  144. data/lib/bundler/vendor/thor/lib/thor/shell.rb +3 -3
  145. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -1
  146. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -2
  147. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  148. data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  149. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  150. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  151. data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  152. data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  153. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  154. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  155. data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  156. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  157. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  158. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  159. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  160. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  161. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  162. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  163. data/lib/bundler/vendored_fileutils.rb +1 -6
  164. data/lib/bundler/vendored_molinillo.rb +1 -1
  165. data/lib/bundler/vendored_persistent.rb +7 -5
  166. data/lib/bundler/vendored_thor.rb +2 -2
  167. data/lib/bundler/vendored_uri.rb +4 -0
  168. data/lib/bundler/version.rb +1 -20
  169. data/lib/bundler/version_ranges.rb +51 -5
  170. data/lib/bundler/vlad.rb +3 -3
  171. data/lib/bundler/worker.rb +1 -3
  172. data/lib/bundler/yaml_serializer.rb +2 -3
  173. data/man/bundle-add.1 +10 -2
  174. data/man/bundle-add.1.txt +11 -5
  175. data/man/bundle-add.ronn +7 -1
  176. data/man/bundle-binstubs.1 +2 -2
  177. data/man/bundle-binstubs.1.txt +2 -2
  178. data/man/bundle-binstubs.ronn +1 -1
  179. data/man/bundle-cache.1 +55 -0
  180. data/man/bundle-cache.1.txt +78 -0
  181. data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
  182. data/man/bundle-check.1 +1 -1
  183. data/man/bundle-check.1.txt +6 -6
  184. data/man/bundle-clean.1 +1 -1
  185. data/man/bundle-clean.1.txt +1 -1
  186. data/man/bundle-config.1 +35 -35
  187. data/man/bundle-config.1.txt +65 -66
  188. data/man/bundle-config.ronn +41 -39
  189. data/man/bundle-doctor.1 +1 -1
  190. data/man/bundle-doctor.1.txt +1 -1
  191. data/man/bundle-exec.1 +2 -2
  192. data/man/bundle-exec.1.txt +2 -2
  193. data/man/bundle-exec.ronn +1 -1
  194. data/man/bundle-gem.1 +1 -1
  195. data/man/bundle-gem.1.txt +3 -3
  196. data/man/bundle-info.1 +1 -1
  197. data/man/bundle-info.1.txt +1 -1
  198. data/man/bundle-init.1 +1 -1
  199. data/man/bundle-init.1.txt +1 -1
  200. data/man/bundle-inject.1 +1 -1
  201. data/man/bundle-inject.1.txt +1 -1
  202. data/man/bundle-install.1 +8 -5
  203. data/man/bundle-install.1.txt +56 -51
  204. data/man/bundle-install.ronn +9 -4
  205. data/man/bundle-list.1 +1 -1
  206. data/man/bundle-list.1.txt +1 -1
  207. data/man/bundle-lock.1 +1 -1
  208. data/man/bundle-lock.1.txt +16 -16
  209. data/man/bundle-open.1 +1 -1
  210. data/man/bundle-open.1.txt +1 -1
  211. data/man/bundle-outdated.1 +1 -1
  212. data/man/bundle-outdated.1.txt +1 -1
  213. data/man/bundle-platform.1 +1 -1
  214. data/man/bundle-platform.1.txt +1 -1
  215. data/man/bundle-pristine.1 +1 -1
  216. data/man/bundle-pristine.1.txt +1 -1
  217. data/man/bundle-remove.1 +1 -1
  218. data/man/bundle-remove.1.txt +1 -1
  219. data/man/bundle-show.1 +1 -1
  220. data/man/bundle-show.1.txt +1 -1
  221. data/man/bundle-update.1 +4 -4
  222. data/man/bundle-update.1.txt +64 -65
  223. data/man/bundle-update.ronn +3 -3
  224. data/man/bundle-viz.1 +1 -1
  225. data/man/bundle-viz.1.txt +1 -1
  226. data/man/bundle.1 +2 -2
  227. data/man/bundle.1.txt +7 -7
  228. data/man/bundle.ronn +1 -1
  229. data/man/gemfile.5 +12 -15
  230. data/man/gemfile.5.ronn +9 -13
  231. data/man/gemfile.5.txt +103 -107
  232. data/man/index.txt +1 -1
  233. metadata +30 -120
  234. data/exe/bundle_ruby +0 -60
  235. data/lib/bundler/cli/package.rb +0 -49
  236. data/lib/bundler/compatibility_guard.rb +0 -13
  237. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  238. data/lib/bundler/ssl_certs/.document +0 -1
  239. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  240. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  241. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  242. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  243. data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +0 -5
  244. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  245. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  246. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  247. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  248. data/man/bundle-package.1 +0 -55
  249. data/man/bundle-package.1.txt +0 -79
@@ -1,17 +1,17 @@
1
- require "bundler/vendor/thor/lib/thor/command"
2
- require "bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access"
3
- require "bundler/vendor/thor/lib/thor/core_ext/ordered_hash"
4
- require "bundler/vendor/thor/lib/thor/error"
5
- require "bundler/vendor/thor/lib/thor/invocation"
6
- require "bundler/vendor/thor/lib/thor/parser"
7
- require "bundler/vendor/thor/lib/thor/shell"
8
- require "bundler/vendor/thor/lib/thor/line_editor"
9
- require "bundler/vendor/thor/lib/thor/util"
1
+ require_relative "command"
2
+ require_relative "core_ext/hash_with_indifferent_access"
3
+ require_relative "error"
4
+ require_relative "invocation"
5
+ require_relative "nested_context"
6
+ require_relative "parser"
7
+ require_relative "shell"
8
+ require_relative "line_editor"
9
+ require_relative "util"
10
10
 
11
11
  class Bundler::Thor
12
- autoload :Actions, "bundler/vendor/thor/lib/thor/actions"
13
- autoload :RakeCompat, "bundler/vendor/thor/lib/thor/rake_compat"
14
- autoload :Group, "bundler/vendor/thor/lib/thor/group"
12
+ autoload :Actions, File.expand_path("actions", __dir__)
13
+ autoload :RakeCompat, File.expand_path("rake_compat", __dir__)
14
+ autoload :Group, File.expand_path("group", __dir__)
15
15
 
16
16
  # Shortcuts for help.
17
17
  HELP_MAPPINGS = %w(-h -? --help -D)
@@ -89,6 +89,7 @@ class Bundler::Thor
89
89
 
90
90
  class << self
91
91
  def included(base) #:nodoc:
92
+ super(base)
92
93
  base.extend ClassMethods
93
94
  base.send :include, Invocation
94
95
  base.send :include, Shell
@@ -113,7 +114,7 @@ class Bundler::Thor
113
114
  end
114
115
 
115
116
  # Whenever a class inherits from Bundler::Thor or Bundler::Thor::Group, we should track the
116
- # class and the file on Bundler::Thor::Base. This is the method responsable for it.
117
+ # class and the file on Bundler::Thor::Base. This is the method responsible for it.
117
118
  #
118
119
  def register_klass_file(klass) #:nodoc:
119
120
  file = caller[1].match(/(.*):\d+/)[1]
@@ -153,17 +154,20 @@ class Bundler::Thor
153
154
 
154
155
  # If you want to raise an error when the default value of an option does not match
155
156
  # the type call check_default_type!
156
- # This is disabled by default for compatibility.
157
+ # This will be the default; for compatibility a deprecation warning is issued if necessary.
157
158
  def check_default_type!
158
159
  @check_default_type = true
159
160
  end
160
161
 
161
- def check_default_type #:nodoc:
162
- @check_default_type ||= from_superclass(:check_default_type, false)
162
+ # If you want to use defaults that don't match the type of an option,
163
+ # either specify `check_default_type: false` or call `allow_incompatible_default_type!`
164
+ def allow_incompatible_default_type!
165
+ @check_default_type = false
163
166
  end
164
167
 
165
- def check_default_type? #:nodoc:
166
- !!check_default_type
168
+ def check_default_type #:nodoc:
169
+ @check_default_type = from_superclass(:check_default_type, nil) unless defined?(@check_default_type)
170
+ @check_default_type
167
171
  end
168
172
 
169
173
  # If true, option parsing is suspended as soon as an unknown option or a
@@ -353,22 +357,22 @@ class Bundler::Thor
353
357
  # Returns the commands for this Bundler::Thor class.
354
358
  #
355
359
  # ==== Returns
356
- # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
357
- # objects as values.
360
+ # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
361
+ # objects as values.
358
362
  #
359
363
  def commands
360
- @commands ||= Bundler::Thor::CoreExt::OrderedHash.new
364
+ @commands ||= Hash.new
361
365
  end
362
366
  alias_method :tasks, :commands
363
367
 
364
368
  # Returns the commands for this Bundler::Thor class and all subclasses.
365
369
  #
366
370
  # ==== Returns
367
- # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
368
- # objects as values.
371
+ # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
372
+ # objects as values.
369
373
  #
370
374
  def all_commands
371
- @all_commands ||= from_superclass(:all_commands, Bundler::Thor::CoreExt::OrderedHash.new)
375
+ @all_commands ||= from_superclass(:all_commands, Hash.new)
372
376
  @all_commands.merge!(commands)
373
377
  end
374
378
  alias_method :all_tasks, :all_commands
@@ -415,14 +419,20 @@ class Bundler::Thor
415
419
  # remove_command :this_is_not_a_command
416
420
  # end
417
421
  #
418
- def no_commands
419
- @no_commands = true
420
- yield
421
- ensure
422
- @no_commands = false
422
+ def no_commands(&block)
423
+ no_commands_context.enter(&block)
423
424
  end
425
+
424
426
  alias_method :no_tasks, :no_commands
425
427
 
428
+ def no_commands_context
429
+ @no_commands_context ||= NestedContext.new
430
+ end
431
+
432
+ def no_commands?
433
+ no_commands_context.entered?
434
+ end
435
+
426
436
  # Sets the namespace for the Bundler::Thor or Bundler::Thor::Group class. By default the
427
437
  # namespace is retrieved from the class name. If your Bundler::Thor class is named
428
438
  # Scripts::MyScript, the help method, for example, will be called as:
@@ -502,10 +512,16 @@ class Bundler::Thor
502
512
  msg = "ERROR: \"#{basename} #{name}\" was called with ".dup
503
513
  msg << "no arguments" if args.empty?
504
514
  msg << "arguments " << args.inspect unless args.empty?
505
- msg << "\nUsage: #{banner(command).inspect}"
515
+ msg << "\nUsage: \"#{banner(command).split("\n").join("\"\n \"")}\""
506
516
  raise InvocationError, msg
507
517
  end
508
518
 
519
+ # A flag that makes the process exit with status 1 if any error happens.
520
+ def exit_on_failure?
521
+ Bundler::Thor.deprecation_warning "Bundler::Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `#{self.name}`"
522
+ false
523
+ end
524
+
509
525
  protected
510
526
 
511
527
  # Prints the class options per group. If an option does not belong to
@@ -563,7 +579,7 @@ class Bundler::Thor
563
579
  # options<Hash>:: Described in both class_option and method_option.
564
580
  # scope<Hash>:: Options hash that is being built up
565
581
  def build_option(name, options, scope) #:nodoc:
566
- scope[name] = Bundler::Thor::Option.new(name, options.merge(:check_default_type => check_default_type?))
582
+ scope[name] = Bundler::Thor::Option.new(name, {:check_default_type => check_default_type}.merge!(options))
567
583
  end
568
584
 
569
585
  # Receives a hash of options, parse them and add to the scope. This is a
@@ -596,13 +612,15 @@ class Bundler::Thor
596
612
  # Everytime someone inherits from a Bundler::Thor class, register the klass
597
613
  # and file into baseclass.
598
614
  def inherited(klass)
615
+ super(klass)
599
616
  Bundler::Thor::Base.register_klass_file(klass)
600
- klass.instance_variable_set(:@no_commands, false)
617
+ klass.instance_variable_set(:@no_commands, 0)
601
618
  end
602
619
 
603
620
  # Fire this callback whenever a method is added. Added methods are
604
621
  # tracked as commands by invoking the create_command method.
605
622
  def method_added(meth)
623
+ super(meth)
606
624
  meth = meth.to_s
607
625
 
608
626
  if meth == "initialize"
@@ -613,8 +631,7 @@ class Bundler::Thor
613
631
  # Return if it's not a public instance method
614
632
  return unless public_method_defined?(meth.to_sym)
615
633
 
616
- @no_commands ||= false
617
- return if @no_commands || !create_command(meth)
634
+ return if no_commands? || !create_command(meth)
618
635
 
619
636
  is_thor_reserved_word?(meth, :command)
620
637
  Bundler::Thor::Base.register_klass_file(self)
@@ -641,11 +658,6 @@ class Bundler::Thor
641
658
  end
642
659
  end
643
660
 
644
- # A flag that makes the process exit with status 1 if any error happens.
645
- def exit_on_failure?
646
- false
647
- end
648
-
649
661
  #
650
662
  # The basename of the program invoking the thor class.
651
663
  #
@@ -49,24 +49,32 @@ class Bundler::Thor
49
49
 
50
50
  formatted ||= "".dup
51
51
 
52
- # Add usage with required arguments
53
- formatted << if klass && !klass.arguments.empty?
54
- usage.to_s.gsub(/^#{name}/) do |match|
55
- match << " " << klass.arguments.map(&:usage).compact.join(" ")
56
- end
57
- else
58
- usage.to_s
59
- end
52
+ Array(usage).map do |specific_usage|
53
+ formatted_specific_usage = formatted
60
54
 
61
- # Add required options
62
- formatted << " #{required_options}"
55
+ formatted_specific_usage += required_arguments_for(klass, specific_usage)
63
56
 
64
- # Strip and go!
65
- formatted.strip
57
+ # Add required options
58
+ formatted_specific_usage += " #{required_options}"
59
+
60
+ # Strip and go!
61
+ formatted_specific_usage.strip
62
+ end.join("\n")
66
63
  end
67
64
 
68
65
  protected
69
66
 
67
+ # Add usage with required arguments
68
+ def required_arguments_for(klass, usage)
69
+ if klass && !klass.arguments.empty?
70
+ usage.to_s.gsub(/^#{name}/) do |match|
71
+ match << " " << klass.arguments.map(&:usage).compact.join(" ")
72
+ end
73
+ else
74
+ usage.to_s
75
+ end
76
+ end
77
+
70
78
  def not_debugging?(instance)
71
79
  !(instance.class.respond_to?(:debugging) && instance.class.debugging)
72
80
  end
@@ -97,8 +105,7 @@ class Bundler::Thor
97
105
  def handle_argument_error?(instance, error, caller)
98
106
  not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin
99
107
  saned = sans_backtrace(error.backtrace, caller)
100
- # Ruby 1.9 always include the called method in the backtrace
101
- saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
108
+ saned.empty? || saned.size == 1
102
109
  end
103
110
  end
104
111
 
@@ -1,22 +1,18 @@
1
1
  class Bundler::Thor
2
- Correctable =
3
- begin
4
- require 'did_you_mean'
5
-
6
- # In order to support versions of Ruby that don't have keyword
7
- # arguments, we need our own spell checker class that doesn't take key
8
- # words. Even though this code wouldn't be hit because of the check
9
- # above, it's still necessary because the interpreter would otherwise be
10
- # unable to parse the file.
11
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
12
- def initialize(dictionary)
13
- @dictionary = dictionary
14
- end
15
- end
16
-
17
- DidYouMean::Correctable
18
- rescue LoadError, NameError
19
- end
2
+ Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
3
+ # In order to support versions of Ruby that don't have keyword
4
+ # arguments, we need our own spell checker class that doesn't take key
5
+ # words. Even though this code wouldn't be hit because of the check
6
+ # above, it's still necessary because the interpreter would otherwise be
7
+ # unable to parse the file.
8
+ class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
9
+ def initialize(dictionary)
10
+ @dictionary = dictionary
11
+ end
12
+ end
13
+
14
+ DidYouMean::Correctable
15
+ end
20
16
 
21
17
  # Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
22
18
  # errors have their backtrace suppressed and are nicely shown to the user.
@@ -1,4 +1,4 @@
1
- require "bundler/vendor/thor/lib/thor/base"
1
+ require_relative "base"
2
2
 
3
3
  # Bundler::Thor has a special class called Bundler::Thor::Group. The main difference to Bundler::Thor class
4
4
  # is that it invokes all commands at once. It also include some methods that allows
@@ -1,6 +1,7 @@
1
1
  class Bundler::Thor
2
2
  module Invocation
3
3
  def self.included(base) #:nodoc:
4
+ super(base)
4
5
  base.extend ClassMethods
5
6
  end
6
7
 
@@ -1,5 +1,5 @@
1
- require "bundler/vendor/thor/lib/thor/line_editor/basic"
2
- require "bundler/vendor/thor/lib/thor/line_editor/readline"
1
+ require_relative "line_editor/basic"
2
+ require_relative "line_editor/readline"
3
3
 
4
4
  class Bundler::Thor
5
5
  module LineEditor
@@ -24,7 +24,7 @@ class Bundler::Thor
24
24
  $stdin.gets
25
25
  else
26
26
  # Lazy-load io/console since it is gem-ified as of 2.3
27
- require "io/console" if RUBY_VERSION > "1.9.2"
27
+ require "io/console"
28
28
  $stdin.noecho(&:gets)
29
29
  end
30
30
  end
@@ -1,19 +1,19 @@
1
- begin
2
- require "readline"
3
- rescue LoadError
4
- end
5
-
6
1
  class Bundler::Thor
7
2
  module LineEditor
8
3
  class Readline < Basic
9
4
  def self.available?
5
+ begin
6
+ require "readline"
7
+ rescue LoadError
8
+ end
9
+
10
10
  Object.const_defined?(:Readline)
11
11
  end
12
12
 
13
13
  def readline
14
14
  if echo?
15
15
  ::Readline.completion_append_character = nil
16
- # Ruby 1.8.7 does not allow Readline.completion_proc= to receive nil.
16
+ # rb-readline does not allow Readline.completion_proc= to receive nil.
17
17
  if complete = completion_proc
18
18
  ::Readline.completion_proc = complete
19
19
  end
@@ -0,0 +1,29 @@
1
+ class Bundler::Thor
2
+ class NestedContext
3
+ def initialize
4
+ @depth = 0
5
+ end
6
+
7
+ def enter
8
+ push
9
+
10
+ yield
11
+ ensure
12
+ pop
13
+ end
14
+
15
+ def entered?
16
+ @depth > 0
17
+ end
18
+
19
+ private
20
+
21
+ def push
22
+ @depth += 1
23
+ end
24
+
25
+ def pop
26
+ @depth -= 1
27
+ end
28
+ end
29
+ end
@@ -1,4 +1,4 @@
1
- require "bundler/vendor/thor/lib/thor/parser/argument"
2
- require "bundler/vendor/thor/lib/thor/parser/arguments"
3
- require "bundler/vendor/thor/lib/thor/parser/option"
4
- require "bundler/vendor/thor/lib/thor/parser/options"
1
+ require_relative "parser/argument"
2
+ require_relative "parser/arguments"
3
+ require_relative "parser/option"
4
+ require_relative "parser/options"
@@ -9,7 +9,7 @@ class Bundler::Thor
9
9
  arguments = []
10
10
 
11
11
  args.each do |item|
12
- break if item =~ /^-/
12
+ break if item.is_a?(String) && item =~ /^-/
13
13
  arguments << item
14
14
  end
15
15
 
@@ -82,7 +82,7 @@ class Bundler::Thor
82
82
  end
83
83
 
84
84
  def current_is_value?
85
- peek && peek.to_s !~ /^-/
85
+ peek && peek.to_s !~ /^-{1,2}\S+/
86
86
  end
87
87
 
88
88
  # Runs through the argument array getting strings that contains ":" and
@@ -1,17 +1,18 @@
1
1
  class Bundler::Thor
2
2
  class Option < Argument #:nodoc:
3
- attr_reader :aliases, :group, :lazy_default, :hide
3
+ attr_reader :aliases, :group, :lazy_default, :hide, :repeatable
4
4
 
5
5
  VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
6
6
 
7
7
  def initialize(name, options = {})
8
8
  @check_default_type = options[:check_default_type]
9
9
  options[:required] = false unless options.key?(:required)
10
+ @repeatable = options.fetch(:repeatable, false)
10
11
  super
11
- @lazy_default = options[:lazy_default]
12
- @group = options[:group].to_s.capitalize if options[:group]
13
- @aliases = Array(options[:aliases])
14
- @hide = options[:hide]
12
+ @lazy_default = options[:lazy_default]
13
+ @group = options[:group].to_s.capitalize if options[:group]
14
+ @aliases = Array(options[:aliases])
15
+ @hide = options[:hide]
15
16
  end
16
17
 
17
18
  # This parse quick options given as method_options. It makes several
@@ -111,7 +112,7 @@ class Bundler::Thor
111
112
 
112
113
  def validate!
113
114
  raise ArgumentError, "An option cannot be boolean and required." if boolean? && required?
114
- validate_default_type! if @check_default_type
115
+ validate_default_type!
115
116
  end
116
117
 
117
118
  def validate_default_type!
@@ -128,7 +129,19 @@ class Bundler::Thor
128
129
  @default.class.name.downcase.to_sym
129
130
  end
130
131
 
131
- raise ArgumentError, "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type
132
+ expected_type = (@repeatable && @type != :hash) ? :array : @type
133
+
134
+ if default_type != expected_type
135
+ err = "Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})"
136
+
137
+ if @check_default_type
138
+ raise ArgumentError, err
139
+ elsif @check_default_type == nil
140
+ Bundler::Thor.deprecation_warning "#{err}.\n" +
141
+ 'This will be rejected in the future unless you explicitly pass the options `check_default_type: false`' +
142
+ ' or call `allow_incompatible_default_type!` in your code'
143
+ end
144
+ end
132
145
  end
133
146
 
134
147
  def dasherized?