Class: Ukiryu::Models::ExecutableInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/models/executable_info.rb

Overview

Information about how an executable was discovered

Provides transparency about tool discovery - whether the executable was found in PATH or is a shell alias, which shell was used, and the alias definition if applicable.

Examples:

PATH discovery

info = ExecutableInfo.new(
  path: "/usr/bin/ffmpeg",
  source: :path,
  shell: :bash
)

Alias discovery

info = ExecutableInfo.new(
  path: "/usr/bin/ffmpeg",
  source: :alias,
  shell: :bash,
  alias_definition: "alias ffmpeg='/opt/homebrew/bin/ffmpeg'"
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, source:, shell:, alias_definition: nil) ⇒ ExecutableInfo

Returns a new instance of ExecutableInfo.



46
47
48
49
50
51
# File 'lib/ukiryu/models/executable_info.rb', line 46

def initialize(path:, source:, shell:, alias_definition: nil)
  @path = path
  @source = source
  @shell = shell
  @alias_definition = alias_definition
end

Instance Attribute Details

#alias_definitionString? (readonly)

The alias definition if source is :alias

Returns:

  • (String, nil)

    the alias definition (e.g., “alias ffmpeg=‘…’”)



44
45
46
# File 'lib/ukiryu/models/executable_info.rb', line 44

def alias_definition
  @alias_definition
end

#pathString (readonly)

The full path to the executable

Returns:

  • (String)

    the executable path



29
30
31
# File 'lib/ukiryu/models/executable_info.rb', line 29

def path
  @path
end

#shellSymbol (readonly)

The shell used for discovery

Returns:

  • (Symbol)

    the shell (:bash, :zsh, :fish, :sh, etc.)



39
40
41
# File 'lib/ukiryu/models/executable_info.rb', line 39

def shell
  @shell
end

#sourceSymbol (readonly)

How the executable was discovered

Returns:

  • (Symbol)

    :path or :alias



34
35
36
# File 'lib/ukiryu/models/executable_info.rb', line 34

def source
  @source
end

Instance Method Details

#alias?Boolean

Check if this is a shell alias

Returns:

  • (Boolean)

    true if source is :alias



68
69
70
# File 'lib/ukiryu/models/executable_info.rb', line 68

def alias?
  source == :alias
end

#descriptionString

Human-readable description

Returns:

  • (String)

    description of how executable was found



56
57
58
59
60
61
62
63
# File 'lib/ukiryu/models/executable_info.rb', line 56

def description
  case source
  when :path
    "Found in PATH at #{path}"
  when :alias
    "Shell alias in #{shell}: #{alias_definition}"
  end
end

#path?Boolean

Check if this was found in PATH

Returns:

  • (Boolean)

    true if source is :path



75
76
77
# File 'lib/ukiryu/models/executable_info.rb', line 75

def path?
  source == :path
end