bundler 1.8.9 → 1.9.0.pre

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -7
  3. data/CHANGELOG.md +8 -33
  4. data/Rakefile +51 -8
  5. data/lib/bundler/cli/gem.rb +20 -1
  6. data/lib/bundler/cli/install.rb +1 -1
  7. data/lib/bundler/definition.rb +8 -12
  8. data/lib/bundler/dep_proxy.rb +2 -2
  9. data/lib/bundler/installer.rb +12 -18
  10. data/lib/bundler/resolver.rb +168 -383
  11. data/lib/bundler/rubygems_ext.rb +1 -1
  12. data/lib/bundler/rubygems_integration.rb +6 -14
  13. data/lib/bundler/runtime.rb +3 -0
  14. data/lib/bundler/shared_helpers.rb +12 -7
  15. data/lib/bundler/source.rb +0 -5
  16. data/lib/bundler/source/path.rb +2 -1
  17. data/lib/bundler/source/path/installer.rb +0 -2
  18. data/lib/bundler/source/rubygems.rb +9 -11
  19. data/lib/bundler/templates/newgem/Rakefile.tt +0 -1
  20. data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  21. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb +5 -0
  22. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/dependency_graph.rb +266 -0
  23. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/errors.rb +69 -0
  24. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/gem_metadata.rb +3 -0
  25. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/specification_provider.rb +90 -0
  26. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/ui.rb +63 -0
  27. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolution.rb +412 -0
  28. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolver.rb +43 -0
  29. data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/state.rb +43 -0
  30. data/lib/bundler/vendor/{thor.rb → thor-0.19.1/lib/thor.rb} +57 -53
  31. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions.rb +34 -34
  32. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/create_file.rb +7 -7
  33. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/create_link.rb +2 -2
  34. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/directory.rb +11 -11
  35. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/empty_directory.rb +2 -2
  36. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/file_manipulation.rb +14 -14
  37. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/inject_into_file.rb +24 -24
  38. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/base.rb +71 -71
  39. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/command.rb +8 -8
  40. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/hash_with_indifferent_access.rb +2 -2
  41. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/io_binary_read.rb +1 -1
  42. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/ordered_hash.rb +2 -2
  43. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/error.rb +3 -3
  44. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/group.rb +27 -27
  45. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/invocation.rb +16 -11
  46. data/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb +17 -0
  47. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/line_editor/basic.rb +2 -2
  48. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/line_editor/readline.rb +7 -7
  49. data/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb +4 -0
  50. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/argument.rb +7 -7
  51. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/arguments.rb +10 -10
  52. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/option.rb +14 -10
  53. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/options.rb +12 -12
  54. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/rake_compat.rb +14 -14
  55. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/runner.rb +76 -76
  56. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell.rb +18 -18
  57. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/basic.rb +31 -30
  58. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/color.rb +10 -10
  59. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/html.rb +28 -28
  60. data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/util.rb +61 -61
  61. data/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb +3 -0
  62. data/lib/bundler/vendored_molinillo.rb +5 -0
  63. data/lib/bundler/vendored_thor.rb +3 -6
  64. data/lib/bundler/version.rb +1 -1
  65. metadata +44 -35
  66. data/lib/bundler/vendor/.document +0 -0
  67. data/lib/bundler/vendor/thor/line_editor.rb +0 -17
  68. data/lib/bundler/vendor/thor/parser.rb +0 -4
  69. data/lib/bundler/vendor/thor/version.rb +0 -3
@@ -1,21 +1,21 @@
1
- require 'rbconfig'
1
+ require "rbconfig"
2
2
 
3
- class Thor
3
+ class Bundler::Thor
4
4
  module Base
5
5
  class << self
6
6
  attr_writer :shell
7
7
 
8
- # Returns the shell used in all Thor classes. If you are in a Unix platform
8
+ # Returns the shell used in all Bundler::Thor classes. If you are in a Unix platform
9
9
  # it will use a colored log, otherwise it will use a basic one without color.
10
10
  #
11
11
  def shell
12
- @shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0
13
- Thor::Shell.const_get(ENV['THOR_SHELL'])
14
- elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ && !ENV['ANSICON']
15
- Thor::Shell::Basic
16
- else
17
- Thor::Shell::Color
18
- end
12
+ @shell ||= if ENV["THOR_SHELL"] && ENV["THOR_SHELL"].size > 0
13
+ Bundler::Thor::Shell.const_get(ENV["THOR_SHELL"])
14
+ elsif RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ && !ENV["ANSICON"]
15
+ Bundler::Thor::Shell::Basic
16
+ else
17
+ Bundler::Thor::Shell::Color
18
+ end
19
19
  end
20
20
  end
21
21
  end
@@ -24,9 +24,9 @@ class 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, 'thor/shell/basic'
28
- autoload :Color, 'thor/shell/color'
29
- autoload :HTML, 'thor/shell/html'
27
+ autoload :Basic, "thor/shell/basic"
28
+ autoload :Color, "thor/shell/color"
29
+ autoload :HTML, "thor/shell/html"
30
30
 
31
31
  # Add shell to initialize config values.
32
32
  #
@@ -35,11 +35,11 @@ class Thor
35
35
  #
36
36
  # ==== Examples
37
37
  #
38
- # class MyScript < Thor
38
+ # class MyScript < Bundler::Thor
39
39
  # argument :first, :type => :numeric
40
40
  # end
41
41
  #
42
- # MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new
42
+ # MyScript.new [1.0], { :foo => :bar }, :shell => Bundler::Thor::Shell::Basic.new
43
43
  #
44
44
  def initialize(args = [], options = {}, config = {})
45
45
  super
@@ -47,10 +47,10 @@ class Thor
47
47
  shell.base ||= self if shell.respond_to?(:base)
48
48
  end
49
49
 
50
- # Holds the shell for the given Thor instance. If no shell is given,
51
- # it gets a default shell from Thor::Base.shell.
50
+ # Holds the shell for the given Bundler::Thor instance. If no shell is given,
51
+ # it gets a default shell from Bundler::Thor::Base.shell.
52
52
  def shell
53
- @shell ||= Thor::Base.shell.new
53
+ @shell ||= Bundler::Thor::Base.shell.new
54
54
  end
55
55
 
56
56
  # Common methods that are delegated to the shell.
@@ -1,6 +1,7 @@
1
- require 'tempfile'
1
+ require "tempfile"
2
+ require "io/console" if RUBY_VERSION > "1.9.2"
2
3
 
3
- class Thor
4
+ class Bundler::Thor
4
5
  module Shell
5
6
  class Basic # rubocop:disable ClassLength
6
7
  attr_accessor :base
@@ -75,9 +76,9 @@ class Thor
75
76
  # ==== Example
76
77
  # say("I know you knew that.")
77
78
  #
78
- def say(message = '', color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
79
+ def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
79
80
  buffer = prepare_message(message, *color)
80
- buffer << "\n" if force_new_line && !message.end_with?("\n")
81
+ buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
81
82
 
82
83
  stdout.print(buffer)
83
84
  stdout.flush
@@ -90,7 +91,7 @@ class Thor
90
91
  #
91
92
  def say_status(status, message, log_status = true)
92
93
  return if quiet? || log_status == false
93
- spaces = ' ' * (padding + 1)
94
+ spaces = " " * (padding + 1)
94
95
  color = log_status.is_a?(Symbol) ? log_status : :green
95
96
 
96
97
  status = status.to_s.rjust(12)
@@ -162,17 +163,17 @@ class Thor
162
163
  maximas << maxima
163
164
  if index == colcount - 1
164
165
  # Don't output 2 trailing spaces when printing the last column
165
- formats << '%-s'
166
+ formats << "%-s"
166
167
  else
167
168
  formats << "%-#{maxima + 2}s"
168
169
  end
169
170
  end
170
171
 
171
- formats[0] = formats[0].insert(0, ' ' * indent)
172
- formats << '%s'
172
+ formats[0] = formats[0].insert(0, " " * indent)
173
+ formats << "%s"
173
174
 
174
175
  array.each do |row|
175
- sentence = ''
176
+ sentence = ""
176
177
 
177
178
  row.each_with_index do |column, index|
178
179
  maxima = maximas[index]
@@ -210,12 +211,12 @@ class Thor
210
211
  paras = message.split("\n\n")
211
212
 
212
213
  paras.map! do |unwrapped|
213
- unwrapped.strip.gsub(/\n/, ' ').squeeze(' ').gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }
214
+ unwrapped.strip.gsub(/\n/, " ").squeeze(" ").gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }
214
215
  end
215
216
 
216
217
  paras.each do |para|
217
218
  para.split("\n").each do |line|
218
- stdout.puts line.insert(0, ' ' * indent)
219
+ stdout.puts line.insert(0, " " * indent)
219
220
  end
220
221
  stdout.puts unless para == paras.last
221
222
  end
@@ -231,7 +232,7 @@ class Thor
231
232
  #
232
233
  def file_collision(destination) # rubocop:disable MethodLength
233
234
  return true if @always_force
234
- options = block_given? ? '[Ynaqdh]' : '[Ynaqh]'
235
+ options = block_given? ? "[Ynaqdh]" : "[Ynaqh]"
235
236
 
236
237
  loop do
237
238
  answer = ask(
@@ -240,18 +241,18 @@ class Thor
240
241
  )
241
242
 
242
243
  case answer
243
- when is?(:yes), is?(:force), ''
244
+ when is?(:yes), is?(:force), ""
244
245
  return true
245
246
  when is?(:no), is?(:skip)
246
247
  return false
247
248
  when is?(:always)
248
249
  return @always_force = true
249
250
  when is?(:quit)
250
- say 'Aborting...'
251
+ say "Aborting..."
251
252
  fail SystemExit
252
253
  when is?(:diff)
253
254
  show_diff(destination, yield) if block_given?
254
- say 'Retrying...'
255
+ say "Retrying..."
255
256
  else
256
257
  say file_collision_help
257
258
  end
@@ -261,8 +262,8 @@ class Thor
261
262
  # This code was copied from Rake, available under MIT-LICENSE
262
263
  # Copyright (c) 2003, 2004 Jim Weirich
263
264
  def terminal_width
264
- if ENV['THOR_COLUMNS']
265
- result = ENV['THOR_COLUMNS'].to_i
265
+ if ENV["THOR_COLUMNS"]
266
+ result = ENV["THOR_COLUMNS"].to_i
266
267
  else
267
268
  result = unix? ? dynamic_width : 80
268
269
  end
@@ -271,9 +272,9 @@ class Thor
271
272
  80
272
273
  end
273
274
 
274
- # Called if something goes wrong during the execution. This is used by Thor
275
+ # Called if something goes wrong during the execution. This is used by Bundler::Thor
275
276
  # internally and should not be used inside your scripts. If something went
276
- # wrong, you can always raise an exception. If you raise a Thor::Error, it
277
+ # wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
277
278
  # will be rescued and wrapped in the method below.
278
279
  #
279
280
  def error(statement)
@@ -281,7 +282,7 @@ class Thor
281
282
  end
282
283
 
283
284
  # Apply color to the given string with optional bold. Disabled in the
284
- # Thor::Shell::Basic class.
285
+ # Bundler::Thor::Shell::Basic class.
285
286
  #
286
287
  def set_color(string, *args) #:nodoc:
287
288
  string
@@ -333,7 +334,7 @@ class Thor
333
334
  end
334
335
 
335
336
  def show_diff(destination, content) #:nodoc:
336
- diff_cmd = ENV['THOR_DIFF'] || ENV['RAILS_DIFF'] || 'diff -u'
337
+ diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
337
338
 
338
339
  Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
339
340
  temp.write content
@@ -352,11 +353,11 @@ class Thor
352
353
  end
353
354
 
354
355
  def dynamic_width_stty
355
- %x{stty size 2>/dev/null}.split[1].to_i
356
+ %x(stty size 2>/dev/null).split[1].to_i
356
357
  end
357
358
 
358
359
  def dynamic_width_tput
359
- %x{tput cols 2>/dev/null}.to_i
360
+ %x(tput cols 2>/dev/null).to_i
360
361
  end
361
362
 
362
363
  def unix?
@@ -369,18 +370,18 @@ class Thor
369
370
  if chars.length <= width
370
371
  chars.join
371
372
  else
372
- ( chars[0, width - 3].join) + '...'
373
+ ( chars[0, width - 3].join) + "..."
373
374
  end
374
375
  end
375
376
  end
376
377
 
377
- if ''.respond_to?(:encode)
378
+ if "".respond_to?(:encode)
378
379
  def as_unicode
379
380
  yield
380
381
  end
381
382
  else
382
383
  def as_unicode
383
- old, $KCODE = $KCODE, 'U'
384
+ old, $KCODE = $KCODE, "U"
384
385
  yield
385
386
  ensure
386
387
  $KCODE = old
@@ -389,15 +390,15 @@ class Thor
389
390
 
390
391
  def ask_simply(statement, color, options)
391
392
  default = options[:default]
392
- message = [statement, ("(#{default})" if default), nil].uniq.join(' ')
393
+ message = [statement, ("(#{default})" if default), nil].uniq.join(" ")
393
394
  message = prepare_message(message, color)
394
- result = Thor::LineEditor.readline(message, options)
395
+ result = Bundler::Thor::LineEditor.readline(message, options)
395
396
 
396
397
  return unless result
397
398
 
398
399
  result.strip!
399
400
 
400
- if default && result == ''
401
+ if default && result == ""
401
402
  default
402
403
  else
403
404
  result
@@ -408,7 +409,7 @@ class Thor
408
409
  answer_set = options[:limited_to]
409
410
  correct_answer = nil
410
411
  until correct_answer
411
- answers = answer_set.join(', ')
412
+ answers = answer_set.join(", ")
412
413
  answer = ask_simply("#{statement} [#{answers}]", color, options)
413
414
  correct_answer = answer_set.include?(answer) ? answer : nil
414
415
  say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
@@ -1,9 +1,9 @@
1
- require 'thor/shell/basic'
1
+ require "thor/shell/basic"
2
2
 
3
- class Thor
3
+ class Bundler::Thor
4
4
  module Shell
5
- # Inherit from Thor::Shell::Basic and add set_color behavior. Check
6
- # Thor::Shell::Basic to see all available methods.
5
+ # Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check
6
+ # Bundler::Thor::Shell::Basic to see all available methods.
7
7
  #
8
8
  class Color < Basic
9
9
  # Embed in a String to clear all previous ANSI sequences.
@@ -89,7 +89,7 @@ class Thor
89
89
  foreground, bold = colors
90
90
  foreground = self.class.const_get(foreground.to_s.upcase) if foreground.is_a?(Symbol)
91
91
 
92
- bold = bold ? BOLD : ''
92
+ bold = bold ? BOLD : ""
93
93
  "#{bold}#{foreground}#{string}#{CLEAR}"
94
94
  end
95
95
  end
@@ -104,7 +104,7 @@ class Thor
104
104
  # available.
105
105
  #
106
106
  def show_diff(destination, content) #:nodoc:
107
- if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
107
+ if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
108
108
  actual = File.binread(destination).to_s.split("\n")
109
109
  content = content.to_s.split("\n")
110
110
 
@@ -118,11 +118,11 @@ class Thor
118
118
 
119
119
  def output_diff_line(diff) #:nodoc:
120
120
  case diff.action
121
- when '-'
121
+ when "-"
122
122
  say "- #{diff.old_element.chomp}", :red, true
123
- when '+'
123
+ when "+"
124
124
  say "+ #{diff.new_element.chomp}", :green, true
125
- when '!'
125
+ when "!"
126
126
  say "- #{diff.old_element.chomp}", :red, true
127
127
  say "+ #{diff.new_element.chomp}", :green, true
128
128
  else
@@ -138,7 +138,7 @@ class Thor
138
138
  return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
139
139
 
140
140
  @diff_lcs_loaded = begin
141
- require 'diff/lcs'
141
+ require "diff/lcs"
142
142
  true
143
143
  rescue LoadError
144
144
  false
@@ -1,47 +1,47 @@
1
- require 'thor/shell/basic'
1
+ require "thor/shell/basic"
2
2
 
3
- class Thor
3
+ class Bundler::Thor
4
4
  module Shell
5
- # Inherit from Thor::Shell::Basic and add set_color behavior. Check
6
- # Thor::Shell::Basic to see all available methods.
5
+ # Inherit from Bundler::Thor::Shell::Basic and add set_color behavior. Check
6
+ # Bundler::Thor::Shell::Basic to see all available methods.
7
7
  #
8
8
  class HTML < Basic
9
9
  # The start of an HTML bold sequence.
10
- BOLD = 'font-weight: bold'
10
+ BOLD = "font-weight: bold"
11
11
 
12
12
  # Set the terminal's foreground HTML color to black.
13
- BLACK = 'color: black'
13
+ BLACK = "color: black"
14
14
  # Set the terminal's foreground HTML color to red.
15
- RED = 'color: red'
15
+ RED = "color: red"
16
16
  # Set the terminal's foreground HTML color to green.
17
- GREEN = 'color: green'
17
+ GREEN = "color: green"
18
18
  # Set the terminal's foreground HTML color to yellow.
19
- YELLOW = 'color: yellow'
19
+ YELLOW = "color: yellow"
20
20
  # Set the terminal's foreground HTML color to blue.
21
- BLUE = 'color: blue'
21
+ BLUE = "color: blue"
22
22
  # Set the terminal's foreground HTML color to magenta.
23
- MAGENTA = 'color: magenta'
23
+ MAGENTA = "color: magenta"
24
24
  # Set the terminal's foreground HTML color to cyan.
25
- CYAN = 'color: cyan'
25
+ CYAN = "color: cyan"
26
26
  # Set the terminal's foreground HTML color to white.
27
- WHITE = 'color: white'
27
+ WHITE = "color: white"
28
28
 
29
29
  # Set the terminal's background HTML color to black.
30
- ON_BLACK = 'background-color: black'
30
+ ON_BLACK = "background-color: black"
31
31
  # Set the terminal's background HTML color to red.
32
- ON_RED = 'background-color: red'
32
+ ON_RED = "background-color: red"
33
33
  # Set the terminal's background HTML color to green.
34
- ON_GREEN = 'background-color: green'
34
+ ON_GREEN = "background-color: green"
35
35
  # Set the terminal's background HTML color to yellow.
36
- ON_YELLOW = 'background-color: yellow'
36
+ ON_YELLOW = "background-color: yellow"
37
37
  # Set the terminal's background HTML color to blue.
38
- ON_BLUE = 'background-color: blue'
38
+ ON_BLUE = "background-color: blue"
39
39
  # Set the terminal's background HTML color to magenta.
40
- ON_MAGENTA = 'background-color: magenta'
40
+ ON_MAGENTA = "background-color: magenta"
41
41
  # Set the terminal's background HTML color to cyan.
42
- ON_CYAN = 'background-color: cyan'
42
+ ON_CYAN = "background-color: cyan"
43
43
  # Set the terminal's background HTML color to white.
44
- ON_WHITE = 'background-color: white'
44
+ ON_WHITE = "background-color: white"
45
45
 
46
46
  # Set color by using a string or one of the defined constants. If a third
47
47
  # option is set to true, it also adds bold to the string. This is based
@@ -66,9 +66,9 @@ class Thor
66
66
  # ==== Example
67
67
  # ask("What is your name?")
68
68
  #
69
- # TODO: Implement #ask for Thor::Shell::HTML
69
+ # TODO: Implement #ask for Bundler::Thor::Shell::HTML
70
70
  def ask(statement, color = nil)
71
- fail NotImplementedError, 'Implement #ask for Thor::Shell::HTML'
71
+ fail NotImplementedError, "Implement #ask for Bundler::Thor::Shell::HTML"
72
72
  end
73
73
 
74
74
  protected
@@ -81,7 +81,7 @@ class Thor
81
81
  # available.
82
82
  #
83
83
  def show_diff(destination, content) #:nodoc:
84
- if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
84
+ if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
85
85
  actual = File.binread(destination).to_s.split("\n")
86
86
  content = content.to_s.split("\n")
87
87
 
@@ -95,11 +95,11 @@ class Thor
95
95
 
96
96
  def output_diff_line(diff) #:nodoc:
97
97
  case diff.action
98
- when '-'
98
+ when "-"
99
99
  say "- #{diff.old_element.chomp}", :red, true
100
- when '+'
100
+ when "+"
101
101
  say "+ #{diff.new_element.chomp}", :green, true
102
- when '!'
102
+ when "!"
103
103
  say "- #{diff.old_element.chomp}", :red, true
104
104
  say "+ #{diff.new_element.chomp}", :green, true
105
105
  else
@@ -115,7 +115,7 @@ class Thor
115
115
  return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
116
116
 
117
117
  @diff_lcs_loaded = begin
118
- require 'diff/lcs'
118
+ require "diff/lcs"
119
119
  true
120
120
  rescue LoadError
121
121
  false
@@ -1,6 +1,6 @@
1
- require 'rbconfig'
1
+ require "rbconfig"
2
2
 
3
- class Thor
3
+ class Bundler::Thor
4
4
  module Sandbox #:nodoc:
5
5
  end
6
6
 
@@ -8,30 +8,30 @@ class Thor
8
8
  #
9
9
  # 1) Methods to convert thor namespaces to constants and vice-versa.
10
10
  #
11
- # Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
11
+ # Bundler::Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
12
12
  #
13
13
  # 2) Loading thor files and sandboxing:
14
14
  #
15
- # Thor::Util.load_thorfile("~/.thor/foo")
15
+ # Bundler::Thor::Util.load_thorfile("~/.thor/foo")
16
16
  #
17
17
  module Util
18
18
  class << self
19
- # Receives a namespace and search for it in the Thor::Base subclasses.
19
+ # Receives a namespace and search for it in the Bundler::Thor::Base subclasses.
20
20
  #
21
21
  # ==== Parameters
22
22
  # namespace<String>:: The namespace to search for.
23
23
  #
24
24
  def find_by_namespace(namespace)
25
25
  namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
26
- Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }
26
+ Bundler::Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }
27
27
  end
28
28
 
29
- # Receives a constant and converts it to a Thor namespace. Since Thor
29
+ # Receives a constant and converts it to a Bundler::Thor namespace. Since Bundler::Thor
30
30
  # commands can be added to a sandbox, this method is also responsable for
31
31
  # removing the sandbox namespace.
32
32
  #
33
33
  # This method should not be used in general because it's used to deal with
34
- # older versions of Thor. On current versions, if you need to get the
34
+ # older versions of Bundler::Thor. On current versions, if you need to get the
35
35
  # namespace from a class, just call namespace on it.
36
36
  #
37
37
  # ==== Parameters
@@ -41,8 +41,8 @@ class Thor
41
41
  # String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
42
42
  #
43
43
  def namespace_from_thor_class(constant)
44
- constant = constant.to_s.gsub(/^Thor::Sandbox::/, '')
45
- constant = snake_case(constant).squeeze(':')
44
+ constant = constant.to_s.gsub(/^Bundler::Thor::Sandbox::/, "")
45
+ constant = snake_case(constant).squeeze(":")
46
46
  constant
47
47
  end
48
48
 
@@ -56,13 +56,13 @@ class Thor
56
56
  # Array[Object]
57
57
  #
58
58
  def namespaces_in_content(contents, file = __FILE__)
59
- old_constants = Thor::Base.subclasses.dup
60
- Thor::Base.subclasses.clear
59
+ old_constants = Bundler::Thor::Base.subclasses.dup
60
+ Bundler::Thor::Base.subclasses.clear
61
61
 
62
62
  load_thorfile(file, contents)
63
63
 
64
- new_constants = Thor::Base.subclasses.dup
65
- Thor::Base.subclasses.replace(old_constants)
64
+ new_constants = Bundler::Thor::Base.subclasses.dup
65
+ Bundler::Thor::Base.subclasses.replace(old_constants)
66
66
 
67
67
  new_constants.map! { |c| c.namespace }
68
68
  new_constants.compact!
@@ -73,9 +73,9 @@ class Thor
73
73
  #
74
74
  def thor_classes_in(klass)
75
75
  stringfied_constants = klass.constants.map { |c| c.to_s }
76
- Thor::Base.subclasses.select do |subclass|
76
+ Bundler::Thor::Base.subclasses.select do |subclass|
77
77
  next unless subclass.name
78
- stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ''))
78
+ stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ""))
79
79
  end
80
80
  end
81
81
 
@@ -89,7 +89,7 @@ class Thor
89
89
  #
90
90
  def snake_case(str)
91
91
  return str.downcase if str =~ /^[A-Z_]+$/
92
- str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/
92
+ str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
93
93
  $+.downcase
94
94
  end
95
95
 
@@ -103,43 +103,43 @@ class Thor
103
103
  #
104
104
  def camel_case(str)
105
105
  return str if str !~ /_/ && str =~ /[A-Z]+.*/
106
- str.split('_').map { |i| i.capitalize }.join
106
+ str.split("_").map { |i| i.capitalize }.join
107
107
  end
108
108
 
109
- # Receives a namespace and tries to retrieve a Thor or Thor::Group class
109
+ # Receives a namespace and tries to retrieve a Bundler::Thor or Bundler::Thor::Group class
110
110
  # from it. It first searches for a class using the all the given namespace,
111
111
  # if it's not found, removes the highest entry and searches for the class
112
112
  # again. If found, returns the highest entry as the class name.
113
113
  #
114
114
  # ==== Examples
115
115
  #
116
- # class Foo::Bar < Thor
116
+ # class Foo::Bar < Bundler::Thor
117
117
  # def baz
118
118
  # end
119
119
  # end
120
120
  #
121
- # class Baz::Foo < Thor::Group
121
+ # class Baz::Foo < Bundler::Thor::Group
122
122
  # end
123
123
  #
124
- # Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command
125
- # Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
126
- # Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
124
+ # Bundler::Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default command
125
+ # Bundler::Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
126
+ # Bundler::Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
127
127
  #
128
128
  # ==== Parameters
129
129
  # namespace<String>
130
130
  #
131
131
  def find_class_and_command_by_namespace(namespace, fallback = true)
132
- if namespace.include?(':') # look for a namespaced command
133
- pieces = namespace.split(':')
132
+ if namespace.include?(":") # look for a namespaced command
133
+ pieces = namespace.split(":")
134
134
  command = pieces.pop
135
- klass = Thor::Util.find_by_namespace(pieces.join(':'))
135
+ klass = Bundler::Thor::Util.find_by_namespace(pieces.join(":"))
136
136
  end
137
- unless klass # look for a Thor::Group with the right name
138
- klass, command = Thor::Util.find_by_namespace(namespace), nil
137
+ unless klass # look for a Bundler::Thor::Group with the right name
138
+ klass, command = Bundler::Thor::Util.find_by_namespace(namespace), nil
139
139
  end
140
140
  if !klass && fallback # try a command in the default namespace
141
141
  command = namespace
142
- klass = Thor::Util.find_by_namespace('')
142
+ klass = Bundler::Thor::Util.find_by_namespace("")
143
143
  end
144
144
  [klass, command]
145
145
  end
@@ -152,7 +152,7 @@ class Thor
152
152
  content ||= File.binread(path)
153
153
 
154
154
  begin
155
- Thor::Sandbox.class_eval(content, path)
155
+ Bundler::Thor::Sandbox.class_eval(content, path)
156
156
  rescue StandardError => e
157
157
  $stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
158
158
  if debug
@@ -164,31 +164,31 @@ class Thor
164
164
  end
165
165
 
166
166
  def user_home # rubocop:disable MethodLength
167
- @@user_home ||= if ENV['HOME']
168
- ENV['HOME']
169
- elsif ENV['USERPROFILE']
170
- ENV['USERPROFILE']
171
- elsif ENV['HOMEDRIVE'] && ENV['HOMEPATH']
172
- File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH'])
173
- elsif ENV['APPDATA']
174
- ENV['APPDATA']
175
- else
176
- begin
177
- File.expand_path('~')
178
- rescue
179
- if File::ALT_SEPARATOR
180
- 'C:/'
181
- else
182
- '/'
183
- end
184
- end
185
- end
167
+ @@user_home ||= if ENV["HOME"]
168
+ ENV["HOME"]
169
+ elsif ENV["USERPROFILE"]
170
+ ENV["USERPROFILE"]
171
+ elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
172
+ File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
173
+ elsif ENV["APPDATA"]
174
+ ENV["APPDATA"]
175
+ else
176
+ begin
177
+ File.expand_path("~")
178
+ rescue
179
+ if File::ALT_SEPARATOR
180
+ "C:/"
181
+ else
182
+ "/"
183
+ end
184
+ end
185
+ end
186
186
  end
187
187
 
188
188
  # Returns the root where thor files are located, depending on the OS.
189
189
  #
190
190
  def thor_root
191
- File.join(user_home, '.thor').gsub(/\\/, '/')
191
+ File.join(user_home, ".thor").gsub(/\\/, "/")
192
192
  end
193
193
 
194
194
  # Returns the files in the thor root. On Windows thor_root will be something
@@ -202,15 +202,15 @@ class Thor
202
202
  files = Dir["#{escape_globs(thor_root)}/*"]
203
203
 
204
204
  files.map! do |file|
205
- File.directory?(file) ? File.join(file, 'main.thor') : file
205
+ File.directory?(file) ? File.join(file, "main.thor") : file
206
206
  end
207
207
  end
208
208
 
209
- # Where to look for Thor files.
209
+ # Where to look for Bundler::Thor files.
210
210
  #
211
211
  def globs_for(path)
212
212
  path = escape_globs(path)
213
- ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
213
+ ["#{path}/Bundler::Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
214
214
  end
215
215
 
216
216
  # Return the path to the ruby interpreter taking into account multiple
@@ -218,15 +218,15 @@ class Thor
218
218
  #
219
219
  def ruby_command # rubocop:disable MethodLength
220
220
  @ruby_command ||= begin
221
- ruby_name = RbConfig::CONFIG['ruby_install_name']
222
- ruby = File.join(RbConfig::CONFIG['bindir'], ruby_name)
223
- ruby << RbConfig::CONFIG['EXEEXT']
221
+ ruby_name = RbConfig::CONFIG["ruby_install_name"]
222
+ ruby = File.join(RbConfig::CONFIG["bindir"], ruby_name)
223
+ ruby << RbConfig::CONFIG["EXEEXT"]
224
224
 
225
225
  # avoid using different name than ruby (on platforms supporting links)
226
- if ruby_name != 'ruby' && File.respond_to?(:readlink)
226
+ if ruby_name != "ruby" && File.respond_to?(:readlink)
227
227
  begin
228
- alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby')
229
- alternate_ruby << RbConfig::CONFIG['EXEEXT']
228
+ alternate_ruby = File.join(RbConfig::CONFIG["bindir"], "ruby")
229
+ alternate_ruby << RbConfig::CONFIG["EXEEXT"]
230
230
 
231
231
  # ruby is a symlink
232
232
  if File.symlink? alternate_ruby
@@ -251,7 +251,7 @@ class Thor
251
251
  #
252
252
  # ==== Examples
253
253
  #
254
- # Thor::Util.escape_globs('[apps]') # => '\[apps\]'
254
+ # Bundler::Thor::Util.escape_globs('[apps]') # => '\[apps\]'
255
255
  #
256
256
  # ==== Parameters
257
257
  # String