Module: Leakferret::Platform Private

Defined in:
lib/leakferret/platform.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Host detection for picking the right release asset. Maps the running Ruby's RbConfig host to a Rust target triple and binary name.

Class Method Summary collapse

Class Method Details

.binary_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executable name for the current OS.

Returns:

  • (String)

    "leakferret.exe" on Windows, otherwise "leakferret"



43
44
45
# File 'lib/leakferret/platform.rb', line 43

def binary_name
  windows? ? 'leakferret.exe' : 'leakferret'
end

.tripleString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The Rust target triple for the current host (e.g. x86_64-unknown-linux-gnu).

Returns:

  • (String)

    the target triple

Raises:

  • (Error)

    on an unsupported CPU or OS, or aarch64-linux (no asset yet)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/leakferret/platform.rb', line 20

def triple
  cpu = case RbConfig::CONFIG['host_cpu']
        when /x86_64|amd64|x64/ then 'x86_64'
        when /aarch64|arm64/ then 'aarch64'
        else
          raise Error, "unsupported CPU: #{RbConfig::CONFIG['host_cpu']}"
        end

  case RbConfig::CONFIG['host_os']
  when /mswin|mingw|cygwin/ then "#{cpu}-pc-windows-msvc"
  when /darwin/             then "#{cpu}-apple-darwin"
  when /linux/
    # No aarch64-linux release asset yet (v0.1.0 ships x86_64 only).
    raise Error, 'aarch64-linux has no prebuilt binary yet; build from source' if cpu == 'aarch64'

    "#{cpu}-unknown-linux-gnu"
  else
    raise Error, "unsupported OS: #{RbConfig::CONFIG['host_os']}"
  end
end

.windows?Integer?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns truthy when the host OS is Windows.

Returns:

  • (Integer, nil)

    truthy when the host OS is Windows



48
49
50
# File 'lib/leakferret/platform.rb', line 48

def windows?
  RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
end