module Travis::Tools::SafeString

Public Instance Methods

clean(string) click to toggle source
# File lib/travis/tools/safe_string.rb, line 17
def clean(string)
  colorized(string).gsub(/\e[^m]+m/, '')
end
colorized(string) click to toggle source
# File lib/travis/tools/safe_string.rb, line 13
def colorized(string)
  encoded(string).gsub(/[^[:print:]\e\n]/, '')
end
encoded(string) click to toggle source
# File lib/travis/tools/safe_string.rb, line 6
def encoded(string)
  return string unless string.respond_to? :encode
  string.encode 'utf-8'
rescue Encoding::UndefinedConversionError
  string.force_encoding 'utf-8'
end