Module: Travis::Tools::SafeString

Extended by:
SafeString
Included in:
CLI::Logs, SafeString
Defined in:
lib/travis/tools/safe_string.rb

Instance Method Summary collapse

Instance Method Details

#clean(string) ⇒ Object



15
16
17
# File 'lib/travis/tools/safe_string.rb', line 15

def clean(string)
  colorized(string).gsub(/\e[^m]+m/, '')
end

#colorized(string) ⇒ Object



11
12
13
# File 'lib/travis/tools/safe_string.rb', line 11

def colorized(string)
  encoded(string).gsub(/[^[:print:]\e\n]/, '')
end

#encoded(string) ⇒ Object



6
7
8
9
# File 'lib/travis/tools/safe_string.rb', line 6

def encoded(string)
  return string unless string.respond_to? :encode
  string.encode 'utf-8'
end