Class: Suma::Eengine::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/suma/eengine/wrapper.rb

Overview

Wrapper for eengine binary to compare EXPRESS schemas

Class Method Summary collapse

Class Method Details

.available?Boolean

Check if eengine is available on the system

Returns:

  • (Boolean)

    true if eengine binary is found



37
38
39
40
41
# File 'lib/suma/eengine/wrapper.rb', line 37

def available?
  return false if ENV["EENGINE_DISABLED"] == "true"

  eengine_path && eengine_executable?
end

.compare(trial_schema, reference_schema, options = {}) ⇒ Hash

Compare two EXPRESS schemas using eengine

Parameters:

  • trial_schema (String)

    Path to the new/trial schema

  • reference_schema (String)

    Path to the old/reference schema

  • options (Hash) (defaults to: {})

    Comparison options

Options Hash (options):

  • :mode (String)

    Comparison mode (resource/module)

  • :trial_stepmod (String)

    Path to trial repo root

  • :reference_stepmod (String)

    Path to reference repo root

Returns:

  • (Hash)

    Result with :success, :xml_path, :has_changes, :output



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/suma/eengine/wrapper.rb', line 20

def compare(trial_schema, reference_schema, options = {})
  ensure_eengine_available!

  cmd = build_command(trial_schema, reference_schema, options)
  output, error, status = Open3.capture3(*cmd)

  unless status.success?
    error_message = error.empty? ? "Unknown eengine error" : error.strip
    raise ComparisonError.new(error_message, error)
  end

  parse_output(output, options)
end

.versionString?

Get the eengine version

Returns:

  • (String, nil)

    Version string or nil if unavailable



46
47
48
49
50
51
52
53
54
# File 'lib/suma/eengine/wrapper.rb', line 46

def version
  return nil unless available?

  cmd = [eengine_path, "--version"]
  output, _, status = Open3.capture3(*cmd)
  status.success? ? parse_version(output) : nil
rescue StandardError
  nil
end