Sha256: 5b6d3596ff2c815ea2901e099d087bd4b19d9a142b68de161d635afeca8df265

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

# The Sys module is a namespace only.
module Sys
  # The Platform class provides singleton methods to tell you what OS you're on.
  class Platform
    # The CPU architecture
    ARCH = File::ALT_SEPARATOR ? Uname.architecture.to_sym : Uname.machine.to_sym

    # Returns a basic OS family, either :windows or :unix
    OS = File::ALT_SEPARATOR ? :windows : :unix

    # Returns the OS type, :macosx, :linux, :mingw32, etc
    IMPL = case Uname.sysname
             when /darwin|mac/i
               :macosx
             when /mingw|windows/i
               require 'rbconfig'
               RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase.to_sym
             when /linux/i
               :linux
             when /sunos|solaris/i
               :solaris
             when /bsd/i
               :bsd
           end

    # Returns whether or not you're on a Windows OS
    def self.windows?
      Uname.sysname =~ /microsoft/i ? true : false
    end

    # Returns whether or not you're on a Unixy (non-Windows) OS
    def self.unix?
      Uname.sysname =~ /microsoft/i ? false : true
    end

    # Returns whether or not you're on a mac, i.e. OSX
    def self.mac?
      Uname.sysname =~ /darwin|mac/i ? true : false
    end

    # Returns whether or not you're on Linux
    def self.linux?
      Uname.sysname =~ /linux/i ? true : false
    end

    # Returns whether or not you're on Solaris
    def self.solaris?
      Uname.sysname =~ /sunos|solaris/i ? true : false
    end

    # Returns whether or not you're on any BSD platform
    def self.bsd?
      Uname.sysname =~ /bsd/i ? true : false
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/sys-uname-1.2.3/lib/sys/platform.rb
sys-uname-1.2.3 lib/sys/platform.rb