Sha256: e0e59b21d15665885c9ea2eb7dc3c69f5c312359a4d9a11b50fecd307c41a0ad

Contents?: true

Size: 961 Bytes

Versions: 7

Compression:

Stored size: 961 Bytes

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 memoizes 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
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/utils/os.rb
contrast-agent-7.6.0 lib/contrast/utils/os.rb
contrast-agent-7.5.0 lib/contrast/utils/os.rb
contrast-agent-7.4.1 lib/contrast/utils/os.rb
contrast-agent-7.4.0 lib/contrast/utils/os.rb
contrast-agent-7.3.2 lib/contrast/utils/os.rb
contrast-agent-7.3.1 lib/contrast/utils/os.rb