Sha256: 9f66b1f345a2a37270e828bccaae5562a3f56f057adacc10a27a6e5d496427b7

Contents?: true

Size: 1.05 KB

Versions: 11

Compression:

Stored size: 1.05 KB

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/components/scope'
require 'cs__os_information/cs__os_information'

module Contrast
  module Utils
    # Simple utility used to make OS calls and determine state. For that state
    # which will not change at runtime, such as the operating system, the
    # Utility memozies to avoid multiple lookups.
    module OS
      extend Contrast::Components::Scope::InstanceMethods

      class << self
        # Check current OS type
        # returns true if check is correct or false if not
        def windows?
          return @_windows unless @_windows.nil?

          @_windows = !(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
        end

        def mac?
          @_mac = RUBY_PLATFORM.include?('darwin') if @_mac.nil?
          @_mac
        end

        def unix?
          !windows?
        end

        def linux?
          (unix? and !mac?)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
contrast-agent-7.3.0 lib/contrast/utils/os.rb
contrast-agent-7.2.0 lib/contrast/utils/os.rb
contrast-agent-7.1.0 lib/contrast/utils/os.rb
contrast-agent-7.0.0 lib/contrast/utils/os.rb
contrast-agent-6.15.3 lib/contrast/utils/os.rb
contrast-agent-6.15.2 lib/contrast/utils/os.rb
contrast-agent-6.15.1 lib/contrast/utils/os.rb
contrast-agent-6.15.0 lib/contrast/utils/os.rb
contrast-agent-6.14.0 lib/contrast/utils/os.rb
contrast-agent-6.13.0 lib/contrast/utils/os.rb
contrast-agent-6.12.0 lib/contrast/utils/os.rb