Method: Aruba::Platforms::UnixPlatform#unescape

Defined in:
lib/aruba/platforms/unix_platform.rb

#unescape(string, keep_ansi = true) ⇒ Object

Unescape string

Parameters:

  • string (String)

    The string which should be unescaped, e.g. the output of a command

Returns:

  • The string stripped from escape sequences



246
247
248
249
250
251
252
253
254
# File 'lib/aruba/platforms/unix_platform.rb', line 246

def unescape(string, keep_ansi = true)
  # rubocop:disable Metrics/LineLength
  deprecated('The use of "Aruba.platform.unescape" is deprecated. Please use "#unescape_text" and "#sanitize_text" instead. But be aware it uses a different implementation')
  # rubocop:enable Metrics/LineLength

  string = string.gsub('\n', "\n").gsub('\"', '"').gsub('\e', "\e")
  string = string.gsub(/\e\[\d+(?>(;\d+)*)m/, '') unless keep_ansi
  string
end