Class: Ukiryu::Extractors::NativeExtractor

Inherits:
BaseExtractor show all
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

Methods inherited from BaseExtractor

#initialize

Constructor Details

This class inherits a constructor from Ukiryu::Extractors::BaseExtractor

Instance Method Details

#available?Boolean

Check if the tool supports native definition extraction

Returns:

  • (Boolean)

    true if the tool exists and the flag is supported



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

#extractString?

Extract definition using native flag

Returns:

  • (String, nil)

    the YAML definition or nil if extraction failed



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