bundler 2.0.1 → 2.1.4

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 +788 -572
  3. data/LICENSE.md +18 -19
  4. data/README.md +9 -8
  5. data/bundler.gemspec +8 -25
  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 +182 -144
  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 +11 -12
  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 +4 -16
  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 +15 -13
  22. data/lib/bundler/cli/issue.rb +3 -3
  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 +36 -27
  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 +8 -13
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +2 -14
  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 +5 -2
  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 +39 -25
  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 +10 -8
  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 -8
  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 +42 -29
  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 +14 -3
  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 -67
  72. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  73. data/lib/bundler/rubygems_integration.rb +149 -399
  74. data/lib/bundler/runtime.rb +2 -9
  75. data/lib/bundler/settings.rb +22 -52
  76. data/lib/bundler/setup.rb +11 -12
  77. data/lib/bundler/shared_helpers.rb +51 -77
  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 +23 -14
  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 +6 -27
  94. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +1 -1
  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 +273 -147
  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 +270 -323
  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 +27 -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 +16 -7
  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 +54 -43
  130. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  131. data/lib/bundler/vendor/thor/lib/thor/error.rb +78 -0
  132. data/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  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 +20 -5
  142. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  143. data/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
  144. data/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
  145. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +62 -8
  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 +36 -36
  187. data/man/bundle-config.1.txt +66 -67
  188. data/man/bundle-config.ronn +42 -40
  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 +2 -2
  199. data/man/bundle-init.1.txt +2 -2
  200. data/man/bundle-init.ronn +1 -1
  201. data/man/bundle-inject.1 +1 -1
  202. data/man/bundle-inject.1.txt +1 -1
  203. data/man/bundle-install.1 +8 -5
  204. data/man/bundle-install.1.txt +56 -51
  205. data/man/bundle-install.ronn +9 -4
  206. data/man/bundle-list.1 +1 -1
  207. data/man/bundle-list.1.txt +1 -1
  208. data/man/bundle-lock.1 +1 -1
  209. data/man/bundle-lock.1.txt +16 -16
  210. data/man/bundle-open.1 +1 -1
  211. data/man/bundle-open.1.txt +1 -1
  212. data/man/bundle-outdated.1 +1 -1
  213. data/man/bundle-outdated.1.txt +1 -1
  214. data/man/bundle-platform.1 +1 -1
  215. data/man/bundle-platform.1.txt +1 -1
  216. data/man/bundle-pristine.1 +1 -1
  217. data/man/bundle-pristine.1.txt +1 -1
  218. data/man/bundle-remove.1 +1 -1
  219. data/man/bundle-remove.1.txt +1 -1
  220. data/man/bundle-show.1 +1 -1
  221. data/man/bundle-show.1.txt +1 -1
  222. data/man/bundle-update.1 +4 -4
  223. data/man/bundle-update.1.txt +64 -65
  224. data/man/bundle-update.ronn +3 -3
  225. data/man/bundle-viz.1 +1 -1
  226. data/man/bundle-viz.1.txt +1 -1
  227. data/man/bundle.1 +3 -3
  228. data/man/bundle.1.txt +8 -8
  229. data/man/bundle.ronn +2 -2
  230. data/man/gemfile.5 +13 -16
  231. data/man/gemfile.5.ronn +10 -14
  232. data/man/gemfile.5.txt +104 -108
  233. data/man/index.txt +1 -1
  234. metadata +33 -108
  235. data/exe/bundle_ruby +0 -60
  236. data/lib/bundler/cli/package.rb +0 -49
  237. data/lib/bundler/compatibility_guard.rb +0 -14
  238. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  239. data/lib/bundler/ssl_certs/.document +0 -1
  240. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  241. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  242. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  243. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  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
@@ -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?
@@ -44,6 +44,7 @@ class Bundler::Thor
44
44
  @shorts = {}
45
45
  @switches = {}
46
46
  @extra = []
47
+ @stopped_parsing_after_extra_index = nil
47
48
 
48
49
  options.each do |option|
49
50
  @switches[option.switch_name] = option
@@ -66,6 +67,7 @@ class Bundler::Thor
66
67
  if result == OPTS_END
67
68
  shift
68
69
  @parsing_options = false
70
+ @stopped_parsing_after_extra_index ||= @extra.size
69
71
  super
70
72
  else
71
73
  result
@@ -95,10 +97,12 @@ class Bundler::Thor
95
97
 
96
98
  switch = normalize_switch(switch)
97
99
  option = switch_option(switch)
98
- @assigns[option.human_name] = parse_peek(switch, option)
100
+ result = parse_peek(switch, option)
101
+ assign_result!(option, result)
99
102
  elsif @stop_on_unknown
100
103
  @parsing_options = false
101
104
  @extra << shifted
105
+ @stopped_parsing_after_extra_index ||= @extra.size
102
106
  @extra << shift while peek
103
107
  break
104
108
  elsif match
@@ -120,13 +124,24 @@ class Bundler::Thor
120
124
  end
121
125
 
122
126
  def check_unknown!
127
+ to_check = @stopped_parsing_after_extra_index ? @extra[0...@stopped_parsing_after_extra_index] : @extra
128
+
123
129
  # an unknown option starts with - or -- and has no more --'s afterward.
124
- unknown = @extra.select { |str| str =~ /^--?(?:(?!--).)*$/ }
125
- raise UnknownArgumentError, "Unknown switches '#{unknown.join(', ')}'" unless unknown.empty?
130
+ unknown = to_check.select { |str| str =~ /^--?(?:(?!--).)*$/ }
131
+ raise UnknownArgumentError.new(@switches.keys, unknown) unless unknown.empty?
126
132
  end
127
133
 
128
134
  protected
129
135
 
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
143
+ end
144
+ end
130
145
  # Check if the current value in peek is a registered switch.
131
146
  #
132
147
  # Two booleans are returned. The first is true if the current value
@@ -156,7 +171,7 @@ class Bundler::Thor
156
171
  end
157
172
 
158
173
  def switch?(arg)
159
- switch_option(normalize_switch(arg))
174
+ !switch_option(normalize_switch(arg)).nil?
160
175
  end
161
176
 
162
177
  def switch_option(arg)
@@ -189,7 +204,7 @@ class Bundler::Thor
189
204
  shift
190
205
  false
191
206
  else
192
- !no_or_skip?(switch)
207
+ @switches.key?(switch) || !no_or_skip?(switch)
193
208
  end
194
209
  else
195
210
  @switches.key?(switch) || !no_or_skip?(switch)
@@ -25,6 +25,7 @@ class Bundler::Thor
25
25
  end
26
26
 
27
27
  def self.included(base)
28
+ super(base)
28
29
  # Hack. Make rakefile point to invoker, so rdoc task is generated properly.
29
30
  rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
30
31
  Rake.application.instance_variable_set(:@rakefile, rakefile)
@@ -1,12 +1,13 @@
1
- require "bundler/vendor/thor/lib/thor"
2
- require "bundler/vendor/thor/lib/thor/group"
3
- require "bundler/vendor/thor/lib/thor/core_ext/io_binary_read"
1
+ require_relative "../thor"
2
+ require_relative "group"
4
3
 
5
4
  require "yaml"
6
- require "digest"
5
+ require "digest/md5"
7
6
  require "pathname"
8
7
 
9
8
  class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
9
+ autoload :OpenURI, "open-uri"
10
+
10
11
  map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
11
12
 
12
13
  def self.banner(command, all = false, subcommand = false)
@@ -65,7 +66,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
65
66
  raise Error, "Error opening file '#{name}'"
66
67
  end
67
68
 
68
- say "Your Bundler::Thorfile contains:"
69
+ say "Your Thorfile contains:"
69
70
  say contents
70
71
 
71
72
  unless options["force"]
@@ -90,7 +91,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
90
91
  end
91
92
 
92
93
  thor_yaml[as] = {
93
- :filename => Digest(:MD5).hexdigest(name + as),
94
+ :filename => Digest::MD5.hexdigest(name + as),
94
95
  :location => location,
95
96
  :namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
96
97
  }
@@ -111,7 +112,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
111
112
 
112
113
  desc "version", "Show Bundler::Thor version"
113
114
  def version
114
- require "bundler/vendor/thor/lib/thor/version"
115
+ require_relative "version"
115
116
  say "Bundler::Thor #{Bundler::Thor::VERSION}"
116
117
  end
117
118
 
@@ -204,7 +205,7 @@ private
204
205
  File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
205
206
  end
206
207
 
207
- # Load the Bundler::Thorfiles. If relevant_to is supplied, looks for specific files
208
+ # Load the Thorfiles. If relevant_to is supplied, looks for specific files
208
209
  # in the thor_root instead of loading them all.
209
210
  #
210
211
  # By default, it also traverses the current path until find Bundler::Thor files, as
@@ -217,11 +218,11 @@ private
217
218
  end
218
219
  end
219
220
 
220
- # Finds Bundler::Thorfiles by traversing from your current directory down to the root
221
+ # Finds Thorfiles by traversing from your current directory down to the root
221
222
  # directory of your system. If at any time we find a Bundler::Thor file, we stop.
222
223
  #
223
- # We also ensure that system-wide Bundler::Thorfiles are loaded first, so local
224
- # Bundler::Thorfiles can override them.
224
+ # We also ensure that system-wide Thorfiles are loaded first, so local
225
+ # Thorfiles can override them.
225
226
  #
226
227
  # ==== Example
227
228
  #
@@ -229,7 +230,7 @@ private
229
230
  #
230
231
  # 1. /Users/wycats/dev/thor
231
232
  # 2. /Users/wycats/dev
232
- # 3. /Users/wycats <-- we find a Bundler::Thorfile here, so we stop
233
+ # 3. /Users/wycats <-- we find a Thorfile here, so we stop
233
234
  #
234
235
  # Suppose we start at c:\Documents and Settings\james\dev\thor ...
235
236
  #
@@ -237,7 +238,7 @@ private
237
238
  # 2. c:\Documents and Settings\james\dev
238
239
  # 3. c:\Documents and Settings\james
239
240
  # 4. c:\Documents and Settings
240
- # 5. c:\ <-- no Bundler::Thorfiles found!
241
+ # 5. c:\ <-- no Thorfiles found!
241
242
  #
242
243
  def thorfiles(relevant_to = nil, skip_lookup = false)
243
244
  thorfiles = []
@@ -258,7 +259,7 @@ private
258
259
  end
259
260
  end
260
261
 
261
- # Load Bundler::Thorfiles relevant to the given method. If you provide "foo:bar" it
262
+ # Load Thorfiles relevant to the given method. If you provide "foo:bar" it
262
263
  # will load all thor files in the thor.yaml that has "foo" e "foo:bar"
263
264
  # namespaces registered.
264
265
  #
@@ -24,9 +24,9 @@ class Bundler::Thor
24
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
25
  attr_writer :shell
26
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"
27
+ autoload :Basic, File.expand_path("shell/basic", __dir__)
28
+ autoload :Color, File.expand_path("shell/color", __dir__)
29
+ autoload :HTML, File.expand_path("shell/html", __dir__)
30
30
 
31
31
  # Add shell to initialize config values.
32
32
  #
@@ -55,7 +55,7 @@ class Bundler::Thor
55
55
 
56
56
  # Common methods that are delegated to the shell.
57
57
  SHELL_DELEGATED_METHODS.each do |method|
58
- module_eval <<-METHOD, __FILE__, __LINE__
58
+ module_eval <<-METHOD, __FILE__, __LINE__ + 1
59
59
  def #{method}(*args,&block)
60
60
  shell.#{method}(*args,&block)
61
61
  end
@@ -1,6 +1,8 @@
1
1
  class Bundler::Thor
2
2
  module Shell
3
3
  class Basic
4
+ DEFAULT_TERMINAL_WIDTH = 80
5
+
4
6
  attr_accessor :base
5
7
  attr_reader :padding
6
8
 
@@ -45,6 +47,10 @@ class Bundler::Thor
45
47
 
46
48
  # Asks something to the user and receives a response.
47
49
  #
50
+ # If a default value is specified it will be presented to the user
51
+ # and allows them to select that value with an empty response. This
52
+ # option is ignored when limited answers are supplied.
53
+ #
48
54
  # If asked to limit the correct responses, you can pass in an
49
55
  # array of acceptable answers. If one of those is not supplied,
50
56
  # they will be shown a message stating that one of those answers
@@ -61,6 +67,8 @@ class Bundler::Thor
61
67
  # ==== Example
62
68
  # ask("What is your name?")
63
69
  #
70
+ # ask("What is the planet furthest from the sun?", :default => "Pluto")
71
+ #
64
72
  # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
65
73
  #
66
74
  # ask("What is your password?", :echo => false)
@@ -222,8 +230,20 @@ class Bundler::Thor
222
230
  paras = message.split("\n\n")
223
231
 
224
232
  paras.map! do |unwrapped|
225
- unwrapped.strip.tr("\n", " ").squeeze(" ").gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }
226
- end
233
+ counter = 0
234
+ unwrapped.split(" ").inject do |memo, word|
235
+ word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
236
+ counter = 0 if word.include? "\n"
237
+ if (counter + word.length + 1) < width
238
+ memo = "#{memo} #{word}"
239
+ counter += (word.length + 1)
240
+ else
241
+ memo = "#{memo}\n#{word}"
242
+ counter = word.length
243
+ end
244
+ memo
245
+ end
246
+ end.compact!
227
247
 
228
248
  paras.each do |para|
229
249
  para.split("\n").each do |line|
@@ -239,11 +259,11 @@ class Bundler::Thor
239
259
  #
240
260
  # ==== Parameters
241
261
  # destination<String>:: the destination file to solve conflicts
242
- # block<Proc>:: an optional block that returns the value to be used in diff
262
+ # block<Proc>:: an optional block that returns the value to be used in diff and merge
243
263
  #
244
264
  def file_collision(destination)
245
265
  return true if @always_force
246
- options = block_given? ? "[Ynaqdh]" : "[Ynaqh]"
266
+ options = block_given? ? "[Ynaqdhm]" : "[Ynaqh]"
247
267
 
248
268
  loop do
249
269
  answer = ask(
@@ -267,6 +287,13 @@ class Bundler::Thor
267
287
  when is?(:diff)
268
288
  show_diff(destination, yield) if block_given?
269
289
  say "Retrying..."
290
+ when is?(:merge)
291
+ if block_given? && !merge_tool.empty?
292
+ merge(destination, yield)
293
+ return nil
294
+ end
295
+
296
+ say "Please specify merge tool to `THOR_MERGE` env."
270
297
  else
271
298
  say file_collision_help
272
299
  end
@@ -279,11 +306,11 @@ class Bundler::Thor
279
306
  result = if ENV["THOR_COLUMNS"]
280
307
  ENV["THOR_COLUMNS"].to_i
281
308
  else
282
- unix? ? dynamic_width : 80
309
+ unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
283
310
  end
284
- result < 10 ? 80 : result
311
+ result < 10 ? DEFAULT_TERMINAL_WIDTH : result
285
312
  rescue
286
- 80
313
+ DEFAULT_TERMINAL_WIDTH
287
314
  end
288
315
 
289
316
  # Called if something goes wrong during the execution. This is used by Bundler::Thor
@@ -344,6 +371,7 @@ class Bundler::Thor
344
371
  q - quit, abort
345
372
  d - diff, show the differences between the old and the new
346
373
  h - help, show this help
374
+ m - merge, run merge tool
347
375
  HELP
348
376
  end
349
377
 
@@ -423,15 +451,41 @@ class Bundler::Thor
423
451
 
424
452
  def ask_filtered(statement, color, options)
425
453
  answer_set = options[:limited_to]
454
+ case_insensitive = options.fetch(:case_insensitive, false)
426
455
  correct_answer = nil
427
456
  until correct_answer
428
457
  answers = answer_set.join(", ")
429
458
  answer = ask_simply("#{statement} [#{answers}]", color, options)
430
- correct_answer = answer_set.include?(answer) ? answer : nil
459
+ correct_answer = answer_match(answer_set, answer, case_insensitive)
431
460
  say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
432
461
  end
433
462
  correct_answer
434
463
  end
464
+
465
+ def answer_match(possibilities, answer, case_insensitive)
466
+ if case_insensitive
467
+ possibilities.detect{ |possibility| possibility.downcase == answer.downcase }
468
+ else
469
+ possibilities.detect{ |possibility| possibility == answer }
470
+ end
471
+ end
472
+
473
+ def merge(destination, content) #:nodoc:
474
+ require "tempfile"
475
+ Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
476
+ temp.write content
477
+ temp.rewind
478
+ system %(#{merge_tool} "#{temp.path}" "#{destination}")
479
+ end
480
+ end
481
+
482
+ def merge_tool #:nodoc:
483
+ @merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
484
+ end
485
+
486
+ def git_merge_tool #:nodoc:
487
+ `git config merge.tool`.rstrip rescue ""
488
+ end
435
489
  end
436
490
  end
437
491
  end