lib/contrast/utils/os.rb in contrast-agent-4.14.1 vs lib/contrast/utils/os.rb in contrast-agent-5.0.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. +# Copyright (c) 2022 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' @@ -34,26 +34,30 @@ end # Check current OS type # returns true if check is correct or false if not def windows? - (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil + return @_windows unless @_windows.nil? + + @_windows = !(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil? end def mac? - RUBY_PLATFORM.include? 'darwin' + @_mac = RUBY_PLATFORM.include? 'darwin' if @_mac.nil? + @_mac end def unix? !windows? end def linux? - unix? and !mac? + (unix? and !mac?) end def jruby? - RUBY_ENGINE == 'jruby' + @_jruby = RUBY_ENGINE == 'jruby' if @_jruby.nil? + @_jruby end end end end end