bundler 1.5.1 → 1.5.2

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 (58) hide show
  1. data/CHANGELOG.md +26 -2
  2. data/bin/bundle +1 -3
  3. data/bundler.gemspec +1 -1
  4. data/lib/bundler/cli.rb +2 -4
  5. data/lib/bundler/fetcher.rb +13 -12
  6. data/lib/bundler/installer.rb +9 -36
  7. data/lib/bundler/parallel_workers/unix_worker.rb +12 -4
  8. data/lib/bundler/parallel_workers/worker.rb +1 -0
  9. data/lib/bundler/rubygems_ext.rb +1 -1
  10. data/lib/bundler/rubygems_integration.rb +15 -8
  11. data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  12. data/lib/bundler/vendor/thor.rb +63 -56
  13. data/lib/bundler/vendor/thor/actions.rb +52 -51
  14. data/lib/bundler/vendor/thor/actions/create_file.rb +35 -37
  15. data/lib/bundler/vendor/thor/actions/create_link.rb +1 -2
  16. data/lib/bundler/vendor/thor/actions/directory.rb +36 -37
  17. data/lib/bundler/vendor/thor/actions/empty_directory.rb +67 -69
  18. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +11 -12
  19. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +41 -43
  20. data/lib/bundler/vendor/thor/base.rb +180 -178
  21. data/lib/bundler/vendor/thor/command.rb +22 -25
  22. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +21 -24
  23. data/lib/bundler/vendor/thor/core_ext/io_binary_read.rb +1 -3
  24. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +8 -10
  25. data/lib/bundler/vendor/thor/error.rb +2 -2
  26. data/lib/bundler/vendor/thor/group.rb +59 -60
  27. data/lib/bundler/vendor/thor/invocation.rb +39 -38
  28. data/lib/bundler/vendor/thor/line_editor.rb +17 -0
  29. data/lib/bundler/vendor/thor/line_editor/basic.rb +35 -0
  30. data/lib/bundler/vendor/thor/line_editor/readline.rb +88 -0
  31. data/lib/bundler/vendor/thor/parser/argument.rb +29 -30
  32. data/lib/bundler/vendor/thor/parser/arguments.rb +102 -98
  33. data/lib/bundler/vendor/thor/parser/option.rb +25 -25
  34. data/lib/bundler/vendor/thor/parser/options.rb +85 -85
  35. data/lib/bundler/vendor/thor/rake_compat.rb +6 -7
  36. data/lib/bundler/vendor/thor/runner.rb +154 -154
  37. data/lib/bundler/vendor/thor/shell.rb +23 -30
  38. data/lib/bundler/vendor/thor/shell/basic.rb +66 -57
  39. data/lib/bundler/vendor/thor/shell/color.rb +44 -43
  40. data/lib/bundler/vendor/thor/shell/html.rb +43 -44
  41. data/lib/bundler/vendor/thor/util.rb +37 -40
  42. data/lib/bundler/vendor/thor/version.rb +1 -1
  43. data/lib/bundler/version.rb +1 -1
  44. data/man/bundle-install.ronn +1 -1
  45. data/man/gemfile.5.ronn +1 -2
  46. data/spec/commands/binstubs_spec.rb +13 -0
  47. data/spec/install/gemfile/git_spec.rb +2 -2
  48. data/spec/install/gems/dependency_api_spec.rb +34 -0
  49. data/spec/install/gems/packed_spec.rb +2 -4
  50. data/spec/quality_spec.rb +2 -2
  51. data/spec/realworld/parallel_spec.rb +69 -0
  52. data/spec/runtime/setup_spec.rb +3 -2
  53. data/spec/spec_helper.rb +1 -0
  54. data/spec/support/artifice/endpoint_host_redirect.rb +15 -0
  55. data/spec/support/permissions.rb +11 -0
  56. metadata +11 -6
  57. data/spec/realworld/parallel_install_spec.rb +0 -23
  58. data/spec/realworld/parallel_update_spec.rb +0 -31
@@ -2,7 +2,7 @@ class Thor
2
2
  class Command < Struct.new(:name, :description, :long_description, :usage, :options)
3
3
  FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
4
4
 
5
- def initialize(name, description, long_description, usage, options=nil)
5
+ def initialize(name, description, long_description, usage, options = nil)
6
6
  super(name.to_s, description, long_description, usage, options || {})
7
7
  end
8
8
 
@@ -17,7 +17,7 @@ class Thor
17
17
 
18
18
  # By default, a command invokes a method in the thor class. You can change this
19
19
  # implementation to create custom commands.
20
- def run(instance, args=[])
20
+ def run(instance, args = [])
21
21
  arity = nil
22
22
 
23
23
  if private_method?(instance)
@@ -31,11 +31,9 @@ class Thor
31
31
  instance.class.handle_no_command_error(name)
32
32
  end
33
33
  rescue ArgumentError => e
34
- handle_argument_error?(instance, e, caller) ?
35
- instance.class.handle_argument_error(self, e, args, arity) : (raise e)
34
+ handle_argument_error?(instance, e, caller) ? instance.class.handle_argument_error(self, e, args, arity) : (raise e)
36
35
  rescue NoMethodError => e
37
- handle_no_method_error?(instance, e, caller) ?
38
- instance.class.handle_no_command_error(name) : (raise e)
36
+ handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (fail e)
39
37
  end
40
38
 
41
39
  # Returns the formatted usage by injecting given required arguments
@@ -43,20 +41,20 @@ class Thor
43
41
  def formatted_usage(klass, namespace = true, subcommand = false)
44
42
  if namespace
45
43
  namespace = klass.namespace
46
- formatted = "#{namespace.gsub(/^(default)/,'')}:"
44
+ formatted = "#{namespace.gsub(/^(default)/, '')}:"
47
45
  end
48
46
  formatted = "#{klass.namespace.split(':').last} " if subcommand
49
47
 
50
- formatted ||= ""
48
+ formatted ||= ''
51
49
 
52
50
  # Add usage with required arguments
53
51
  formatted << if klass && !klass.arguments.empty?
54
- usage.to_s.gsub(/^#{name}/) do |match|
55
- match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ')
56
- end
57
- else
58
- usage.to_s
59
- end
52
+ usage.to_s.gsub(/^#{name}/) do |match|
53
+ match << ' ' << klass.arguments.map { |a| a.usage }.compact.join(' ')
54
+ end
55
+ else
56
+ usage.to_s
57
+ end
60
58
 
61
59
  # Add required options
62
60
  formatted << " #{required_options}"
@@ -72,7 +70,7 @@ class Thor
72
70
  end
73
71
 
74
72
  def required_options
75
- @required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ")
73
+ @required_options ||= options.map { |_, o| o.usage if o.required? }.compact.sort.join(' ')
76
74
  end
77
75
 
78
76
  # Given a target, checks if this class name is a public method.
@@ -90,15 +88,15 @@ class Thor
90
88
  end
91
89
 
92
90
  def sans_backtrace(backtrace, caller) #:nodoc:
93
- saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) }
94
- saned -= caller
91
+ saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) }
92
+ saned - caller
95
93
  end
96
94
 
97
95
  def handle_argument_error?(instance, error, caller)
98
96
  not_debugging?(instance) && error.message =~ /wrong number of arguments/ && begin
99
97
  saned = sans_backtrace(error.backtrace, caller)
100
98
  # Ruby 1.9 always include the called method in the backtrace
101
- saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
99
+ saned.empty? || (saned.size == 1 && RUBY_VERSION >= '1.9')
102
100
  end
103
101
  end
104
102
 
@@ -107,7 +105,7 @@ class Thor
107
105
  error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
108
106
  end
109
107
  end
110
- Task = Command
108
+ Task = Command # rubocop:disable ConstantName
111
109
 
112
110
  # A command that is hidden in help messages but still invocable.
113
111
  class HiddenCommand < Command
@@ -115,15 +113,15 @@ class Thor
115
113
  true
116
114
  end
117
115
  end
118
- HiddenTask = HiddenCommand
116
+ HiddenTask = HiddenCommand # rubocop:disable ConstantName
119
117
 
120
118
  # A dynamic command that handles method missing scenarios.
121
119
  class DynamicCommand < Command
122
- def initialize(name, options=nil)
123
- super(name.to_s, "A dynamically-generated command", name.to_s, name.to_s, options)
120
+ def initialize(name, options = nil)
121
+ super(name.to_s, 'A dynamically-generated command', name.to_s, name.to_s, options)
124
122
  end
125
123
 
126
- def run(instance, args=[])
124
+ def run(instance, args = [])
127
125
  if (instance.methods & [name.to_s, name.to_sym]).empty?
128
126
  super
129
127
  else
@@ -131,6 +129,5 @@ class Thor
131
129
  end
132
130
  end
133
131
  end
134
- DynamicTask = DynamicCommand
135
-
132
+ DynamicTask = DynamicCommand # rubocop:disable ConstantName
136
133
  end
@@ -1,6 +1,5 @@
1
1
  class Thor
2
2
  module CoreExt #:nodoc:
3
-
4
3
  # A hash with indifferent access and magic predicates.
5
4
  #
6
5
  # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true
@@ -10,8 +9,7 @@ class Thor
10
9
  # hash.foo? #=> true
11
10
  #
12
11
  class HashWithIndifferentAccess < ::Hash #:nodoc:
13
-
14
- def initialize(hash={})
12
+ def initialize(hash = {})
15
13
  super()
16
14
  hash.each do |key, value|
17
15
  self[convert_key(key)] = value
@@ -31,7 +29,7 @@ class Thor
31
29
  end
32
30
 
33
31
  def values_at(*indices)
34
- indices.collect { |key| self[convert_key(key)] }
32
+ indices.map { |key| self[convert_key(key)] }
35
33
  end
36
34
 
37
35
  def merge(other)
@@ -50,31 +48,30 @@ class Thor
50
48
  Hash.new(default).merge!(self)
51
49
  end
52
50
 
53
- protected
51
+ protected
54
52
 
55
- def convert_key(key)
56
- key.is_a?(Symbol) ? key.to_s : key
57
- end
53
+ def convert_key(key)
54
+ key.is_a?(Symbol) ? key.to_s : key
55
+ end
58
56
 
59
- # Magic predicates. For instance:
60
- #
61
- # options.force? # => !!options['force']
62
- # options.shebang # => "/usr/lib/local/ruby"
63
- # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
64
- #
65
- def method_missing(method, *args, &block)
66
- method = method.to_s
67
- if method =~ /^(\w+)\?$/
68
- if args.empty?
69
- !!self[$1]
70
- else
71
- self[$1] == args.first
72
- end
57
+ # Magic predicates. For instance:
58
+ #
59
+ # options.force? # => !!options['force']
60
+ # options.shebang # => "/usr/lib/local/ruby"
61
+ # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
62
+ #
63
+ def method_missing(method, *args, &block)
64
+ method = method.to_s
65
+ if method =~ /^(\w+)\?$/
66
+ if args.empty?
67
+ !!self[$1]
73
68
  else
74
- self[method]
69
+ self[$1] == args.first
75
70
  end
71
+ else
72
+ self[method]
76
73
  end
77
-
74
+ end
78
75
  end
79
76
  end
80
77
  end
@@ -1,12 +1,10 @@
1
1
  class IO #:nodoc:
2
2
  class << self
3
-
4
3
  def binread(file, *args)
5
- raise ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3
4
+ fail ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3
6
5
  File.open(file, 'rb') do |f|
7
6
  f.read(*args)
8
7
  end
9
8
  end unless method_defined? :binread
10
-
11
9
  end
12
10
  end
@@ -1,6 +1,5 @@
1
1
  class Thor
2
2
  module CoreExt #:nodoc:
3
-
4
3
  if RUBY_VERSION >= '1.9'
5
4
  class OrderedHash < ::Hash
6
5
  end
@@ -24,12 +23,12 @@ class Thor
24
23
  end
25
24
 
26
25
  def []=(key, value)
27
- if node = @hash[key]
26
+ if node = @hash[key] # rubocop:disable AssignmentInCondition
28
27
  node.value = value
29
28
  else
30
29
  node = Node.new(key, value)
31
30
 
32
- if @first.nil?
31
+ if !defined?(@first) || @first.nil?
33
32
  @first = @last = node
34
33
  else
35
34
  node.prev = @last
@@ -43,7 +42,7 @@ class Thor
43
42
  end
44
43
 
45
44
  def delete(key)
46
- if node = @hash[key]
45
+ if node = @hash[key] # rubocop:disable AssignmentInCondition
47
46
  prev_node = node.prev
48
47
  next_node = node.next
49
48
 
@@ -61,25 +60,25 @@ class Thor
61
60
  end
62
61
 
63
62
  def keys
64
- self.map { |k, v| k }
63
+ map { |k, v| k }
65
64
  end
66
65
 
67
66
  def values
68
- self.map { |k, v| v }
67
+ map { |k, v| v }
69
68
  end
70
69
 
71
70
  def each
72
- return unless @first
71
+ return unless defined?(@first) && @first
73
72
  yield [@first.key, @first.value]
74
73
  node = @first
75
- yield [node.key, node.value] while node = node.next
74
+ yield [node.key, node.value] while node = node.next # rubocop:disable AssignmentInCondition
76
75
  self
77
76
  end
78
77
 
79
78
  def merge(other)
80
79
  hash = self.class.new
81
80
 
82
- self.each do |key, value|
81
+ each do |key, value|
83
82
  hash[key] = value
84
83
  end
85
84
 
@@ -95,6 +94,5 @@ class Thor
95
94
  end
96
95
  end
97
96
  end
98
-
99
97
  end
100
98
  end
@@ -11,11 +11,11 @@ class Thor
11
11
  # Raised when a command was not found.
12
12
  class UndefinedCommandError < Error
13
13
  end
14
- UndefinedTaskError = UndefinedCommandError
14
+ UndefinedTaskError = UndefinedCommandError # rubocop:disable ConstantName
15
15
 
16
16
  class AmbiguousCommandError < Error
17
17
  end
18
- AmbiguousTaskError = AmbiguousCommandError
18
+ AmbiguousTaskError = AmbiguousCommandError # rubocop:disable ConstantName
19
19
 
20
20
  # Raised when a command was found, but not invoked properly.
21
21
  class InvocationError < Error
@@ -4,7 +4,7 @@ require 'thor/base'
4
4
  # is that it invokes all commands at once. It also include some methods that allows
5
5
  # invocations to be done at the class method, which are not available to Thor
6
6
  # commands.
7
- class Thor::Group
7
+ class Thor::Group # rubocop:disable ClassLength
8
8
  class << self
9
9
  # The description for this Thor::Group. If none is provided, but a source root
10
10
  # exists, tries to find the USAGE one folder above it, otherwise searches
@@ -13,12 +13,11 @@ class Thor::Group
13
13
  # ==== Parameters
14
14
  # description<String>:: The description for this Thor::Group.
15
15
  #
16
- def desc(description=nil)
17
- @desc = case description
18
- when nil
19
- @desc || from_superclass(:desc, nil)
16
+ def desc(description = nil)
17
+ if description
18
+ @desc = description
20
19
  else
21
- description
20
+ @desc ||= from_superclass(:desc, nil)
22
21
  end
23
22
  end
24
23
 
@@ -28,11 +27,11 @@ class Thor::Group
28
27
  # short:: When true, shows only usage.
29
28
  #
30
29
  def help(shell)
31
- shell.say "Usage:"
30
+ shell.say 'Usage:'
32
31
  shell.say " #{banner}\n"
33
32
  shell.say
34
33
  class_options_help(shell)
35
- shell.say self.desc if self.desc
34
+ shell.say desc if desc
36
35
  end
37
36
 
38
37
  # Stores invocations for this class merging with superclass values.
@@ -54,7 +53,7 @@ class Thor::Group
54
53
  # The namespace/class given will have its options showed on the help
55
54
  # usage. Check invoke_from_option for more information.
56
55
  #
57
- def invoke(*names, &block)
56
+ def invoke(*names, &block) # rubocop:disable MethodLength
58
57
  options = names.last.is_a?(Hash) ? names.pop : {}
59
58
  verbose = options.fetch(:verbose, true)
60
59
 
@@ -108,14 +107,14 @@ class Thor::Group
108
107
  # invoked. The block receives two parameters, an instance of the current
109
108
  # class and the klass to be invoked.
110
109
  #
111
- def invoke_from_option(*names, &block)
110
+ def invoke_from_option(*names, &block) # rubocop:disable MethodLength
112
111
  options = names.last.is_a?(Hash) ? names.pop : {}
113
112
  verbose = options.fetch(:verbose, :white)
114
113
 
115
114
  names.each do |name|
116
115
  unless class_options.key?(name)
117
- raise ArgumentError, "You have to define the option #{name.inspect} " <<
118
- "before setting invoke_from_option."
116
+ fail ArgumentError, "You have to define the option #{name.inspect} " <<
117
+ 'before setting invoke_from_option.'
119
118
  end
120
119
 
121
120
  invocations[name] = true
@@ -159,7 +158,7 @@ class Thor::Group
159
158
  # Overwrite class options help to allow invoked generators options to be
160
159
  # shown recursively when invoking a generator.
161
160
  #
162
- def class_options_help(shell, groups={}) #:nodoc:
161
+ def class_options_help(shell, groups = {}) #:nodoc:
163
162
  get_options_from_invocations(groups, class_options) do |klass|
164
163
  klass.send(:get_options_from_invocations, groups, class_options)
165
164
  end
@@ -170,14 +169,14 @@ class Thor::Group
170
169
  # options are added to group_options hash. Options that already exists
171
170
  # in base_options are not added twice.
172
171
  #
173
- def get_options_from_invocations(group_options, base_options) #:nodoc:
172
+ def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
174
173
  invocations.each do |name, from_option|
175
174
  value = if from_option
176
- option = class_options[name]
177
- option.type == :boolean ? name : option.default
178
- else
179
- name
180
- end
175
+ option = class_options[name]
176
+ option.type == :boolean ? name : option.default
177
+ else
178
+ name
179
+ end
181
180
  next unless value
182
181
 
183
182
  klass, _ = prepare_for_invocation(name, value)
@@ -200,70 +199,70 @@ class Thor::Group
200
199
  def printable_commands(*)
201
200
  item = []
202
201
  item << banner
203
- item << (desc ? "# #{desc.gsub(/\s+/m,' ')}" : "")
202
+ item << (desc ? "# #{desc.gsub(/\s+/m, ' ')}" : '')
204
203
  [item]
205
204
  end
206
- alias printable_tasks printable_commands
205
+ alias_method :printable_tasks, :printable_commands
207
206
 
208
207
  def handle_argument_error(command, error, args, arity) #:nodoc:
209
208
  msg = "#{basename} #{command.name} takes #{arity} argument"
210
- msg << "s" if arity > 1
211
- msg << ", but it should not."
212
- raise error, msg
209
+ msg << 's' if arity > 1
210
+ msg << ', but it should not.'
211
+ fail error, msg
213
212
  end
214
213
 
215
- protected
214
+ protected
216
215
 
217
- # The method responsible for dispatching given the args.
218
- def dispatch(command, given_args, given_opts, config) #:nodoc:
219
- if Thor::HELP_MAPPINGS.include?(given_args.first)
220
- help(config[:shell])
221
- return
222
- end
216
+ # The method responsible for dispatching given the args.
217
+ def dispatch(command, given_args, given_opts, config) #:nodoc:
218
+ if Thor::HELP_MAPPINGS.include?(given_args.first)
219
+ help(config[:shell])
220
+ return
221
+ end
223
222
 
224
- args, opts = Thor::Options.split(given_args)
225
- opts = given_opts || opts
223
+ args, opts = Thor::Options.split(given_args)
224
+ opts = given_opts || opts
226
225
 
227
- instance = new(args, opts, config)
228
- yield instance if block_given?
226
+ instance = new(args, opts, config)
227
+ yield instance if block_given?
229
228
 
230
- if command
231
- instance.invoke_command(all_commands[command])
232
- else
233
- instance.invoke_all
234
- end
229
+ if command
230
+ instance.invoke_command(all_commands[command])
231
+ else
232
+ instance.invoke_all
235
233
  end
234
+ end
236
235
 
237
- # The banner for this class. You can customize it if you are invoking the
238
- # thor class by another ways which is not the Thor::Runner.
239
- def banner
240
- "#{basename} #{self_command.formatted_usage(self, false)}"
241
- end
236
+ # The banner for this class. You can customize it if you are invoking the
237
+ # thor class by another ways which is not the Thor::Runner.
238
+ def banner
239
+ "#{basename} #{self_command.formatted_usage(self, false)}"
240
+ end
242
241
 
243
- # Represents the whole class as a command.
244
- def self_command #:nodoc:
245
- Thor::DynamicCommand.new(self.namespace, class_options)
246
- end
247
- alias self_task self_command
242
+ # Represents the whole class as a command.
243
+ def self_command #:nodoc:
244
+ Thor::DynamicCommand.new(namespace, class_options)
245
+ end
246
+ alias_method :self_task, :self_command
248
247
 
249
- def baseclass #:nodoc:
250
- Thor::Group
251
- end
248
+ def baseclass #:nodoc:
249
+ Thor::Group
250
+ end
252
251
 
253
- def create_command(meth) #:nodoc:
254
- commands[meth.to_s] = Thor::Command.new(meth, nil, nil, nil, nil)
255
- true
256
- end
257
- alias create_task create_command
252
+ def create_command(meth) #:nodoc:
253
+ commands[meth.to_s] = Thor::Command.new(meth, nil, nil, nil, nil)
254
+ true
255
+ end
256
+ alias_method :create_task, :create_command
258
257
  end
259
258
 
260
259
  include Thor::Base
261
260
 
262
- protected
261
+ protected
263
262
 
264
263
  # Shortcut to invoke with padding and block handling. Use internally by
265
264
  # invoke and invoke_from_option class methods.
266
- def _invoke_for_class_method(klass, command=nil, *args, &block) #:nodoc:
265
+ def _invoke_for_class_method(klass, command = nil, *args, &block) #:nodoc:
267
266
  with_padding do
268
267
  if block
269
268
  case block.arity