Class: Lutaml::Qea::Verification::StructureMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/qea/verification/structure_matcher.rb

Overview

Matches corresponding elements between XMI and QEA documents by qualified name/path

Instance Method Summary collapse

Instance Method Details

#build_qualified_names(document) ⇒ Hash

Build qualified name index for document

Parameters:

Returns:

  • (Hash)

    Hash mapping qualified names to elements



61
62
63
64
65
66
67
68
# File 'lib/lutaml/qea/verification/structure_matcher.rb', line 61

def build_qualified_names(document)
  {
    packages: build_package_index(document.packages),
    classes: build_class_index(document),
    enums: build_enum_index(document),
    data_types: build_data_type_index(document),
  }
end

#match_attributes(xmi_class, qea_class) ⇒ Hash

Match attributes between classes

Parameters:

Returns:

  • (Hash)

    Hash with :matches, :xmi_only, :qea_only



38
39
40
41
42
43
# File 'lib/lutaml/qea/verification/structure_matcher.rb', line 38

def match_attributes(xmi_class, qea_class)
  xmi_attrs = index_by_name(xmi_class.attributes || [])
  qea_attrs = index_by_name(qea_class.attributes || [])

  match_elements(xmi_attrs, qea_attrs)
end

#match_classes(xmi_doc, qea_doc) ⇒ Hash

Match classes between documents

Parameters:

Returns:

  • (Hash)

    Hash with :matches, :xmi_only, :qea_only



26
27
28
29
30
31
# File 'lib/lutaml/qea/verification/structure_matcher.rb', line 26

def match_classes(xmi_doc, qea_doc)
  xmi_classes = build_class_index(xmi_doc)
  qea_classes = build_class_index(qea_doc)

  match_elements(xmi_classes, qea_classes)
end

#match_operations(xmi_class, qea_class) ⇒ Hash

Match operations between classes

Parameters:

Returns:

  • (Hash)

    Hash with :matches, :xmi_only, :qea_only



50
51
52
53
54
55
# File 'lib/lutaml/qea/verification/structure_matcher.rb', line 50

def match_operations(xmi_class, qea_class)
  xmi_ops = index_by_signature(xmi_class.operations || [])
  qea_ops = index_by_signature(qea_class.operations || [])

  match_elements(xmi_ops, qea_ops)
end

#match_packages(xmi_doc, qea_doc) ⇒ Hash

Match packages between documents

Parameters:

Returns:

  • (Hash)

    Hash with :matches, :xmi_only, :qea_only



14
15
16
17
18
19
# File 'lib/lutaml/qea/verification/structure_matcher.rb', line 14

def match_packages(xmi_doc, qea_doc)
  xmi_packages = build_package_index(xmi_doc.packages)
  qea_packages = build_package_index(qea_doc.packages)

  match_elements(xmi_packages, qea_packages)
end