Module: Aidp::Interfaces::BinaryCheckerInterface

Included in:
AidpBinaryChecker, CachingBinaryChecker, NullBinaryChecker, PathBinaryChecker, StubBinaryChecker
Defined in:
lib/aidp/interfaces/binary_checker_interface.rb

Overview

BinaryCheckerInterface defines the contract for checking CLI binary availability. This interface allows for dependency injection of different binary checking implementations, facilitating extraction of provider code into standalone gems.

Examples:

Implementing the interface

class MyBinaryChecker
  include Aidp::Interfaces::BinaryCheckerInterface

  def available?(binary_name)
    system("which", binary_name, out: File::NULL, err: File::NULL)
  end

  def path_for(binary_name)
    `which #{binary_name}`.chomp
  end
end

Using an injected checker

class Provider
  def initialize(binary_checker: PathBinaryChecker.new)
    @binary_checker = binary_checker
  end

  def available?
    @binary_checker.available?("claude")
  end
end

Instance Method Summary collapse

Instance Method Details

#available?(binary_name) ⇒ Boolean

Check if a binary is available in the system PATH.

Parameters:

  • binary_name (String)

    the name of the binary to check (e.g., "claude", "cursor-agent")

Returns:

  • (Boolean)

    true if the binary is executable and in PATH

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/aidp/interfaces/binary_checker_interface.rb', line 38

def available?(binary_name)
  raise NotImplementedError, "#{self.class} must implement #available?"
end

#path_for(binary_name) ⇒ String?

Get the full path to a binary.

Parameters:

  • binary_name (String)

    the name of the binary to find

Returns:

  • (String, nil)

    the full path to the binary, or nil if not found

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/aidp/interfaces/binary_checker_interface.rb', line 46

def path_for(binary_name)
  raise NotImplementedError, "#{self.class} must implement #path_for"
end