Class: Ea::Sources::Xmi::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/sources/xmi/adapter.rb

Overview

Driving port: produces an Ea::Model::Document from a parsed Xmi::Sparx::Root. Walks the UML model tree once and delegates to per-domain builders. The result is structurally identical to what the QEA adapter produces for the same conceptual source — that's the "single way" promise.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, xmi_path = nil) ⇒ Adapter

Returns a new instance of Adapter.



14
15
16
17
# File 'lib/ea/sources/xmi/adapter.rb', line 14

def initialize(root, xmi_path = nil)
  @root = root
  @xmi_path = xmi_path
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



12
13
14
# File 'lib/ea/sources/xmi/adapter.rb', line 12

def root
  @root
end

#xmi_pathObject (readonly)

Returns the value of attribute xmi_path.



12
13
14
# File 'lib/ea/sources/xmi/adapter.rb', line 12

def xmi_path
  @xmi_path
end

Class Method Details

.from_path(xmi_path) ⇒ Object

Convenience: build a document directly from an .xmi file path. Parses via Xmi::Sparx::Root.parse_xml.



21
22
23
24
25
# File 'lib/ea/sources/xmi/adapter.rb', line 21

def self.from_path(xmi_path)
  require "xmi"
  root = ::Xmi::Sparx::Root.parse_xml(File.read(xmi_path))
  new(root, xmi_path).to_document
end

Instance Method Details

#to_documentObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/ea/sources/xmi/adapter.rb', line 27

def to_document
  Ea::Model::Document.new(
    metadata: ,
    packages: packages,
    classifiers: classifiers,
    relationships: relationships,
    stereotypes: [],
    diagrams: diagrams
  )
end