bundler 1.5.3 → 1.6.0.pre.1

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 (74) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -11
  3. data/CHANGELOG.md +10 -3
  4. data/CONTRIBUTING.md +21 -12
  5. data/DEVELOPMENT.md +2 -2
  6. data/README.md +3 -2
  7. data/Rakefile +19 -9
  8. data/bundler.gemspec +1 -1
  9. data/lib/bundler.rb +9 -5
  10. data/lib/bundler/cli.rb +51 -10
  11. data/lib/bundler/dsl.rb +10 -6
  12. data/lib/bundler/friendly_errors.rb +1 -1
  13. data/lib/bundler/installer.rb +28 -17
  14. data/lib/bundler/parallel_workers/worker.rb +1 -1
  15. data/lib/bundler/resolver.rb +191 -207
  16. data/lib/bundler/rubygems_ext.rb +2 -4
  17. data/lib/bundler/rubygems_integration.rb +5 -0
  18. data/lib/bundler/runtime.rb +15 -12
  19. data/lib/bundler/settings.rb +4 -2
  20. data/lib/bundler/source.rb +11 -1
  21. data/lib/bundler/source/git.rb +11 -7
  22. data/lib/bundler/source/git/git_proxy.rb +4 -7
  23. data/lib/bundler/source/path.rb +21 -12
  24. data/lib/bundler/source/path/installer.rb +1 -1
  25. data/lib/bundler/source/rubygems.rb +18 -8
  26. data/lib/bundler/ssl_certs/certificate_manager.rb +41 -0
  27. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  28. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -2
  29. data/lib/bundler/ui.rb +4 -141
  30. data/lib/bundler/ui/rg_proxy.rb +21 -0
  31. data/lib/bundler/ui/shell.rb +98 -0
  32. data/lib/bundler/ui/silent.rb +44 -0
  33. data/lib/bundler/vendor/net/http/faster.rb +0 -1
  34. data/lib/bundler/vendor/net/http/persistent.rb +0 -1
  35. data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +0 -1
  36. data/lib/bundler/version.rb +1 -1
  37. data/spec/bundler/definition_spec.rb +2 -2
  38. data/spec/bundler/dsl_spec.rb +3 -3
  39. data/spec/bundler/gem_helper_spec.rb +5 -7
  40. data/spec/bundler/settings_spec.rb +15 -0
  41. data/spec/bundler/source_spec.rb +1 -1
  42. data/spec/commands/config_spec.rb +18 -0
  43. data/spec/commands/console_spec.rb +22 -0
  44. data/spec/commands/exec_spec.rb +1 -0
  45. data/spec/commands/newgem_spec.rb +2 -2
  46. data/spec/commands/open_spec.rb +13 -0
  47. data/spec/{install/gems/packed_spec.rb → commands/package_spec.rb} +30 -0
  48. data/spec/commands/show_spec.rb +87 -71
  49. data/spec/install/binstubs_spec.rb +1 -1
  50. data/spec/install/bundler_spec.rb +1 -1
  51. data/spec/install/gemfile/git_spec.rb +1 -1
  52. data/spec/install/gemfile/path_spec.rb +12 -0
  53. data/spec/install/gemfile_spec.rb +1 -1
  54. data/spec/install/gems/groups_spec.rb +1 -1
  55. data/spec/install/gems/platform_spec.rb +0 -1
  56. data/spec/install/gems/post_install_spec.rb +74 -0
  57. data/spec/install/gems/resolving_spec.rb +22 -26
  58. data/spec/install/gems/simple_case_spec.rb +17 -1
  59. data/spec/install/gemspecs_spec.rb +1 -1
  60. data/spec/install/path_spec.rb +1 -1
  61. data/spec/install/prereleases_spec.rb +1 -1
  62. data/spec/other/ext_spec.rb +1 -1
  63. data/spec/other/ssl_cert_spec.rb +10 -0
  64. data/spec/realworld/edgecases_spec.rb +1 -1
  65. data/spec/resolver/basic_spec.rb +29 -0
  66. data/spec/support/builders.rb +42 -43
  67. data/spec/support/indexes.rb +129 -1
  68. data/spec/support/permissions.rb +1 -0
  69. data/spec/update/gems_spec.rb +37 -0
  70. data/spec/update/git_spec.rb +24 -1
  71. data/spec/update/source_spec.rb +14 -1
  72. metadata +14 -9
  73. data/lib/bundler/safe_catch.rb +0 -101
  74. data/spec/bundler/safe_catch_spec.rb +0 -37
@@ -56,10 +56,8 @@ module Gem
56
56
  end
57
57
 
58
58
  def git_version
59
- if loaded_from && File.exist?(File.join(full_gem_path, ".git"))
60
- sha = Bundler::SharedHelpers.chdir(full_gem_path){ `git rev-parse HEAD`.strip }
61
- " #{sha[0..6]}"
62
- end
59
+ return unless loaded_from && source.is_a?(Bundler::Source::Git)
60
+ " #{source.revision[0..6]}"
63
61
  end
64
62
 
65
63
  def to_gemfile(path = nil)
@@ -290,6 +290,11 @@ module Bundler
290
290
 
291
291
  if exec_name
292
292
  spec = specs.find { |s| s.executables.include?(exec_name) }
293
+ unless spec.name == name
294
+ warn "Bundler is using a binstub that was created for a different gem.\n" \
295
+ "This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
296
+ "to work around a system/bundle conflict."
297
+ end
293
298
  spec or raise Gem::Exception, "can't find executable #{exec_name}"
294
299
  else
295
300
  spec = specs.find { |s| s.name == name }
@@ -104,13 +104,14 @@ module Bundler
104
104
 
105
105
  alias gems specs
106
106
 
107
- def cache
107
+ def cache(custom_path = nil)
108
+ cache_path = cache_path(custom_path)
108
109
  FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path)
109
110
 
110
111
  Bundler.ui.info "Updating files in vendor/cache"
111
112
  specs.each do |spec|
112
113
  next if spec.name == 'bundler'
113
- spec.source.cache(spec) if spec.source.respond_to?(:cache)
114
+ spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
114
115
  end
115
116
 
116
117
  Dir[cache_path.join("*/.git")].each do |git_dir|
@@ -118,14 +119,15 @@ module Bundler
118
119
  FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
119
120
  end
120
121
 
121
- prune_cache unless Bundler.settings[:no_prune]
122
+ prune_cache(custom_path) unless Bundler.settings[:no_prune]
122
123
  end
123
124
 
124
- def prune_cache
125
+ def prune_cache(custom_path)
126
+ cache_path = cache_path(custom_path)
125
127
  FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path)
126
128
  resolve = @definition.resolve
127
- prune_gem_cache(resolve)
128
- prune_git_and_path_cache(resolve)
129
+ prune_gem_cache(resolve, custom_path)
130
+ prune_git_and_path_cache(resolve, custom_path)
129
131
  end
130
132
 
131
133
  def clean(dry_run = false)
@@ -239,8 +241,8 @@ module Bundler
239
241
 
240
242
  private
241
243
 
242
- def prune_gem_cache(resolve)
243
- cached = Dir["#{cache_path}/*.gem"]
244
+ def prune_gem_cache(resolve, custom_path)
245
+ cached = Dir["#{cache_path(custom_path)}/*.gem"]
244
246
 
245
247
  cached = cached.delete_if do |path|
246
248
  spec = Bundler.rubygems.spec_from_gem path
@@ -260,8 +262,8 @@ module Bundler
260
262
  end
261
263
  end
262
264
 
263
- def prune_git_and_path_cache(resolve)
264
- cached = Dir["#{cache_path}/*/.bundlecache"]
265
+ def prune_git_and_path_cache(resolve, custom_path)
266
+ cached = Dir["#{cache_path(custom_path)}/*/.bundlecache"]
265
267
 
266
268
  cached = cached.delete_if do |path|
267
269
  name = File.basename(File.dirname(path))
@@ -300,8 +302,9 @@ module Bundler
300
302
  end
301
303
  end
302
304
 
303
- def cache_path
304
- root.join("vendor/cache")
305
+ def cache_path(custom_path = nil)
306
+ path = custom_path || root
307
+ path.join("vendor/cache")
305
308
  end
306
309
  end
307
310
  end
@@ -13,7 +13,7 @@ module Bundler
13
13
  end
14
14
 
15
15
  def []=(key, value)
16
- local_config_file || raise(GemfileNotFound)
16
+ local_config_file or raise GemfileNotFound, "Could not locate Gemfile"
17
17
  set_key(key, value, @local_config, local_config_file)
18
18
  end
19
19
 
@@ -154,7 +154,9 @@ module Bundler
154
154
  def load_config(config_file)
155
155
  valid_file = config_file && config_file.exist? && !config_file.size.zero?
156
156
  if !ignore_config? && valid_file
157
- Hash[config_file.read.scan(/^(BUNDLE_.+): ['"]?(.+?)['"]?$/)]
157
+ config_regex = /^(BUNDLE_.+): (?:['"](.*)['"]|(.+))$/
158
+ config_pairs = config_file.read.scan(config_regex).map{|m| m.compact }
159
+ Hash[config_pairs]
158
160
  else
159
161
  {}
160
162
  end
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
- module Source
2
+ class Source
3
3
  autoload :Rubygems, 'bundler/source/rubygems'
4
4
  autoload :Path, 'bundler/source/path'
5
5
  autoload :Git, 'bundler/source/git'
@@ -14,5 +14,15 @@ module Bundler
14
14
  mirrors[normalized_key] || uri
15
15
  end
16
16
 
17
+ def version_message(spec)
18
+ locked_spec = Bundler.locked_gems.specs.find { |s| s.name == spec.name } if Bundler.locked_gems
19
+ locked_spec_version = locked_spec.version if locked_spec
20
+ message = "#{spec.name} #{spec.version}"
21
+ if locked_spec_version && spec.version != locked_spec_version
22
+ message << " (was #{locked_spec_version})"
23
+ end
24
+ message
25
+ end
26
+
17
27
  end
18
28
  end
@@ -3,7 +3,7 @@ require 'uri'
3
3
  require 'digest/sha1'
4
4
 
5
5
  module Bundler
6
- module Source
6
+ class Source
7
7
 
8
8
  class Git < Path
9
9
  autoload :GitProxy, 'bundler/source/git/git_proxy'
@@ -159,10 +159,14 @@ module Bundler
159
159
  @copied = true
160
160
  end
161
161
  generate_bin(spec)
162
- ["Using #{spec.name} (#{spec.version}) from #{to_s}", nil, debug]
162
+ if requires_checkout? && spec.post_install_message
163
+ Installer.post_install_messages[spec.name] = spec.post_install_message
164
+ end
165
+ ["Using #{version_message(spec)} from #{to_s}", nil, debug]
163
166
  end
164
167
 
165
- def cache(spec)
168
+ def cache(spec, custom_path = nil)
169
+ app_cache_path = app_cache_path(custom_path)
166
170
  return unless Bundler.settings[:cache_all]
167
171
  return if path == app_cache_path
168
172
  cached!
@@ -199,6 +203,10 @@ module Bundler
199
203
  "#{base_name}-#{shortref_for_path(cached_revision || revision)}"
200
204
  end
201
205
 
206
+ def revision
207
+ git_proxy.revision
208
+ end
209
+
202
210
  private
203
211
 
204
212
  def serialize_gemspecs_in(destination)
@@ -263,10 +271,6 @@ module Bundler
263
271
  options["revision"]
264
272
  end
265
273
 
266
- def revision
267
- git_proxy.revision
268
- end
269
-
270
274
  def cached?
271
275
  cache_path.exist?
272
276
  end
@@ -1,6 +1,7 @@
1
1
  module Bundler
2
- module Source
2
+ class Source
3
3
  class Git < Path
4
+
4
5
  class GitNotInstalledError < GitError
5
6
  def initialize
6
7
  msg = "You need to install git to be able to use gems from git repositories. "
@@ -61,7 +62,7 @@ module Bundler
61
62
  def checkout
62
63
  if path.exist?
63
64
  return if has_revision_cached?
64
- Bundler.ui.info "Updating #{uri}"
65
+ Bundler.ui.confirm "Updating #{uri}"
65
66
  in_path do
66
67
  git %|fetch --force --quiet --tags #{uri_escaped} "refs/heads/*:refs/heads/*"|
67
68
  end
@@ -100,11 +101,7 @@ module Bundler
100
101
  # If it doesn't, everything will work fine, but the user
101
102
  # will get the $stderr messages as well.
102
103
  def git_null(command)
103
- if !Bundler::WINDOWS && File.exist?("/dev/null")
104
- git("#{command} 2>/dev/null", false)
105
- else
106
- git(command, false)
107
- end
104
+ git("#{command} 2>#{Bundler::NULL}", false)
108
105
  end
109
106
 
110
107
  def git(command, check_errors=true)
@@ -1,7 +1,7 @@
1
1
  module Bundler
2
- module Source
2
+ class Source
3
3
 
4
- class Path
4
+ class Path < Source
5
5
  autoload :Installer, 'bundler/source/path/installer'
6
6
 
7
7
  attr_reader :path, :options
@@ -19,7 +19,7 @@ module Bundler
19
19
 
20
20
  if options["path"]
21
21
  @path = Pathname.new(options["path"])
22
- @path = @path.expand_path(Bundler.root) unless @path.relative?
22
+ @path = expand(@path) unless @path.relative?
23
23
  end
24
24
 
25
25
  @name = options["name"]
@@ -59,24 +59,25 @@ module Bundler
59
59
 
60
60
  def eql?(o)
61
61
  o.instance_of?(Path) &&
62
- path.expand_path(Bundler.root) == o.path.expand_path(Bundler.root) &&
62
+ expand(path) == expand(o.path) &&
63
63
  version == o.version
64
64
  end
65
65
 
66
66
  alias == eql?
67
67
 
68
68
  def name
69
- File.basename(path.expand_path(Bundler.root).to_s)
69
+ File.basename(expand(path).to_s)
70
70
  end
71
71
 
72
72
  def install(spec)
73
73
  generate_bin(spec, :disable_extensions)
74
- ["Using #{spec.name} (#{spec.version}) from #{to_s}", nil]
74
+ ["Using #{version_message(spec)} from #{to_s}", nil]
75
75
  end
76
76
 
77
- def cache(spec)
77
+ def cache(spec, custom_path = nil)
78
+ app_cache_path = app_cache_path(custom_path)
78
79
  return unless Bundler.settings[:cache_all]
79
- return if @original_path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0
80
+ return if expand(@original_path).to_s.index(Bundler.root.to_s) == 0
80
81
  FileUtils.rm_rf(app_cache_path)
81
82
  FileUtils.cp_r("#{@original_path}/.", app_cache_path)
82
83
  FileUtils.touch(app_cache_path.join(".bundlecache"))
@@ -97,10 +98,18 @@ module Bundler
97
98
  name
98
99
  end
99
100
 
100
- private
101
+ private
101
102
 
102
- def app_cache_path
103
- @app_cache_path ||= Bundler.app_cache.join(app_cache_dirname)
103
+ def expand(somepath)
104
+ somepath.expand_path(Bundler.root)
105
+ rescue ArgumentError => e
106
+ Bundler.ui.debug(e)
107
+ raise PathError, "There was an error while trying to use the path " \
108
+ "`#{somepath}`.\nThe error message was: #{e.message}."
109
+ end
110
+
111
+ def app_cache_path(custom_path = nil)
112
+ @app_cache_path ||= Bundler.app_cache(custom_path).join(app_cache_dirname)
104
113
  end
105
114
 
106
115
  def has_app_cache?
@@ -109,7 +118,7 @@ module Bundler
109
118
 
110
119
  def load_spec_files
111
120
  index = Index.new
112
- expanded_path = path.expand_path(Bundler.root)
121
+ expanded_path = expand(path)
113
122
 
114
123
  if File.directory?(expanded_path)
115
124
  Dir["#{expanded_path}/#{@glob}"].each do |file|
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
- module Source
2
+ class Source
3
3
  class Path
4
4
 
5
5
  class Installer < Bundler::GemInstaller
@@ -3,8 +3,9 @@ require 'rubygems/user_interaction'
3
3
  require 'rubygems/spec_fetcher'
4
4
 
5
5
  module Bundler
6
- module Source
7
- class Rubygems
6
+ class Source
7
+ # TODO: Refactor this class
8
+ class Rubygems < Source
8
9
  API_REQUEST_LIMIT = 100 # threshold for switching back to the modern index instead of fetching every spec
9
10
 
10
11
  attr_reader :remotes, :caches
@@ -67,8 +68,8 @@ module Bundler
67
68
  end
68
69
 
69
70
  def install(spec)
70
- if installed_specs[spec].any?
71
- return ["Using #{spec.name} (#{spec.version})", nil]
71
+ if installed_specs[spec].any? && gem_dir_exists?(spec)
72
+ return ["Using #{version_message(spec)}", nil]
72
73
  end
73
74
 
74
75
  # Download the gem to get the spec, because some specs that are returned
@@ -79,7 +80,6 @@ module Bundler
79
80
  spec.__swap__(s)
80
81
  end
81
82
 
82
- install_message = "Installing #{spec.name} (#{spec.version})"
83
83
  path = cached_gem(spec)
84
84
  if Bundler.requires_sudo?
85
85
  install_path = Bundler.tmp
@@ -113,15 +113,15 @@ module Bundler
113
113
  end
114
114
  installed_spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
115
115
  spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
116
- [install_message, spec.post_install_message]
116
+ ["Installing #{version_message(spec)}", spec.post_install_message]
117
117
  end
118
118
 
119
- def cache(spec)
119
+ def cache(spec, custom_path = nil)
120
120
  cached_path = cached_gem(spec)
121
121
  raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
122
122
  return if File.dirname(cached_path) == Bundler.app_cache.to_s
123
123
  Bundler.ui.info " * #{File.basename(cached_path)}"
124
- FileUtils.cp(cached_path, Bundler.app_cache)
124
+ FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
125
125
  end
126
126
 
127
127
  def add_remote(source)
@@ -276,6 +276,16 @@ module Bundler
276
276
  end
277
277
  end
278
278
 
279
+ def gem_dir_exists?(spec)
280
+ return true if spec.name == "bundler"
281
+ # Ruby 2 default gems
282
+ return true if spec.loaded_from.include?("specifications/default/")
283
+ # Ruby 1.9 default gems
284
+ return true if spec.summary =~ /is bundled with Ruby/
285
+
286
+ File.directory?(spec.full_gem_path)
287
+ end
279
288
  end
289
+
280
290
  end
281
291
  end
@@ -0,0 +1,41 @@
1
+ require 'fileutils'
2
+
3
+ module Bundler
4
+ module SSLCerts
5
+ class CertificateManager
6
+ attr_reader :bundler_cert_path, :bundler_certs, :rubygems_certs
7
+
8
+ def self.update_from!(rubygems_path)
9
+ new(rubygems_path).update!
10
+ end
11
+
12
+ def initialize(rubygems_path)
13
+ rubygems_certs = File.join(rubygems_path, 'lib/rubygems/ssl_certs')
14
+ @rubygems_certs = certificates_in(rubygems_certs)
15
+
16
+ @bundler_cert_path = File.expand_path("..", __FILE__)
17
+ @bundler_certs = certificates_in(bundler_cert_path)
18
+ end
19
+
20
+ def up_to_date?
21
+ bundler_certs.zip(rubygems_certs).all? do |bc, rc|
22
+ File.basename(bc) == File.basename(rc) && FileUtils.compare_file(bc, rc)
23
+ end
24
+ end
25
+
26
+ def update!
27
+ return if up_to_date?
28
+
29
+ FileUtils.rm bundler_certs
30
+ FileUtils.cp rubygems_certs, bundler_cert_path
31
+ end
32
+
33
+ private
34
+
35
+ def certificates_in(path)
36
+ Dir[File.join(path, "*.pem")].sort
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -22,7 +22,7 @@ TODO: Write usage instructions here
22
22
 
23
23
  ## Contributing
24
24
 
25
- 1. Fork it ( http://github.com/<my-github-username>/<%=config[:name]%>/fork )
25
+ 1. Fork it ( http://github.com/[my-github-username]/<%=config[:name]%>/fork )
26
26
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
27
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
28
  4. Push to the branch (`git push origin my-new-feature`)
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  describe <%= config[:constant_name] %> do
4
4
  it 'should have a version number' do
5
- <%= config[:constant_name] %>::VERSION.should_not be_nil
5
+ expect(<%= config[:constant_name] %>::VERSION).not_to be nil
6
6
  end
7
7
 
8
8
  it 'should do something useful' do
9
- false.should eq(true)
9
+ expect(false).to be true
10
10
  end
11
11
  end
@@ -1,144 +1,7 @@
1
- require 'rubygems/user_interaction'
2
-
3
1
  module Bundler
4
- class UI
5
- def warn(message, newline = nil)
6
- end
7
-
8
- def debug(message, newline = nil)
9
- end
10
-
11
- def trace(message, newline = nil)
12
- end
13
-
14
- def error(message, newline = nil)
15
- end
16
-
17
- def info(message, newline = nil)
18
- end
19
-
20
- def confirm(message, newline = nil)
21
- end
22
-
23
- def quiet?
24
- false
25
- end
26
-
27
- def debug?
28
- false
29
- end
30
-
31
- def ask(message)
32
- end
33
-
34
- class Shell < UI
35
- LEVELS = %w(silent error warn confirm info debug)
36
-
37
- attr_writer :shell
38
-
39
- def initialize(options = {})
40
- if options["no-color"] || !STDOUT.tty?
41
- Thor::Base.shell = Thor::Shell::Basic
42
- end
43
- @shell = Thor::Base.shell.new
44
- @level = ENV['DEBUG'] ? "debug" : "info"
45
- end
46
-
47
- def info(msg, newline = nil)
48
- tell_me(msg, nil, newline) if level("info")
49
- end
50
-
51
- def confirm(msg, newline = nil)
52
- tell_me(msg, :green, newline) if level("confirm")
53
- end
54
-
55
- def warn(msg, newline = nil)
56
- tell_me(msg, :yellow, newline) if level("warn")
57
- end
58
-
59
- def error(msg, newline = nil)
60
- tell_me(msg, :red, newline) if level("error")
61
- end
62
-
63
- def debug(msg, newline = nil)
64
- tell_me(msg, nil, newline) if level("debug")
65
- end
66
-
67
- def debug?
68
- # needs to be false instead of nil to be newline param to other methods
69
- level("debug")
70
- end
71
-
72
- def quiet?
73
- LEVELS.index(@level) <= LEVELS.index("warn")
74
- end
75
-
76
- def ask(msg)
77
- @shell.ask(msg)
78
- end
79
-
80
- def level=(level)
81
- raise ArgumentError unless LEVELS.include?(level.to_s)
82
- @level = level
83
- end
84
-
85
- def level(name = nil)
86
- name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
87
- end
88
-
89
- def trace(e, newline = nil)
90
- msg = ["#{e.class}: #{e.message}", *e.backtrace].join("\n")
91
- if debug?
92
- tell_me(msg, nil, newline)
93
- elsif @trace
94
- STDERR.puts "#{msg}#{newline}"
95
- end
96
- end
97
-
98
- def silence
99
- old_level, @level = @level, "silent"
100
- yield
101
- ensure
102
- @level = old_level
103
- end
104
-
105
- private
106
-
107
- # valimism
108
- def tell_me(msg, color = nil, newline = nil)
109
- msg = word_wrap(msg) if newline.is_a?(Hash) && newline[:wrap]
110
- if newline.nil?
111
- @shell.say(msg, color)
112
- else
113
- @shell.say(msg, color, newline)
114
- end
115
- end
116
-
117
- def strip_leading_spaces(text)
118
- spaces = text[/\A\s+/, 0]
119
- spaces ? text.gsub(/#{spaces}/, '') : text
120
- end
121
-
122
- def word_wrap(text, line_width = @shell.terminal_width)
123
- strip_leading_spaces(text).split("\n").collect do |line|
124
- line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
125
- end * "\n"
126
- end
127
- end
128
-
129
- class RGProxy < ::Gem::SilentUI
130
- def initialize(ui)
131
- @ui = ui
132
- super()
133
- end
134
-
135
- def say(message)
136
- if message =~ /native extensions/
137
- @ui.info "with native extensions "
138
- else
139
- @ui.debug(message)
140
- end
141
- end
142
- end
2
+ module UI
3
+ autoload :RGProxy, 'bundler/ui/rg_proxy'
4
+ autoload :Shell, 'bundler/ui/shell'
5
+ autoload :Silent, 'bundler/ui/silent'
143
6
  end
144
7
  end