Module: Leakferret::Binary Private
- Defined in:
- lib/leakferret/binary.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.
Resolves the native leakferret binary that ships inside the gem.
Precompiled platform gems bundle the binary at lib/leakferret/bin/. There is
deliberately no download path: the gem either carries the binary for your
platform or it tells you how to provide one. Nothing here touches the
network, so what you gem unpack is exactly what runs - the whole gem is
auditable, with no fetch-and-execute code to vet.
Constant Summary collapse
- BUNDLED_DIR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Where a precompiled platform gem stages the native binary.
Pathname.new(__dir__).join('bin').freeze
Class Method Summary collapse
-
.no_binary_message ⇒ String
private
Message shown when the source/fallback gem is installed on a platform with no precompiled binary.
-
.path ⇒ String
private
Absolute path to the native binary.
Class Method Details
.no_binary_message ⇒ String
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.
Message shown when the source/fallback gem is installed on a platform with no precompiled binary. No automatic download is attempted - the user provides the binary, or builds it.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/leakferret/binary.rb', line 65 def plat = begin Gem::Platform.local.to_s rescue StandardError RUBY_PLATFORM end <<~MSG No prebuilt leakferret binary ships for this platform (#{plat}). leakferret publishes precompiled gems for x86_64 and arm64 macOS, x86_64 Linux (glibc), and x86_64 Windows. On any other platform, provide the binary yourself - either of these works: 1. Build from source and point LEAKFERRET_BIN at it: cargo install leakferret-cli export LEAKFERRET_BIN="$(command -v leakferret)" 2. Download a release binary for your platform from https://github.com/leakferrethq/leakferret/releases and set LEAKFERRET_BIN to its absolute path. MSG end |
.path ⇒ String
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.
Absolute path to the native binary. Resolution order:
- LEAKFERRET_BIN - explicit override
- lib/leakferret/bin/
- bundled by the precompiled platform gem
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 |
# File 'lib/leakferret/binary.rb', line 32 def path override = ENV['LEAKFERRET_BIN'] unless override.nil? || override.empty? unless File.file?(override) raise BinaryNotFoundError, "LEAKFERRET_BIN points to a missing file: #{override}" end return override end bundled = BUNDLED_DIR.join(Platform.binary_name) if bundled.file? # Make sure it is executable in case the mode did not survive packaging # or install; the gem dir is usually writable, a read-only one is # harmless to skip. unless Platform.windows? || bundled.executable? begin bundled.chmod(0o755) rescue StandardError # best effort end end return bundled.to_s end raise BinaryNotFoundError, end |