Class: Ea::Sources::Xmi::UmldiKeywordExtractor
- Inherits:
-
Object
- Object
- Ea::Sources::Xmi::UmldiKeywordExtractor
- Defined in:
- lib/ea/sources/xmi/umldi_keyword_extractor.rb
Overview
Reads UMLDI <ownedElement> blocks from the XMI source and
returns the keyword text EA emitted for each modeled element.
The xmi gem's typed parser does not surface umldi: keyword
labels, but EA encodes them as
<ownedElement xmi:type="umldi:UMLKeywordLabel" text="Type"/>.
This class pre-parses the raw XML once and indexes by the
referenced classifier ID.
Returned text is the raw keyword ("Type", "FeatureType", "dataType"). The emitter wraps it in «...» when rendering.
Constant Summary collapse
- UMLDI_NAMESPACES =
Sparx EA 6.5 declares umldi: as the 20161101 namespace on the XMI root. Older EAs use the 20131001 version. Try both.
[ "http://www.omg.org/spec/UML/20161101/UMLDI", "http://www.omg.org/spec/UML/20131001/UMLDI" ].freeze
Instance Attribute Summary collapse
-
#xmi_path ⇒ Object
readonly
Returns the value of attribute xmi_path.
Instance Method Summary collapse
-
#initialize(xmi_path) ⇒ UmldiKeywordExtractor
constructor
A new instance of UmldiKeywordExtractor.
-
#keywords_for_diagram(diagram_id) ⇒ Object
Returns { classifier_id => keyword_text } for every umldi:UMLKeywordLabel found, scoped to the given diagram.
Constructor Details
#initialize(xmi_path) ⇒ UmldiKeywordExtractor
Returns a new instance of UmldiKeywordExtractor.
29 30 31 |
# File 'lib/ea/sources/xmi/umldi_keyword_extractor.rb', line 29 def initialize(xmi_path) @xmi_path = xmi_path end |
Instance Attribute Details
#xmi_path ⇒ Object (readonly)
Returns the value of attribute xmi_path.
27 28 29 |
# File 'lib/ea/sources/xmi/umldi_keyword_extractor.rb', line 27 def xmi_path @xmi_path end |
Instance Method Details
#keywords_for_diagram(diagram_id) ⇒ Object
Returns { classifier_id => keyword_text } for every umldi:UMLKeywordLabel found, scoped to the given diagram.
35 36 37 38 39 |
# File 'lib/ea/sources/xmi/umldi_keyword_extractor.rb', line 35 def keywords_for_diagram(diagram_id) return {} unless File.exist?(xmi_path) keywords_by_diagram[diagram_id] || {} end |