Class: Ace::Llm::Providers::Cli::Atoms::ProviderDetector
- Inherits:
-
Object
- Object
- Ace::Llm::Providers::Cli::Atoms::ProviderDetector
- Defined in:
- lib/ace/llm/providers/cli/atoms/provider_detector.rb
Overview
Detects whether a CLI tool is installed and retrieves its version
Class Method Summary collapse
-
.available?(cli_name) ⇒ Boolean
Check if a CLI tool is available on the system.
-
.extract_version(output) ⇒ String
Extract version number from command output.
-
.version(check_cmd) ⇒ String
Get the version of a CLI tool.
Class Method Details
.available?(cli_name) ⇒ Boolean
Check if a CLI tool is available on the system
15 16 17 |
# File 'lib/ace/llm/providers/cli/atoms/provider_detector.rb', line 15 def self.available?(cli_name) system("which", cli_name, out: File::NULL, err: File::NULL) end |
.extract_version(output) ⇒ String
Extract version number from command output
34 35 36 37 38 39 40 41 42 |
# File 'lib/ace/llm/providers/cli/atoms/provider_detector.rb', line 34 def self.extract_version(output) if output =~ /(\d+\.\d+\.\d+)/ $1 elsif output =~ /v(\d+\.\d+)/ $1 else output.lines.first&.strip || "Unknown" end end |
.version(check_cmd) ⇒ String
Get the version of a CLI tool
22 23 24 25 26 27 28 29 |
# File 'lib/ace/llm/providers/cli/atoms/provider_detector.rb', line 22 def self.version(check_cmd) stdout, _, status = Open3.capture3(*check_cmd) return "Unknown" unless status.success? extract_version(stdout) rescue Errno::ENOENT, Errno::EACCES "Unknown" end |