Sha256: f29582b5d9829a63089dfc6a3a89192b46d7869c994d1bb628cb853d0ee5a8bd

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

module Mutest
  class Reporter
    class CLI
      # Interface to the optionally present tput binary
      class Tput
        include Adamantium, Concord::Public.new(:prepare, :restore)

        private_class_method :new

        # Detected tput support
        #
        # @return [Tput]
        #   if tput support is present
        #
        # @return [nil]
        #   otherwise
        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

        # Capture output
        #
        # @param [String] command
        #   command to run
        #
        # @return [String]
        #   stdout of command on success
        #
        # @return [nil]
        #   otherwise
        def self.capture(command)
          stdout, _stderr, exitstatus = Open3.capture3(command)
          stdout if exitstatus.success?
        end
        private_class_method :capture
      end # Tput
    end # CLI
  end # Reporter
end # Mutest

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutest-0.0.9 lib/mutest/reporter/cli/tput.rb
mutest-0.0.8 lib/mutest/reporter/cli/tput.rb
mutest-0.0.7 lib/mutest/reporter/cli/tput.rb
mutest-0.0.6 lib/mutest/reporter/cli/tput.rb
mutest-0.0.5 lib/mutest/reporter/cli/tput.rb
mutest-0.0.4 lib/mutest/reporter/cli/tput.rb
mutest-0.0.3 lib/mutest/reporter/cli/tput.rb
mutest-0.0.2 lib/mutest/reporter/cli/tput.rb