Module: Textbringer::TreeSitter::Platform

Defined in:
lib/textbringer/tree_sitter/platform.rb

Class Method Summary collapse

Class Method Details

.dylib_ext ⇒ String

Get dynamic library extension for current platform

Returns:

  • (String) —

    ".dylib" for macOS, ".so" for others



29
30
31
32
33
34
# File 'lib/textbringer/tree_sitter/platform.rb', line 29

def dylib_ext
  case RbConfig::CONFIG["host_os"]
  when /darwin/i then ".dylib"
  else ".so"
  end
end

.faveod_platform ⇒ String

Convert platform string to Faveod naming convention

Returns:

  • (String) —

    Faveod platform name (e.g., "macos-arm64", "linux-x64")



38
39
40
41
42
43
44
45
46
# File 'lib/textbringer/tree_sitter/platform.rb', line 38

def faveod_platform
  case platform
  when "darwin-arm64" then "macos-arm64"
  when "darwin-x64" then "macos-x64"
  when "linux-x64" then "linux-x64"
  when "linux-arm64" then "linux-arm64"
  else platform
  end
end

.platform ⇒ String

Detect OS and architecture

Returns:

  • (String) —

    platform string in format "os-arch" (e.g., "darwin-arm64", "linux-x64")



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/textbringer/tree_sitter/platform.rb', line 11

def platform
  os = case RbConfig::CONFIG["host_os"]
       when /darwin/i then "darwin"
       when /linux/i then "linux"
       else "unknown"
       end

  arch = case RbConfig::CONFIG["host_cpu"]
         when /arm64|aarch64/i then "arm64"
         when /x86_64|amd64/i then "x64"
         else "unknown"
         end

  "#{os}-#{arch}"
end