Module: Travis::Tools::SafeString
- Included in:
- CLI::Logs
- Defined in:
- lib/travis/tools/safe_string.rb
Class Method Summary collapse
Class Method Details
.clean(string) ⇒ Object
20 21 22 |
# File 'lib/travis/tools/safe_string.rb', line 20 def clean(string) colorized(string).gsub(/\e[^m]+m/, '') end |
.colorized(string) ⇒ Object
16 17 18 |
# File 'lib/travis/tools/safe_string.rb', line 16 def colorized(string) encoded(string).gsub(/[^[:print:]\e\n]/, '') end |
.encoded(string) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/travis/tools/safe_string.rb', line 8 def encoded(string) return string unless string.respond_to? :encode string.encode 'utf-8' rescue Encoding::UndefinedConversionError string.force_encoding 'utf-8' end |