Module: DetectOS

Defined in:
lib/pact/detect_os.rb

Class Method Summary collapse

Class Method Details

.debug?Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/pact/detect_os.rb', line 36

def self.debug?
  return if ENV['DEBUG_TARGET'].nil?
  true
end

.get_bin_pathObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pact/detect_os.rb', line 41

def self.get_bin_path
  if debug?
    ENV['DEBUG_TARGET'].to_s
  elsif windows?
    File.join(__dir__, '../../ffi/windows-x64/pact_ffi.dll')
  elsif mac_arm?
    File.join(__dir__, '../../ffi/macos-arm64/libpact_ffi.dylib')
  elsif mac?
    File.join(__dir__, '../../ffi/macos-x64/libpact_ffi.dylib')
  elsif linux_arm_musl?
    File.join(__dir__, '../../ffi/linux-arm64-musl/libpact_ffi.so')
  elsif linux_musl?
    File.join(__dir__, '../../ffi/linux-x64-musl/libpact_ffi.so')
  elsif linux_arm?
    File.join(__dir__, '../../ffi/linux-arm64/libpact_ffi.so')
  elsif linux?
    File.join(__dir__, '../../ffi/linux-x64/libpact_ffi.so')
  else
    raise "Detected #{RbConfig::CONFIG['arch']}-- I have no idea what to do with that."
  end
end

.get_osObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/pact/detect_os.rb', line 63

def self.get_os
  if windows?
    'win'
  elsif mac_arm?
    'macos-arm64'
  elsif mac?
    'linux-x8664'
  elsif linux_arm?
    'linux-aarch64'
  elsif linux?
    'linux-x8664'
  else
    raise "Detected #{RbConfig::CONFIG['arch']}-- I have no idea what to do with that."
  end
end

.linux?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/pact/detect_os.rb', line 31

def self.linux?
  return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?
  true
end

.linux_arm?Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/pact/detect_os.rb', line 26

def self.linux_arm?
  return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil?
  true
end

.linux_arm_musl?Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/pact/detect_os.rb', line 17

def self.linux_arm_musl?
  return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/aarch64/ =~ RbConfig::CONFIG['arch']).nil? && !(/musl/ =~ RbConfig::CONFIG['arch']).nil?
  true
end

.linux_musl?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/pact/detect_os.rb', line 22

def self.linux_musl?
  return unless !(/linux/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?&& !(/musl/ =~ RbConfig::CONFIG['arch']).nil?
  true
end

.mac?Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/pact/detect_os.rb', line 12

def self.mac?
  return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/x86_64/ =~ RbConfig::CONFIG['arch']).nil?
  true
end

.mac_arm?Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/pact/detect_os.rb', line 7

def self.mac_arm?
  return unless !(/darwin/ =~ RbConfig::CONFIG['arch']).nil? && !(/arm64/ =~ RbConfig::CONFIG['arch']).nil?
  true
end

.windows?Boolean

Returns:

  • (Boolean)


2
3
4
5
# File 'lib/pact/detect_os.rb', line 2

def self.windows?
  return if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['arch']).nil?
  true
end