Module: Bsdkrun::Binary

Defined in:
lib/bsdkrun/binary.rb

Overview

Locates the bsdkrun binary on the host and caches the result.

Resolution order (first match wins):

1. an explicit override set via {Bsdkrun.binary_path=}
2. the +BSDKRUN_BIN+ environment variable
3. +bsdkrun+ on +PATH+
4. an in-repo dev build: +<repo>/target/release/bsdkrun+ then +debug+

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.overrideString?

Returns the current explicit override, if any.

Returns:

  • (String, nil)

    the current explicit override, if any.



28
29
30
# File 'lib/bsdkrun/binary.rb', line 28

def override
  @override
end

Class Method Details

.reset!void

This method returns an undefined value.

Reset cached discovery state (mainly for tests).



32
33
34
35
# File 'lib/bsdkrun/binary.rb', line 32

def reset!
  @resolved = nil
  @override = nil
end

.resolveString

Resolve (and cache) the path to the bsdkrun binary.

Returns:

  • (String)

    the resolved absolute path or bare command name.

Raises:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/bsdkrun/binary.rb', line 41

def resolve
  return @resolved if @resolved

  searched = candidates
  searched.each do |candidate|
    if path_like?(candidate)
      return @resolved = candidate if File.exist?(candidate)
    else
      found = which(candidate)
      return @resolved = found if found
    end
  end
  raise BinaryNotFound, searched
end