Module: Aikido::Zen::Internals
- Extended by:
- FFI::Library
- Defined in:
- lib/aikido/zen/internals.rb
Class Method Summary collapse
-
.libzen_name ⇒ String
use in error messages.
- .libzen_names ⇒ Object
-
.load_libzen ⇒ Object
Load the most specific library.
Class Method Details
.libzen_name ⇒ String
use in error messages.
39 40 41 42 |
# File 'lib/aikido/zen/internals.rb', line 39 def self.libzen_name # The most generic platform library name. libzen_names.last end |
.libzen_names ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/aikido/zen/internals.rb', line 10 def self.libzen_names lib_name = "libzen-v#{LIBZEN_VERSION}" lib_ext = FFI::Platform::LIBSUFFIX # Gem::Platform#version should be understood as an arbitrary Ruby defined # OS specific string. A platform with a version string is considered more # specific than a platform without a version string. # https://docs.ruby-lang.org/en/3.3/Gem/Platform.html platform = Gem::Platform.local.dup # Library names in preferred order. # # If two library names are added, the specific platform library names is # first and the generic platform library name is second. names = [] names << "#{lib_name}-#{platform}.#{lib_ext}" unless platform.version.nil? platform.version = nil names << "#{lib_name}-#{platform}.#{lib_ext}" end names end |
.load_libzen ⇒ Object
Load the most specific library
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/aikido/zen/internals.rb', line 45 def self.load_libzen libzen_names.each do |name| path = File.(name, __dir__) begin return ffi_lib(path) rescue LoadError # empty end end raise LoadError, "Zen could not load its native extension #{libzen_name}" end |