aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2013-03-14 23:06:53 -0700
committerAndre Arko <andre@arko.net>2013-03-14 23:06:53 -0700
commit405f57a75ed230e913f5b451f906c4e6a984db49 (patch)
treeeb24fadc331272936eeed797241e701598baa050 /lib
parent2569e99ca0d13f0af5ccf683ae3009a074d77c70 (diff)
downloadbundler-405f57a75ed230e913f5b451f906c4e6a984db49.tar.gz
fix UI :wrap option to strip leading spaces
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb8
-rw-r--r--lib/bundler/friendly_errors.rb11
-rw-r--r--lib/bundler/ui.rb7
3 files changed, 17 insertions, 9 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 98d94361..bdf42aff 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -270,9 +270,11 @@ module Bundler
end
if Bundler.definition.rubygems_remotes.empty?
- Bundler.ui.warn "Your Gemfile has no remote sources. If you need " \
- "gems that are not already on\nyour machine, add a line like this " \
- "to your Gemfile:\n source 'https://rubygems.org'"
+ Bundler.ui.warn <<-WARN, :wrap => true
+ Your Gemfile has no Rubygems sources. If you need gems that are not \
+ already on your machine, add a line like this to your Gemfile:
+ source 'https://rubygems.org'
+ WARN
end
raise e
end
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 91ffa344..1a8b9aa3 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -8,9 +8,11 @@ module Bundler
rescue LoadError => e
raise e unless e.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
Bundler.ui.error "\nCould not load OpenSSL."
- Bundler.ui.warn "You must recompile Ruby with OpenSSL support or change the sources in your" \
- "\nGemfile from 'https' to 'http'. Instructions for compiling with OpenSSL" \
- "\nusing RVM are available at rvm.io/packages/openssl."
+ Bundler.ui.warn <<-WARN, :wrap => true
+ You must recompile Ruby with OpenSSL support or change the sources in your \
+ Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \
+ using RVM are available at rvm.io/packages/openssl.
+ WARN
Bundler.ui.trace e
exit 1
rescue Interrupt => e
@@ -21,9 +23,8 @@ module Bundler
exit e.status
rescue Exception => e
Bundler.ui.error <<-ERR, :wrap => true
- Unfortunately, a fatal error has occurred. Please see the Bundler
+ Unfortunately, a fatal error has occurred. Please see the Bundler \
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
-
ERR
raise e
end
diff --git a/lib/bundler/ui.rb b/lib/bundler/ui.rb
index 5de8f753..01b6c6ea 100644
--- a/lib/bundler/ui.rb
+++ b/lib/bundler/ui.rb
@@ -110,8 +110,13 @@ module Bundler
end
end
+ def strip_leading_spaces(text)
+ spaces = text[/\A\s+/, 0]
+ spaces ? text.gsub(/#{spaces}/, '') : text
+ end
+
def word_wrap(text, line_width = @shell.terminal_width)
- text.split("\n").collect do |line|
+ strip_leading_spaces(text).split("\n").collect do |line|
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
end * "\n"
end