Module: Yerba
- Defined in:
- lib/yerba.rb,
lib/yerba/version.rb
Defined Under Namespace
Classes: CompilationError, ExecutableNotFoundError, UnsupportedPlatformError
Constant Summary collapse
- GEM_NAME =
"yerba"- EXECUTABLE_NAME =
"yerba"- NATIVE_PLATFORMS =
{ "arm64-darwin" => "arm64-darwin", "x86_64-darwin" => "x86_64-darwin", "aarch64-linux" => "aarch64-linux", "arm64-linux" => "aarch64-linux", "x86_64-linux" => "x86_64-linux", }.freeze
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.executable(exe_path: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/yerba.rb', line 21 def self.executable(exe_path: nil) if exe_path return exe_path if File.executable?(exe_path) raise ExecutableNotFoundError, "yerba executable not found at #{exe_path}" end if ENV["YERBA_INSTALL_DIR"] install_dir_exe = File.join(ENV["YERBA_INSTALL_DIR"], EXECUTABLE_NAME) if File.executable?(install_dir_exe) return install_dir_exe end raise ExecutableNotFoundError, "yerba executable not found at #{install_dir_exe} (set by YERBA_INSTALL_DIR)" end # Try platform-specific precompiled binary platform = Gem::Platform.local platform_key = "#{platform.cpu}-#{platform.os}" exe_directory = NATIVE_PLATFORMS[platform_key] if exe_directory exe_file = File.( File.join("..", "exe", exe_directory, EXECUTABLE_NAME), __dir__ ) return exe_file if File.executable?(exe_file) end # Try compiling from source if Rust source is bundled compiled = compile_from_source return compiled if compiled if exe_directory raise ExecutableNotFoundError, "yerba executable not found at exe/#{exe_directory}/yerba. " \ "Try reinstalling the gem: gem install yerba" else raise UnsupportedPlatformError, "yerba does not have a precompiled binary for #{platform_key}. " \ "Install Rust (https://rustup.rs) and reinstall the gem to compile from source, " \ "or set YERBA_INSTALL_DIR to use a custom binary." end end |