Module: Xmi::Parsing
- Defined in:
- lib/xmi/parsing.rb
Overview
Unified API for XMI parsing with version support
This module provides a consistent interface for parsing XMI documents with automatic version detection or explicit version specification.
Class Method Summary collapse
-
.detect_version(xml) ⇒ Hash
Detect XMI version without full parsing.
-
.parse(xml, options = {}) ⇒ Root, Object
Parse XMI with automatic version detection.
-
.parse_file(path, options = {}) ⇒ Root, Object
Parse XMI file.
-
.supported_versions ⇒ Array<String>
Get supported XMI versions.
-
.version_supported?(version) ⇒ Boolean
Check if a version is supported.
Class Method Details
.detect_version(xml) ⇒ Hash
Detect XMI version without full parsing
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/xmi/parsing.rb', line 57 def detect_version(xml) versions = NamespaceDetector.detect_versions(xml) uris = NamespaceDetector.detect_namespace_uris(xml) { versions: versions, uris: uris, xmi_version: versions[:xmi], uml_version: versions[:uml], } end |
.parse(xml, options = {}) ⇒ Root, Object
Parse XMI with automatic version detection
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/xmi/parsing.rb', line 29 def parse(xml, = {}) xml_content = xml.is_a?(String) ? xml : xml.read ctx = { xml: xml_content, root_class: [:model_class] || Root, } register = explicit_register() ctx[:register] = register if register ParserPipeline.run(ctx)[:root] end |
.parse_file(path, options = {}) ⇒ Root, Object
Parse XMI file
48 49 50 |
# File 'lib/xmi/parsing.rb', line 48 def parse_file(path, = {}) parse(File.read(path), ) end |
.supported_versions ⇒ Array<String>
Get supported XMI versions
73 74 75 |
# File 'lib/xmi/parsing.rb', line 73 def supported_versions VersionRegistry.available_versions end |
.version_supported?(version) ⇒ Boolean
Check if a version is supported
82 83 84 |
# File 'lib/xmi/parsing.rb', line 82 def version_supported?(version) supported_versions.include?(version) end |