Module: FzfRuby::Platform
- Defined in:
- lib/fzf/platform.rb
Constant Summary collapse
- ARCH_MAP =
RbConfig host_cpu → fzf/Go architecture name. Keys are matched as prefixes, since host_cpu carries suffixes such as "armv7l" that the release names ("armv7") do not.
{ "x86_64" => "amd64", "amd64" => "amd64", "aarch64" => "arm64", "arm64" => "arm64", "armv7" => "armv7", "armv6" => "armv6", "armv5" => "armv5", "loong64" => "loong64", "ppc64le" => "ppc64le", "riscv64" => "riscv64", "s390x" => "s390x", }.freeze
- OS_MAP =
RbConfig host_os → fzf/Go operating system name. Keys are matched as prefixes ("linux-gnu", "darwin23" and so on).
{ "linux" => "linux", "darwin" => "darwin", "freebsd" => "freebsd", "openbsd" => "openbsd", }.freeze
Class Method Summary collapse
-
.arch ⇒ Object
Architecture in fzf's naming, or nil when unrecognised.
-
.os ⇒ Object
Operating system in fzf's naming, or nil when unrecognised.
-
.slug ⇒ Object
Platform slug as it appears in a release asset name, e.g.
Class Method Details
.arch ⇒ Object
Architecture in fzf's naming, or nil when unrecognised.
50 51 52 53 54 |
# File 'lib/fzf/platform.rb', line 50 def self.arch cpu = RbConfig::CONFIG["host_cpu"] ARCH_MAP.each { |prefix, name| return name if cpu.start_with?(prefix) } nil end |
.os ⇒ Object
Operating system in fzf's naming, or nil when unrecognised.
43 44 45 46 47 |
# File 'lib/fzf/platform.rb', line 43 def self.os host = RbConfig::CONFIG["host_os"] OS_MAP.each { |prefix, name| return name if host.start_with?(prefix) } nil end |
.slug ⇒ Object
Platform slug as it appears in a release asset name, e.g. "linux_amd64". nil when either half is unrecognised, meaning no prebuilt asset exists.
58 59 60 61 62 63 |
# File 'lib/fzf/platform.rb', line 58 def self.slug detected_os, detected_arch = os, arch return nil unless detected_os && detected_arch "#{detected_os}_#{detected_arch}" end |