Module: Ea::Transformations

Defined in:
lib/ea/transformations.rb,
lib/ea/transformations/configuration.rb,
lib/ea/transformations/format_registry.rb,
lib/ea/transformations/parsers/qea_parser.rb,
lib/ea/transformations/parsers/xmi_parser.rb,
lib/ea/transformations/parsers/base_parser.rb,
lib/ea/transformations/transformation_engine.rb

Defined Under Namespace

Modules: Parsers Classes: Configuration, FormatRegistry, TransformationEngine, UnsupportedFormatError

Class Method Summary collapse

Class Method Details

.configurationObject



121
122
123
# File 'lib/ea/transformations.rb', line 121

def configuration
  engine.configuration
end

.configuration=(config) ⇒ Object



125
126
127
# File 'lib/ea/transformations.rb', line 125

def configuration=(config)
  engine.configuration = config
end

.configure {|configuration| ... } ⇒ Object

Yields:



129
130
131
# File 'lib/ea/transformations.rb', line 129

def configure
  yield(configuration) if block_given?
end

.constantize(class_name) ⇒ Class?

Resolve a class name string to a constant

Parameters:

  • class_name (String)

    Fully qualified class name (e.g. "Ea::Foo::Bar")

Returns:

  • (Class, nil)

    The resolved class constant, or nil if not found



18
19
20
21
22
23
24
25
# File 'lib/ea/transformations.rb', line 18

def self.constantize(class_name)
  parts = class_name.split("::")
  constant = Object
  parts.each { |part| constant = constant.const_get(part) }
  constant
rescue NameError
  nil
end

.detect_parser(file_path) ⇒ Object



89
90
91
# File 'lib/ea/transformations.rb', line 89

def detect_parser(file_path)
  engine.detect_parser(file_path)
end

.engineObject



28
29
30
# File 'lib/ea/transformations.rb', line 28

def engine
  @engine ||= TransformationEngine.new
end

.engine=(engine) ⇒ Object



32
33
34
# File 'lib/ea/transformations.rb', line 32

def engine=(engine)
  @engine = engine
end

.load_configuration(config_path) ⇒ Object



117
118
119
# File 'lib/ea/transformations.rb', line 117

def load_configuration(config_path)
  engine.configuration = Configuration.load(config_path)
end

.parse(file_path, options = {}) ⇒ Ea::Qea::Database, Xmi::Sparx::Root

Parse an EA file into its native representation.

Pure entry point — does NOT require lutaml-uml. Returns:

.qea → Ea::Qea::Database
.xmi → Xmi::Sparx::Root

To get a Lutaml::Uml::Document instead, use to_uml.

Parameters:

  • file_path (String)

    path to a .qea or .xmi file

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

    parser options (e.g. config: for QEA)

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ea/transformations.rb', line 47

def parse(file_path, options = {})
  ext = File.extname(file_path).downcase
  case ext
  when ".qea"
    Ea::Qea.load(file_path, options[:config])
  when ".xmi", ".xml"
    Ea::Xmi.load(file_path)
  else
    raise Ea::Error,
          "Unsupported file extension #{ext.inspect}. " \
          "Supported: .qea, .xmi"
  end
end

.register_parser(extension, parser_class) ⇒ Object



113
114
115
# File 'lib/ea/transformations.rb', line 113

def register_parser(extension, parser_class)
  engine.register_parser(extension, parser_class)
end

.reset_statisticsObject



105
106
107
# File 'lib/ea/transformations.rb', line 105

def reset_statistics
  engine.clear_history
end

.statisticsObject



101
102
103
# File 'lib/ea/transformations.rb', line 101

def statistics
  engine.statistics
end

.supported_extensionsObject



93
94
95
# File 'lib/ea/transformations.rb', line 93

def supported_extensions
  engine.supported_extensions
end

.supports_file?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/ea/transformations.rb', line 97

def supports_file?(file_path)
  engine.supports_file?(file_path)
end

.to_uml(path_or_model, options = {}) ⇒ Lutaml::Uml::Document

Transform an EA file (or pre-parsed model) into a Lutaml::Uml::Document.

Bridge entry point — requires the optional lutaml-uml gem. Lazy-loads the bridge code on first call.

Parameters:

  • path_or_model (String, Ea::Qea::Database, Xmi::Sparx::Root)
  • options (Hash) (defaults to: {})

    transformation options

Returns:

  • (Lutaml::Uml::Document)


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ea/transformations.rb', line 70

def to_uml(path_or_model, options = {})
  model = if path_or_model.is_a?(String)
            parse(path_or_model, options)
          else
            path_or_model
          end

  case model
  when Ea::Qea::Database
    Ea::Bridge::QeaToUml.transform(model, options)
  when ::Xmi::Sparx::Root
    Ea::Bridge::XmiToUml.transform(model)
  else
    raise Ea::Error,
          "Cannot transform #{model.class} to Lutaml::Uml::Document. " \
          "Expected Ea::Qea::Database or Xmi::Sparx::Root."
  end
end

.validate_setupObject



109
110
111
# File 'lib/ea/transformations.rb', line 109

def validate_setup
  engine.validate_setup
end