Commit 159ca279 authored by Fabio Pelosin's avatar Fabio Pelosin

[UI] Allow to disable wrapping

parent e3390c0e
......@@ -23,6 +23,12 @@ module Pod
attr_accessor :title_level
attr_accessor :warnings
# @return [Bool] Whether the wrapping of the strings to the width of the
# terminal should be disabled.
#
attr_accessor :disable_wrap
alias_method :disable_wrap?, :disable_wrap
# Prints a title taking an optional verbose prefix and
# a relative indentation valid for the UI action in the passed
# block.
......@@ -254,12 +260,16 @@ module Pod
# terminal is too small a width of 80 is assumed.
#
def wrap_string(txt, indent = '')
if disable_wrap
txt
else
width = `stty size`.split(' ')[1].to_i - indent.length
width = 80 unless width >= 10
txt.strip.gsub(/(.{1,#{width}})( +|$)\n?|(.{#{width}})/, indent + "\\1\\3\n")
end
end
end
end
UI = UserInterface
# Redirects cocoapods-core UI.
......
module Pod
# @note as some outputs wraps strings
# Disable the wrapping so the output is deterministic in the tests.
#
UI.disable_wrap = true
# Redirects the messages to an internal store.
#
module UI
@output = ''
......@@ -10,17 +14,12 @@ module Pod
attr_accessor :output
attr_accessor :warnings
# @todo Allow to specify whether the text should be wrapped with an
# environment variable and remove the new feed replacement.
def puts(message = '')
# Wrapping can bite in tests.
@output << "#{message}".gsub(/\n/,'')
@output << "#{message}"
end
def warn(message = '', actions = [])
# Wrapping can bite in tests.
@warnings << "#{message}".gsub(/\n/,'')
@warnings << "#{message}"
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment