Class: Ukiryu::Extractors::NativeExtractor
- Inherits:
-
BaseExtractor
- Object
- BaseExtractor
- Ukiryu::Extractors::NativeExtractor
- Defined in:
- lib/ukiryu/extractors/native_extractor.rb
Overview
Native flag extraction strategy
Attempts to extract definition using the tool’s native ‘–ukiryu-definition` flag if supported.
Constant Summary collapse
- NATIVE_FLAG =
Native flag to try
'--ukiryu-definition'
Instance Method Summary collapse
-
#available? ⇒ Boolean
Check if the tool supports native definition extraction.
-
#extract ⇒ String?
Extract definition using native flag.
Methods inherited from BaseExtractor
Constructor Details
This class inherits a constructor from Ukiryu::Extractors::BaseExtractor
Instance Method Details
#available? ⇒ Boolean
Check if the tool supports native definition extraction
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ukiryu/extractors/native_extractor.rb', line 30 def available? # First check if tool exists which_result = execute_command(['which', @tool_name.to_s]) return false unless which_result[:exit_status].zero? # Then check if it supports the flag help_result = execute_command([@tool_name.to_s, '--help']) return false unless help_result[:exit_status].zero? # Check if help mentions ukiryu help_output = help_result[:stdout] + help_result[:stderr] help_output.downcase.include?('ukiryu') || help_output.include?(NATIVE_FLAG) end |
#extract ⇒ String?
Extract definition using native flag
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ukiryu/extractors/native_extractor.rb', line 16 def extract return nil unless available? result = execute_command([@tool_name.to_s, NATIVE_FLAG]) return nil unless result[:exit_status].zero? return nil if result[:stdout].strip.empty? result[:stdout] end |