Sha256: f7d11d0aa5517232921a92fdbb6de434f0cf6ced838aaefaca38d3c32d19cd6f

Contents?: true

Size: 808 Bytes

Versions: 17

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal: true

module Cri
  # Provides tools to detect platform and environment configuration (e.g. is
  # color support available?)
  #
  # @api private
  module Platform
    # @return [Boolean] true if the current platform is Windows, false
    # otherwise.
    def self.windows?
      RUBY_PLATFORM =~ /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
    end

    # Checks whether colors can be enabled. For colors to be enabled, the given
    # IO should be a TTY, and, when on Windows, ::Win32::Console::ANSI needs to
    # be defined.
    #
    # @return [Boolean] True if colors should be enabled, false otherwise.
    def self.color?(io)
      if !io.tty?
        false
      elsif windows?
        defined?(::Win32::Console::ANSI)
      else
        true
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cri-2.15.12 lib/cri/platform.rb
cri-2.15.11 lib/cri/platform.rb
cri-2.15.10 lib/cri/platform.rb
cri-2.15.9 lib/cri/platform.rb
cri-2.15.8 lib/cri/platform.rb
cri-2.15.7 lib/cri/platform.rb
cri-2.15.6 lib/cri/platform.rb
cri-2.15.5 lib/cri/platform.rb
cri-2.15.4 lib/cri/platform.rb
cri-2.15.3 lib/cri/platform.rb
cri-2.15.2 lib/cri/platform.rb
cri-2.15.1 lib/cri/platform.rb
cri-2.15.0 lib/cri/platform.rb
cri-2.14.0 lib/cri/platform.rb
cri-2.13.0 lib/cri/platform.rb
cri-2.12.0 lib/cri/platform.rb
cri-2.11.0 lib/cri/platform.rb