class Mutest::Reporter::CLI::Tput

Interface to the optionally present tput binary

Public Class Methods

detect() click to toggle source

Detected tput support

@return [Tput]

if tput support is present

@return [nil]

otherwise
# File lib/mutest/reporter/cli/tput.rb, line 18
def self.detect
  reset   = capture('tput reset')
  save    = capture('tput sc') if reset
  restore = capture('tput rc') if save
  clean   = capture('tput ed') || capture('tput cd') if restore
  new(reset + save, restore + clean) if clean
end

Private Class Methods

capture(command) click to toggle source

Capture output

@param [String] command

command to run

@return [String]

stdout of command on success

@return [nil]

otherwise
# File lib/mutest/reporter/cli/tput.rb, line 36
def self.capture(command)
  stdout, _stderr, exitstatus = Open3.capture3(command)
  stdout if exitstatus.success?
end