xmi 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (384) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +14 -0
  3. data/.github/workflows/release.yml +22 -0
  4. data/.rubocop.yml +6 -0
  5. data/README.adoc +87 -2
  6. data/lib/xmi/documentation.rb +6 -6
  7. data/lib/xmi/ea_root.rb +316 -0
  8. data/lib/xmi/extension.rb +5 -5
  9. data/lib/xmi/root.rb +43 -20
  10. data/lib/xmi/root13.rb +0 -1
  11. data/lib/xmi/sparx.rb +368 -154
  12. data/lib/xmi/uml.rb +422 -131
  13. data/lib/xmi/uml13/abstraction.rb +90 -88
  14. data/lib/xmi/uml13/action.rb +86 -84
  15. data/lib/xmi/uml13/action_sequence.rb +76 -74
  16. data/lib/xmi/uml13/action_sequenceaction.rb +23 -21
  17. data/lib/xmi/uml13/action_sequencestate.rb +7 -5
  18. data/lib/xmi/uml13/action_sequencestate2.rb +7 -5
  19. data/lib/xmi/uml13/action_sequencetransition.rb +7 -5
  20. data/lib/xmi/uml13/action_state.rb +89 -87
  21. data/lib/xmi/uml13/actionaction_sequence.rb +7 -5
  22. data/lib/xmi/uml13/actionactual_argument.rb +7 -5
  23. data/lib/xmi/uml13/actionis_asynchronous.rb +6 -4
  24. data/lib/xmi/uml13/actionmessage.rb +7 -5
  25. data/lib/xmi/uml13/actionrecurrence.rb +15 -13
  26. data/lib/xmi/uml13/actionrequest.rb +7 -5
  27. data/lib/xmi/uml13/actionscript.rb +7 -5
  28. data/lib/xmi/uml13/actiontarget.rb +7 -5
  29. data/lib/xmi/uml13/activity_model.rb +77 -75
  30. data/lib/xmi/uml13/activity_modelpartition.rb +7 -5
  31. data/lib/xmi/uml13/activity_state.rb +88 -86
  32. data/lib/xmi/uml13/actor.rb +113 -111
  33. data/lib/xmi/uml13/argument.rb +17 -15
  34. data/lib/xmi/uml13/argumentaction.rb +7 -5
  35. data/lib/xmi/uml13/argumentvalue.rb +15 -13
  36. data/lib/xmi/uml13/association.rb +90 -88
  37. data/lib/xmi/uml13/association_class.rb +120 -118
  38. data/lib/xmi/uml13/association_end.rb +100 -98
  39. data/lib/xmi/uml13/association_end_role.rb +106 -104
  40. data/lib/xmi/uml13/association_end_roleassociation_role.rb +7 -5
  41. data/lib/xmi/uml13/association_end_rolebase.rb +7 -5
  42. data/lib/xmi/uml13/association_endaggregation.rb +6 -4
  43. data/lib/xmi/uml13/association_endassociation.rb +7 -5
  44. data/lib/xmi/uml13/association_endassociation_end_role.rb +7 -5
  45. data/lib/xmi/uml13/association_endchangeable.rb +6 -4
  46. data/lib/xmi/uml13/association_endis_navigable.rb +6 -4
  47. data/lib/xmi/uml13/association_endis_ordered.rb +6 -4
  48. data/lib/xmi/uml13/association_endlink_end.rb +7 -5
  49. data/lib/xmi/uml13/association_endmultiplicity.rb +7 -5
  50. data/lib/xmi/uml13/association_endqualifier.rb +7 -5
  51. data/lib/xmi/uml13/association_endspecification.rb +7 -5
  52. data/lib/xmi/uml13/association_endtarget_scope.rb +6 -4
  53. data/lib/xmi/uml13/association_endtype.rb +7 -5
  54. data/lib/xmi/uml13/association_role.rb +95 -93
  55. data/lib/xmi/uml13/association_rolebase.rb +7 -5
  56. data/lib/xmi/uml13/association_rolemultiplicity.rb +7 -5
  57. data/lib/xmi/uml13/association_rolenamespace.rb +7 -5
  58. data/lib/xmi/uml13/associationassociation_end.rb +7 -5
  59. data/lib/xmi/uml13/associationconnection.rb +9 -7
  60. data/lib/xmi/uml13/associationlink.rb +7 -5
  61. data/lib/xmi/uml13/attribute.rb +94 -92
  62. data/lib/xmi/uml13/attribute_link.rb +74 -72
  63. data/lib/xmi/uml13/attribute_linkattribute.rb +7 -5
  64. data/lib/xmi/uml13/attribute_linkinstance.rb +7 -5
  65. data/lib/xmi/uml13/attribute_linkvalue.rb +7 -5
  66. data/lib/xmi/uml13/attributeassociation_end.rb +7 -5
  67. data/lib/xmi/uml13/attributeattribute_link.rb +7 -5
  68. data/lib/xmi/uml13/attributeinitial_value.rb +15 -13
  69. data/lib/xmi/uml13/auxiliary_elements.rb +28 -26
  70. data/lib/xmi/uml13/behavioral_elements.rb +18 -16
  71. data/lib/xmi/uml13/behavioral_feature.rb +82 -80
  72. data/lib/xmi/uml13/behavioral_featureis_query.rb +6 -4
  73. data/lib/xmi/uml13/behavioral_featureparameter.rb +7 -5
  74. data/lib/xmi/uml13/behavioral_featureraised_exception.rb +7 -5
  75. data/lib/xmi/uml13/binding.rb +81 -79
  76. data/lib/xmi/uml13/bindingargument.rb +175 -173
  77. data/lib/xmi/uml13/boolean_expression.rb +18 -16
  78. data/lib/xmi/uml13/call_action.rb +89 -87
  79. data/lib/xmi/uml13/call_actionmode.rb +6 -4
  80. data/lib/xmi/uml13/call_event.rb +74 -72
  81. data/lib/xmi/uml13/call_eventoperation.rb +7 -5
  82. data/lib/xmi/uml13/change_event.rb +73 -71
  83. data/lib/xmi/uml13/change_eventchange_expression.rb +7 -5
  84. data/lib/xmi/uml13/class.rb +116 -114
  85. data/lib/xmi/uml13/classifier.rb +113 -111
  86. data/lib/xmi/uml13/classifier_in_state.rb +122 -120
  87. data/lib/xmi/uml13/classifier_in_statein_state.rb +7 -5
  88. data/lib/xmi/uml13/classifier_in_stateobject_flow_state.rb +7 -5
  89. data/lib/xmi/uml13/classifier_in_statetype.rb +7 -5
  90. data/lib/xmi/uml13/classifier_role.rb +130 -128
  91. data/lib/xmi/uml13/classifier_roleassociation_end_role.rb +7 -5
  92. data/lib/xmi/uml13/classifier_roleavailable_feature.rb +7 -5
  93. data/lib/xmi/uml13/classifier_rolebase.rb +7 -5
  94. data/lib/xmi/uml13/classifier_rolemessage.rb +7 -5
  95. data/lib/xmi/uml13/classifier_rolemessage2.rb +7 -5
  96. data/lib/xmi/uml13/classifier_rolemultiplicity.rb +7 -5
  97. data/lib/xmi/uml13/classifier_rolenamespace.rb +7 -5
  98. data/lib/xmi/uml13/classifierassociation_end.rb +7 -5
  99. data/lib/xmi/uml13/classifierclassifier_in_state.rb +7 -5
  100. data/lib/xmi/uml13/classifierclassifier_role.rb +7 -5
  101. data/lib/xmi/uml13/classifiercollaboration.rb +7 -5
  102. data/lib/xmi/uml13/classifiercreate_action.rb +7 -5
  103. data/lib/xmi/uml13/classifierfeature.rb +19 -17
  104. data/lib/xmi/uml13/classifierinstance.rb +7 -5
  105. data/lib/xmi/uml13/classifierparameter.rb +7 -5
  106. data/lib/xmi/uml13/classifierparticipant.rb +7 -5
  107. data/lib/xmi/uml13/classifierrealization.rb +7 -5
  108. data/lib/xmi/uml13/classifierspecification.rb +7 -5
  109. data/lib/xmi/uml13/classifierstructural_feature.rb +7 -5
  110. data/lib/xmi/uml13/classis_active.rb +6 -4
  111. data/lib/xmi/uml13/collaboration.rb +78 -76
  112. data/lib/xmi/uml13/collaborationconstraining_element.rb +7 -5
  113. data/lib/xmi/uml13/collaborationinteraction.rb +7 -5
  114. data/lib/xmi/uml13/collaborationrepresented_classifier.rb +7 -5
  115. data/lib/xmi/uml13/collaborationrepresented_operation.rb +7 -5
  116. data/lib/xmi/uml13/collaborations.rb +22 -20
  117. data/lib/xmi/uml13/comment.rb +65 -63
  118. data/lib/xmi/uml13/common_behavior.rb +56 -54
  119. data/lib/xmi/uml13/component.rb +119 -117
  120. data/lib/xmi/uml13/componentdeployment.rb +7 -5
  121. data/lib/xmi/uml13/componentimplements.rb +7 -5
  122. data/lib/xmi/uml13/composite_state.rb +94 -92
  123. data/lib/xmi/uml13/composite_stateis_concurrent.rb +6 -4
  124. data/lib/xmi/uml13/composite_statesubstate.rb +23 -21
  125. data/lib/xmi/uml13/constraint.rb +73 -71
  126. data/lib/xmi/uml13/constraintbody.rb +7 -5
  127. data/lib/xmi/uml13/constraintconstrained_element.rb +7 -5
  128. data/lib/xmi/uml13/constraintconstrained_stereotype.rb +7 -5
  129. data/lib/xmi/uml13/core.rb +52 -50
  130. data/lib/xmi/uml13/create_action.rb +89 -87
  131. data/lib/xmi/uml13/create_actioninstantiation.rb +7 -5
  132. data/lib/xmi/uml13/data_type.rb +113 -111
  133. data/lib/xmi/uml13/data_types.rb +36 -34
  134. data/lib/xmi/uml13/data_value.rb +85 -83
  135. data/lib/xmi/uml13/dependency.rb +79 -77
  136. data/lib/xmi/uml13/dependencyclient.rb +7 -5
  137. data/lib/xmi/uml13/dependencydescription.rb +7 -5
  138. data/lib/xmi/uml13/dependencyowning_dependency.rb +7 -5
  139. data/lib/xmi/uml13/dependencysub_dependencies.rb +15 -13
  140. data/lib/xmi/uml13/dependencysupplier.rb +7 -5
  141. data/lib/xmi/uml13/destroy_action.rb +86 -84
  142. data/lib/xmi/uml13/diagram.rb +25 -23
  143. data/lib/xmi/uml13/diagram_compositions.rb +7 -5
  144. data/lib/xmi/uml13/diagram_element.rb +20 -18
  145. data/lib/xmi/uml13/diagram_element_properties.rb +9 -7
  146. data/lib/xmi/uml13/diagram_elementdiagram.rb +7 -5
  147. data/lib/xmi/uml13/diagram_elementgeometry.rb +7 -5
  148. data/lib/xmi/uml13/diagram_elementstyle.rb +7 -5
  149. data/lib/xmi/uml13/diagram_properties.rb +13 -11
  150. data/lib/xmi/uml13/diagramdiagram_type.rb +7 -5
  151. data/lib/xmi/uml13/diagramelement.rb +7 -5
  152. data/lib/xmi/uml13/diagramname.rb +7 -5
  153. data/lib/xmi/uml13/diagramowner.rb +157 -155
  154. data/lib/xmi/uml13/diagramstyle.rb +7 -5
  155. data/lib/xmi/uml13/diagramtool_name.rb +7 -5
  156. data/lib/xmi/uml13/element.rb +12 -10
  157. data/lib/xmi/uml13/element_reference.rb +24 -22
  158. data/lib/xmi/uml13/element_referencealias.rb +7 -5
  159. data/lib/xmi/uml13/element_referencepackage.rb +7 -5
  160. data/lib/xmi/uml13/element_referencereferenced_element.rb +7 -5
  161. data/lib/xmi/uml13/element_referencevisibility.rb +6 -4
  162. data/lib/xmi/uml13/enumeration.rb +115 -113
  163. data/lib/xmi/uml13/enumeration_literal.rb +18 -16
  164. data/lib/xmi/uml13/enumeration_literalenumeration.rb +7 -5
  165. data/lib/xmi/uml13/enumeration_literalname.rb +7 -5
  166. data/lib/xmi/uml13/enumerationliteral.rb +7 -5
  167. data/lib/xmi/uml13/event.rb +71 -69
  168. data/lib/xmi/uml13/eventstate.rb +7 -5
  169. data/lib/xmi/uml13/eventtransition.rb +7 -5
  170. data/lib/xmi/uml13/exception.rb +99 -97
  171. data/lib/xmi/uml13/exceptioncontext.rb +7 -5
  172. data/lib/xmi/uml13/expression.rb +18 -16
  173. data/lib/xmi/uml13/expressionbody.rb +7 -5
  174. data/lib/xmi/uml13/expressionlanguage.rb +7 -5
  175. data/lib/xmi/uml13/extension_mechanisms.rb +14 -12
  176. data/lib/xmi/uml13/feature.rb +74 -72
  177. data/lib/xmi/uml13/featureclassifier_role.rb +7 -5
  178. data/lib/xmi/uml13/featureowner.rb +7 -5
  179. data/lib/xmi/uml13/featureowner_scope.rb +6 -4
  180. data/lib/xmi/uml13/foundation.rb +18 -16
  181. data/lib/xmi/uml13/generalizable_element.rb +82 -80
  182. data/lib/xmi/uml13/generalizable_elementgeneralization.rb +7 -5
  183. data/lib/xmi/uml13/generalizable_elementis_abstract.rb +6 -4
  184. data/lib/xmi/uml13/generalizable_elementis_leaf.rb +6 -4
  185. data/lib/xmi/uml13/generalizable_elementis_root.rb +6 -4
  186. data/lib/xmi/uml13/generalizable_elementspecialization.rb +7 -5
  187. data/lib/xmi/uml13/generalization.rb +74 -72
  188. data/lib/xmi/uml13/generalizationdiscriminator.rb +7 -5
  189. data/lib/xmi/uml13/generalizationsubtype.rb +7 -5
  190. data/lib/xmi/uml13/generalizationsupertype.rb +7 -5
  191. data/lib/xmi/uml13/geometry.rb +15 -13
  192. data/lib/xmi/uml13/geometrybody.rb +7 -5
  193. data/lib/xmi/uml13/graphic_marker.rb +15 -13
  194. data/lib/xmi/uml13/graphic_markerbody.rb +7 -5
  195. data/lib/xmi/uml13/guard.rb +70 -68
  196. data/lib/xmi/uml13/guardexpression.rb +7 -5
  197. data/lib/xmi/uml13/guardtransition.rb +7 -5
  198. data/lib/xmi/uml13/instance.rb +85 -83
  199. data/lib/xmi/uml13/instanceattribute_link.rb +7 -5
  200. data/lib/xmi/uml13/instanceclassifier.rb +7 -5
  201. data/lib/xmi/uml13/instancelink_end.rb +7 -5
  202. data/lib/xmi/uml13/instancemessage_instance.rb +7 -5
  203. data/lib/xmi/uml13/instancemessage_instance2.rb +7 -5
  204. data/lib/xmi/uml13/instancemessage_instance3.rb +7 -5
  205. data/lib/xmi/uml13/instanceslot.rb +7 -5
  206. data/lib/xmi/uml13/interaction.rb +70 -68
  207. data/lib/xmi/uml13/interactioncontext.rb +7 -5
  208. data/lib/xmi/uml13/interactionmessage.rb +7 -5
  209. data/lib/xmi/uml13/interface.rb +113 -111
  210. data/lib/xmi/uml13/link.rb +70 -68
  211. data/lib/xmi/uml13/link_end.rb +74 -72
  212. data/lib/xmi/uml13/link_endassociation_end.rb +7 -5
  213. data/lib/xmi/uml13/link_endinstance.rb +7 -5
  214. data/lib/xmi/uml13/link_endlink.rb +7 -5
  215. data/lib/xmi/uml13/link_object.rb +90 -88
  216. data/lib/xmi/uml13/linkassociation.rb +7 -5
  217. data/lib/xmi/uml13/linklink_role.rb +7 -5
  218. data/lib/xmi/uml13/local_invocation.rb +86 -84
  219. data/lib/xmi/uml13/mapping.rb +15 -13
  220. data/lib/xmi/uml13/mappingbody.rb +7 -5
  221. data/lib/xmi/uml13/message.rb +89 -87
  222. data/lib/xmi/uml13/message_instance.rb +77 -75
  223. data/lib/xmi/uml13/message_instanceargument.rb +7 -5
  224. data/lib/xmi/uml13/message_instancereceiver.rb +7 -5
  225. data/lib/xmi/uml13/message_instancesender.rb +7 -5
  226. data/lib/xmi/uml13/message_instancespecification.rb +7 -5
  227. data/lib/xmi/uml13/messageaction.rb +7 -5
  228. data/lib/xmi/uml13/messageactivator.rb +7 -5
  229. data/lib/xmi/uml13/messageinteraction.rb +7 -5
  230. data/lib/xmi/uml13/messagemessage.rb +7 -5
  231. data/lib/xmi/uml13/messagemessage2.rb +7 -5
  232. data/lib/xmi/uml13/messagepredecessor.rb +7 -5
  233. data/lib/xmi/uml13/messagereceiver.rb +7 -5
  234. data/lib/xmi/uml13/messagesender.rb +7 -5
  235. data/lib/xmi/uml13/method.rb +87 -85
  236. data/lib/xmi/uml13/methodbody.rb +7 -5
  237. data/lib/xmi/uml13/methodspecification.rb +7 -5
  238. data/lib/xmi/uml13/model.rb +81 -79
  239. data/lib/xmi/uml13/model_element.rb +65 -63
  240. data/lib/xmi/uml13/model_element_owns_diagramowned_diagram.rb +7 -5
  241. data/lib/xmi/uml13/model_elementbehavior.rb +7 -5
  242. data/lib/xmi/uml13/model_elementbinding.rb +7 -5
  243. data/lib/xmi/uml13/model_elementcollaboration.rb +7 -5
  244. data/lib/xmi/uml13/model_elementconstraint.rb +7 -5
  245. data/lib/xmi/uml13/model_elementelement_reference.rb +7 -5
  246. data/lib/xmi/uml13/model_elementimplementation.rb +7 -5
  247. data/lib/xmi/uml13/model_elementname.rb +7 -5
  248. data/lib/xmi/uml13/model_elementnamespace.rb +7 -5
  249. data/lib/xmi/uml13/model_elementpartition.rb +7 -5
  250. data/lib/xmi/uml13/model_elementpresentation.rb +7 -5
  251. data/lib/xmi/uml13/model_elementprovision.rb +7 -5
  252. data/lib/xmi/uml13/model_elementrequirement.rb +7 -5
  253. data/lib/xmi/uml13/model_elementstereotype.rb +7 -5
  254. data/lib/xmi/uml13/model_elementtagged_value.rb +7 -5
  255. data/lib/xmi/uml13/model_elementtemplate.rb +7 -5
  256. data/lib/xmi/uml13/model_elementtemplate_parameter.rb +7 -5
  257. data/lib/xmi/uml13/model_elementview.rb +7 -5
  258. data/lib/xmi/uml13/model_elementvisibility.rb +6 -4
  259. data/lib/xmi/uml13/model_management.rb +18 -16
  260. data/lib/xmi/uml13/multiplicity_range.rb +18 -16
  261. data/lib/xmi/uml13/multiplicity_rangelower.rb +7 -5
  262. data/lib/xmi/uml13/multiplicity_rangeupper.rb +7 -5
  263. data/lib/xmi/uml13/namespace.rb +67 -65
  264. data/lib/xmi/uml13/namespaceowned_element.rb +175 -173
  265. data/lib/xmi/uml13/node.rb +116 -114
  266. data/lib/xmi/uml13/nodecomponent.rb +7 -5
  267. data/lib/xmi/uml13/object.rb +85 -83
  268. data/lib/xmi/uml13/object_flow_state.rb +92 -90
  269. data/lib/xmi/uml13/object_flow_statetype_state.rb +7 -5
  270. data/lib/xmi/uml13/object_set_expression.rb +18 -16
  271. data/lib/xmi/uml13/operation.rb +102 -100
  272. data/lib/xmi/uml13/operationcollaboration.rb +7 -5
  273. data/lib/xmi/uml13/operationconcurrency.rb +6 -4
  274. data/lib/xmi/uml13/operationis_polymorphic.rb +6 -4
  275. data/lib/xmi/uml13/operationmethod.rb +7 -5
  276. data/lib/xmi/uml13/operationoccurrence.rb +7 -5
  277. data/lib/xmi/uml13/operationspecification.rb +7 -5
  278. data/lib/xmi/uml13/package.rb +81 -79
  279. data/lib/xmi/uml13/packageelement_reference.rb +7 -5
  280. data/lib/xmi/uml13/parameter.rb +79 -77
  281. data/lib/xmi/uml13/parameterbehavioral_feature.rb +7 -5
  282. data/lib/xmi/uml13/parameterdefault_value.rb +15 -13
  283. data/lib/xmi/uml13/parameterkind.rb +6 -4
  284. data/lib/xmi/uml13/parametersignal.rb +7 -5
  285. data/lib/xmi/uml13/parametertype.rb +7 -5
  286. data/lib/xmi/uml13/partition.rb +71 -69
  287. data/lib/xmi/uml13/partitionactivity_model.rb +7 -5
  288. data/lib/xmi/uml13/partitioncontents.rb +7 -5
  289. data/lib/xmi/uml13/presentation.rb +22 -20
  290. data/lib/xmi/uml13/presentationgeometry.rb +7 -5
  291. data/lib/xmi/uml13/presentationmodel.rb +7 -5
  292. data/lib/xmi/uml13/presentationstyle.rb +7 -5
  293. data/lib/xmi/uml13/presentationview_element.rb +7 -5
  294. data/lib/xmi/uml13/primitive.rb +113 -111
  295. data/lib/xmi/uml13/procedure_expression.rb +18 -16
  296. data/lib/xmi/uml13/pseudo_state.rb +77 -75
  297. data/lib/xmi/uml13/pseudo_statekind.rb +6 -4
  298. data/lib/xmi/uml13/reception.rb +91 -89
  299. data/lib/xmi/uml13/receptionis_polymorphic.rb +6 -4
  300. data/lib/xmi/uml13/receptionsignal.rb +7 -5
  301. data/lib/xmi/uml13/receptionspecification.rb +7 -5
  302. data/lib/xmi/uml13/refinement.rb +81 -79
  303. data/lib/xmi/uml13/refinementmapping.rb +7 -5
  304. data/lib/xmi/uml13/request.rb +71 -69
  305. data/lib/xmi/uml13/requestaction.rb +7 -5
  306. data/lib/xmi/uml13/requestmessage_instance.rb +7 -5
  307. data/lib/xmi/uml13/return_action.rb +86 -84
  308. data/lib/xmi/uml13/send_action.rb +86 -84
  309. data/lib/xmi/uml13/signal.rb +96 -94
  310. data/lib/xmi/uml13/signal_event.rb +74 -72
  311. data/lib/xmi/uml13/signal_eventsignal.rb +7 -5
  312. data/lib/xmi/uml13/signaloccurrence.rb +7 -5
  313. data/lib/xmi/uml13/signalparameter.rb +7 -5
  314. data/lib/xmi/uml13/signalreception.rb +7 -5
  315. data/lib/xmi/uml13/simple_state.rb +89 -87
  316. data/lib/xmi/uml13/state.rb +89 -87
  317. data/lib/xmi/uml13/state_machine.rb +75 -73
  318. data/lib/xmi/uml13/state_machinecontext.rb +7 -5
  319. data/lib/xmi/uml13/state_machines.rb +50 -48
  320. data/lib/xmi/uml13/state_machinesubmachine_state.rb +7 -5
  321. data/lib/xmi/uml13/state_machinetop.rb +19 -17
  322. data/lib/xmi/uml13/state_machinetransitions.rb +7 -5
  323. data/lib/xmi/uml13/state_vertex.rb +74 -72
  324. data/lib/xmi/uml13/state_vertexincoming.rb +7 -5
  325. data/lib/xmi/uml13/state_vertexoutgoing.rb +7 -5
  326. data/lib/xmi/uml13/state_vertexparent.rb +7 -5
  327. data/lib/xmi/uml13/stateclassifier_in_state.rb +7 -5
  328. data/lib/xmi/uml13/statedeferred_event.rb +7 -5
  329. data/lib/xmi/uml13/stateentry.rb +7 -5
  330. data/lib/xmi/uml13/stateexit.rb +7 -5
  331. data/lib/xmi/uml13/stateinternal_transition.rb +7 -5
  332. data/lib/xmi/uml13/statestate_machine.rb +7 -5
  333. data/lib/xmi/uml13/stereotype.rb +95 -93
  334. data/lib/xmi/uml13/stereotypebase_class.rb +7 -5
  335. data/lib/xmi/uml13/stereotypeextended_element.rb +7 -5
  336. data/lib/xmi/uml13/stereotypeicon.rb +7 -5
  337. data/lib/xmi/uml13/stereotyperequired_tag.rb +7 -5
  338. data/lib/xmi/uml13/stereotypestereotype_constraint.rb +7 -5
  339. data/lib/xmi/uml13/structural_feature.rb +86 -84
  340. data/lib/xmi/uml13/structural_featurechangeable.rb +6 -4
  341. data/lib/xmi/uml13/structural_featuremultiplicity.rb +7 -5
  342. data/lib/xmi/uml13/structural_featuretarget_scope.rb +6 -4
  343. data/lib/xmi/uml13/structural_featuretype.rb +7 -5
  344. data/lib/xmi/uml13/structure.rb +113 -111
  345. data/lib/xmi/uml13/submachine_state.rb +88 -86
  346. data/lib/xmi/uml13/submachine_statestate_machine.rb +7 -5
  347. data/lib/xmi/uml13/subsystem.rb +115 -113
  348. data/lib/xmi/uml13/subsystemis_instantiable.rb +6 -4
  349. data/lib/xmi/uml13/tagged_value.rb +24 -22
  350. data/lib/xmi/uml13/tagged_valuemodel_element.rb +7 -5
  351. data/lib/xmi/uml13/tagged_valuestereotype.rb +7 -5
  352. data/lib/xmi/uml13/tagged_valuetag.rb +7 -5
  353. data/lib/xmi/uml13/tagged_valuevalue.rb +7 -5
  354. data/lib/xmi/uml13/terminate_action.rb +86 -84
  355. data/lib/xmi/uml13/time_event.rb +73 -71
  356. data/lib/xmi/uml13/time_eventduration.rb +7 -5
  357. data/lib/xmi/uml13/time_expression.rb +18 -16
  358. data/lib/xmi/uml13/trace.rb +79 -77
  359. data/lib/xmi/uml13/transition.rb +84 -82
  360. data/lib/xmi/uml13/transitioneffect.rb +7 -5
  361. data/lib/xmi/uml13/transitionguard.rb +7 -5
  362. data/lib/xmi/uml13/transitionsource.rb +7 -5
  363. data/lib/xmi/uml13/transitionstate.rb +7 -5
  364. data/lib/xmi/uml13/transitionstatemachine.rb +7 -5
  365. data/lib/xmi/uml13/transitiontarget.rb +7 -5
  366. data/lib/xmi/uml13/transitiontrigger.rb +7 -5
  367. data/lib/xmi/uml13/uninterpreted_action.rb +89 -87
  368. data/lib/xmi/uml13/uninterpreted_actionbody.rb +7 -5
  369. data/lib/xmi/uml13/usage.rb +79 -77
  370. data/lib/xmi/uml13/use_case.rb +116 -114
  371. data/lib/xmi/uml13/use_case_instance.rb +85 -83
  372. data/lib/xmi/uml13/use_caseextension_point.rb +7 -5
  373. data/lib/xmi/uml13/use_cases.rb +16 -14
  374. data/lib/xmi/uml13/view_element.rb +18 -16
  375. data/lib/xmi/uml13/view_elementmodel.rb +7 -5
  376. data/lib/xmi/uml13/view_elementpresentation.rb +7 -5
  377. data/lib/xmi/uml13/xm_iextension.rb +11 -9
  378. data/lib/xmi/uml13/xm_ireference.rb +6 -4
  379. data/lib/xmi/uml13.rb +2 -0
  380. data/lib/xmi/version.rb +1 -1
  381. data/lib/xmi.rb +10 -0
  382. data/xmi.gemspec +2 -2
  383. metadata +10 -22
  384. data/.github/workflows/main.yml +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa4e27e664d57a10744a5226b3aef8dfd3458e55aa95e83654bc0898b2426f18
4
- data.tar.gz: f54767772c17fda9edaad58d8b899f9f0dac4f735a60cddbefe75ed6c3171092
3
+ metadata.gz: a6e11e8807b6e645ac8d6a3316ad055e34214aaa747925ee134ed6b5fd3a1cae
4
+ data.tar.gz: 0515d55369b0d206204e957d0cf0f835784d527fb8d658cdb06a1a43b66c2f8f
5
5
  SHA512:
6
- metadata.gz: a65fc0ccd4efb06fc11cd74294a11dd00ab458a70feaa13d619af7c962aea887cac053e70b59fcaacc4b98b9688f719f4013aafa56e4dcfed05e0d6e791e2b69
7
- data.tar.gz: f4e1bba099780038cac95ee69096b8fa052d2a53533c74d2894c36b8cc3419a99fe0ec302e161ff94259543f16b94641dcaf62dc2a2347a0ecb7794ad58ea514
6
+ metadata.gz: 5aa1d6b95aecb8e28587b8072268ad3b058bb3db819ec5fd3fe9d1d05a74affe81ddd1dfe7be9314a5e275f4e21db7006a2980c1687284a437ccaaf9d3e1c62a
7
+ data.tar.gz: d423ab53b4a06d9de7728a4c301d4861b218c1c512ab6745b51a2e3ecc0f18ac0335f8ee4ad157412576d28245188d69c1c87e590b47317de8207b54023a2602
@@ -0,0 +1,14 @@
1
+ name: rake
2
+
3
+ on:
4
+ push:
5
+ branches: [ master, main ]
6
+ tags: [ v* ]
7
+ pull_request:
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ rake:
12
+ uses: metanorma/ci/.github/workflows/graphviz-rake.yml@main
13
+ secrets:
14
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -0,0 +1,22 @@
1
+ name: release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ next_version:
7
+ description: |
8
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
9
+ required: true
10
+ default: 'skip'
11
+ push:
12
+ tags: [ v* ]
13
+
14
+ jobs:
15
+ release:
16
+ uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
17
+ with:
18
+ next_version: ${{ github.event.inputs.next_version }}
19
+ secrets:
20
+ rubygems-api-key: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }}
21
+ pat_token: ${{ secrets.LUTAML_CI_PAT_TOKEN }}
22
+
data/.rubocop.yml CHANGED
@@ -1,8 +1,14 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.0
3
+ Exclude:
4
+ - "lib/xmi/uml13/**/*.rb"
5
+ - "vendor/bundle/**/*"
3
6
 
4
7
  Style/StringLiterals:
5
8
  EnforcedStyle: double_quotes
6
9
 
7
10
  Style/StringLiteralsInInterpolation:
8
11
  EnforcedStyle: double_quotes
12
+
13
+ Documentation:
14
+ Enabled: false
data/README.adoc CHANGED
@@ -1,5 +1,90 @@
1
- = XMI: OMG XMI parser
1
+ = XMI
2
2
 
3
3
  == Purpose
4
4
 
5
- This parser provides a Ruby interface to OMG XMI (2.5.2) files.
5
+ This Ruby object mapper is a module designed to convert XMI (XML Metadata Interchange) files into Ruby objects. It can also leverage the `nokogiri` gem for XML parsing and provides methods to dynamically generate Ruby classes and modules based on the XML structure, particularly those related to EA (Enterprise Architect) MDG (Model Driven Generation) extensions.
6
+
7
+ == Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ [source,ruby]
12
+ ----
13
+ gem "xmi"
14
+ ----
15
+
16
+ And then execute:
17
+
18
+ [source,shell]
19
+ ----
20
+ $ bundle install
21
+ ----
22
+
23
+ Or install it yourself as:
24
+
25
+ [source,shell]
26
+ ----
27
+ $ gem install xmi
28
+ ----
29
+
30
+ == Usage
31
+
32
+ === Convert XMI file into Ruby objects
33
+
34
+ To convert XMI file into Ruby objects, run:
35
+
36
+ [source,ruby]
37
+ ----
38
+ xml = "path/to/your/file.xmi"
39
+ xml_content = File.read(xml)
40
+ xmi_root_model = Xmi::Sparx::SparxRoot2013.from_xml(xml_content)
41
+ ----
42
+
43
+ This method takes the path to an XMI file and generate the Ruby objects.
44
+
45
+ === Loading MDG Extensions and Generate Ruby Classes and Modules Dynamically
46
+
47
+ To load an MDG extension from an XML file, use the `load_mdg_extension` method:
48
+
49
+ [source,ruby]
50
+ ----
51
+ Xmi::EaRoot.load_mdg_extension("path/to/your/mdg_extension.xml")
52
+
53
+ xml = "path/to/your/file.xmi"
54
+ xml_content = File.read(xml)
55
+ xmi_root_model = Xmi::Sparx::SparxRoot2013.from_xml(xml_content)
56
+ ----
57
+
58
+ `Xmi::EaRoot.load_mdg_extension` takes the path to an XML file and generate the
59
+ Ruby classes and modules defined in XML file dynamically.
60
+ Then, you can generate Ruby objects by `Xmi::Sparx::SparxRoot2013.from_xml`.
61
+
62
+ === Output Classes and Modules Generated from Extension into Ruby Files
63
+
64
+ You can also generate Ruby files directly from the XMI content:
65
+
66
+ [source,ruby]
67
+ ----
68
+ Xmi::EaRoot.load_extension(
69
+ input_xml_path: 'path/to/your/custom_extension.xml',
70
+ module_name: 'CustomModule'
71
+ )
72
+ Xmi::EaRoot.output_rb_file('path/to/output_file.rb')
73
+ ----
74
+
75
+ This approach allows you to save the dynamically generated Ruby code to a file for further use.
76
+
77
+ == Development
78
+
79
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
80
+
81
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
82
+
83
+
84
+ == Contributing
85
+
86
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/xmi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/xmi/blob/master/CODE_OF_CONDUCT.md).
87
+
88
+ == Code of Conduct
89
+
90
+ Everyone interacting in the Xmi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/xmi/blob/master/CODE_OF_CONDUCT.md).
@@ -25,14 +25,14 @@ module Xmi
25
25
 
26
26
  xml do
27
27
  root "Documentation"
28
- namespace "http://www.omg.org/spec/XMI/20131001", "xmlns"
28
+ namespace "http://www.omg.org/spec/XMI/20131001", "xmi"
29
29
 
30
- map_attribute "id", to: :id, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
31
- map_attribute "label", to: :label, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
32
- map_attribute "uuid", to: :uuid, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
30
+ map_attribute "id", to: :id
31
+ map_attribute "label", to: :label
32
+ map_attribute "uuid", to: :uuid
33
33
  map_attribute "href", to: :href
34
- map_attribute "idref", to: :idref, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
35
- map_attribute "type", to: :type, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
34
+ map_attribute "idref", to: :idref
35
+ map_attribute "type", to: :type
36
36
  map_attribute "exporter", to: :exporter
37
37
  map_attribute "exporterVersion", to: :exporter_version
38
38
  map_attribute "exporterID", to: :exporter_id
@@ -0,0 +1,316 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "nokogiri"
4
+
5
+ module Xmi
6
+ class EaRoot # rubocop:disable Metrics/ClassLength
7
+ MODULE_TEMPLATE = <<~TEXT
8
+ module Xmi
9
+ class EaRoot
10
+ module #MODULE_NAME#
11
+ #KLASSES#
12
+ end
13
+ end
14
+ end
15
+ TEXT
16
+
17
+ KLASS_TEMPLATE = <<~TEXT
18
+ class #KLASS_NAME# < #FROM_KLASS#
19
+ #ROOT_TAG_LINE#
20
+
21
+ #ATTRIBUTES##XML_MAPPING#
22
+ end
23
+ TEXT
24
+
25
+ XML_MAPPING = <<~TEXT
26
+ xml do
27
+ root "#ROOT_TAG#"
28
+ #MAP_ATTRIBUTES#
29
+ end
30
+ TEXT
31
+
32
+ ATTRIBUTE_LINE = <<~TEXT
33
+ attribute :#TAG_NAME#, #ATTRIBUTE_TYPE#
34
+ TEXT
35
+
36
+ MAP_ATTRIBUTES = <<~TEXT
37
+ map_attribute "#ATTRIBUTE_NAME#", to: :#ATTRIBUTE_METHOD#
38
+ TEXT
39
+
40
+ MAP_ELEMENT = <<~TEXT
41
+ map_element "#ELEMENT_NAME#",
42
+ to: :#ELEMENT_METHOD#,
43
+ namespace: "#NAMESPACE#",
44
+ prefix: "#PREFIX#"
45
+ TEXT
46
+
47
+ class << self
48
+ def load_mdg_extension(xml_path)
49
+ options = {}
50
+ options[:input_xml_path] = xml_path
51
+ options[:module_name] = "Mdg"
52
+ load_extension(options)
53
+ update_mdg_mappings
54
+ end
55
+
56
+ def load_extension(options)
57
+ @content = gen_content(options)
58
+ Object.class_eval @content
59
+ end
60
+
61
+ def output_rb_file(output_rb_path)
62
+ File.open(output_rb_path, "w") { |file| file.write(@content) }
63
+ end
64
+
65
+ private
66
+
67
+ def update_mdg_mappings
68
+ mdg_klasses = all_mdg_klasses
69
+ map_elements = construct_shale_xml_mappings(mdg_klasses)
70
+ sparx_roots.each do |sparx_root|
71
+ update_shale_attributes(mdg_klasses, sparx_root)
72
+ update_shale_xml_mappings(map_elements, sparx_root)
73
+ end
74
+ end
75
+
76
+ def construct_shale_xml_mappings(mdg_klasses)
77
+ map_elements = []
78
+ mdg_klasses.each do |klass|
79
+ next unless Xmi::EaRoot::Mdg.const_get(klass).respond_to? :root_tag
80
+
81
+ map_elements << MAP_ELEMENT
82
+ .gsub("#ELEMENT_NAME#", Xmi::EaRoot::Mdg.const_get(klass).root_tag)
83
+ .gsub("#ELEMENT_METHOD#", Shale::Utils.snake_case(klass.to_s))
84
+ .gsub("#NAMESPACE#", @mdg_namespace[:uri])
85
+ .gsub("#PREFIX#", @mdg_namespace[:name])
86
+ end
87
+
88
+ map_elements
89
+ end
90
+
91
+ def update_shale_attributes(mdg_klasses, sparx_root)
92
+ mdg_klasses.each do |klass|
93
+ method_name = Shale::Utils.snake_case(klass)
94
+ full_klass_name = "Xmi::EaRoot::Mdg::#{klass}"
95
+
96
+ attr_line = "#{ATTRIBUTE_LINE.rstrip}, collection: true"
97
+ attr_line = attr_line
98
+ .gsub("#TAG_NAME#", method_name)
99
+ .gsub("#ATTRIBUTE_TYPE#", full_klass_name)
100
+
101
+ sparx_root.class_eval(attr_line)
102
+ end
103
+ end
104
+
105
+ def update_shale_xml_mappings(map_elements, sparx_root)
106
+ new_mapping = sparx_root.class_variable_get("@@default_mapping")
107
+ new_mapping += map_elements.join("\n")
108
+ sparx_root.class_variable_set("@@mapping", new_mapping) # rubocop:disable Style/ClassVars
109
+
110
+ new_mapping_block = proc do
111
+ eval sparx_root.class_variable_get("@@mapping") # rubocop:disable Security/Eval
112
+ end
113
+ new_mapping = proc { xml(&new_mapping_block) }
114
+ sparx_root.class_eval(&new_mapping)
115
+ end
116
+
117
+ def sparx_roots
118
+ [Xmi::Sparx::SparxRoot, Xmi::Sparx::SparxRoot2013]
119
+ end
120
+
121
+ def all_mdg_klasses
122
+ Xmi::EaRoot::Mdg.constants.select do |c|
123
+ Xmi::EaRoot::Mdg.const_get(c).is_a? Class
124
+ end
125
+ end
126
+
127
+ def get_abstract_klass_node(xmi_doc)
128
+ xmi_doc.at_xpath(
129
+ "//UMLProfiles//Stereotypes//Stereotype[@isAbstract='true']"
130
+ )
131
+ end
132
+
133
+ def get_klass_name_from_node(node)
134
+ node.attribute_nodes.find { |attr| attr.name == "name" }.value
135
+ end
136
+
137
+ def gen_map_attribute_line(attr_name, attr_method)
138
+ space_before = " " * 10
139
+ method_name = Shale::Utils.snake_case(attr_method)
140
+
141
+ map_attributes = MAP_ATTRIBUTES
142
+ .gsub("#ATTRIBUTE_NAME#", attr_name)
143
+ .gsub("#ATTRIBUTE_METHOD#", method_name)
144
+
145
+ "#{space_before}#{map_attributes}"
146
+ end
147
+
148
+ def gen_attribute_line(tag_name, attribute_type = "Shale::Type::String")
149
+ tag_name = Shale::Utils.snake_case(tag_name)
150
+ space_before = " " * 8
151
+
152
+ attribute_line = ATTRIBUTE_LINE
153
+ .gsub("#TAG_NAME#", tag_name)
154
+ .gsub("#ATTRIBUTE_TYPE#", attribute_type)
155
+
156
+ "#{space_before}#{attribute_line}"
157
+ end
158
+
159
+ def get_tag_name(tag)
160
+ tag.attribute_nodes.find { |attr| attr.name == "name" }.value
161
+ end
162
+
163
+ def gen_tags(node)
164
+ tags = node.search("Tag")
165
+ attributes_lines = ""
166
+
167
+ tags.each do |tag|
168
+ tag_name = get_tag_name(tag)
169
+ attributes_lines += gen_attribute_line(tag_name)
170
+ end
171
+
172
+ [attributes_lines, tags]
173
+ end
174
+
175
+ def gen_abstract_klass
176
+ attributes_lines = ""
177
+ tags_lines, @abstract_tags = gen_tags(@abstract_klass_node)
178
+ attributes_lines += tags_lines
179
+ klass_name = get_klass_name_from_node(@abstract_klass_node)
180
+
181
+ KLASS_TEMPLATE
182
+ .gsub("#KLASS_NAME#", Shale::Utils.classify(klass_name))
183
+ .gsub("#FROM_KLASS#", "Shale::Mapper")
184
+ .gsub("#ATTRIBUTES#", attributes_lines.rstrip)
185
+ .gsub("#XML_MAPPING#", "")
186
+ .gsub("#ROOT_TAG_LINE#", "")
187
+ end
188
+
189
+ def gen_apply_types(node)
190
+ apply_types_lines = ""
191
+ apply_types_nodes = node.search("Apply")
192
+ apply_types_nodes.each do |n|
193
+ apply_types = n.attribute_nodes.map(&:value)
194
+ apply_types.each do |apply_type|
195
+ tag_name = "base_#{apply_type}"
196
+ apply_types_lines += gen_attribute_line(tag_name)
197
+ end
198
+ end
199
+
200
+ [apply_types_lines, apply_types_nodes]
201
+ end
202
+
203
+ def gen_generic_klass(node)
204
+ node_name = get_klass_name_from_node(node)
205
+ attributes_lines, map_attributes_lines = gen_klass_tags(node)
206
+ apply_types_lines, apply_types_nodes = gen_apply_types(node)
207
+ attributes_lines, map_attributes_lines = gen_klass_apply_types(
208
+ attributes_lines, map_attributes_lines,
209
+ apply_types_lines, apply_types_nodes
210
+ )
211
+
212
+ xml_mapping = replace_xml_mapping(node_name, map_attributes_lines)
213
+
214
+ replace_klass_template(node_name, attributes_lines, xml_mapping)
215
+ end
216
+
217
+ def gen_klass_apply_types(attributes_lines, map_attributes_lines, apply_types_lines, apply_types_nodes)
218
+ unless apply_types_nodes.empty?
219
+ attributes_lines += apply_types_lines
220
+ apply_types_nodes.each do |n|
221
+ apply_types = n.attribute_nodes.map(&:value)
222
+ apply_types.each do |apply_type|
223
+ map_attributes_lines += gen_map_attribute_line("base_#{apply_type}", "base_#{apply_type}")
224
+ end
225
+ end
226
+ end
227
+
228
+ [attributes_lines, map_attributes_lines]
229
+ end
230
+
231
+ def gen_klass_tags(node)
232
+ attributes_lines = ""
233
+ map_attributes_lines = ""
234
+
235
+ tags_lines, tags = gen_tags(node)
236
+ attributes_lines += tags_lines
237
+ (@abstract_tags + tags).each do |tag|
238
+ tag_name = get_tag_name(tag)
239
+ map_attributes_lines += gen_map_attribute_line(tag_name, tag_name)
240
+ end
241
+
242
+ [attributes_lines, map_attributes_lines]
243
+ end
244
+
245
+ def replace_xml_mapping(node_name, map_attributes_lines)
246
+ XML_MAPPING
247
+ .gsub("#ROOT_TAG#", node_name)
248
+ .gsub("#MAP_ATTRIBUTES#", "\n#{map_attributes_lines.rstrip}")
249
+ .rstrip
250
+ end
251
+
252
+ def replace_klass_template(node_name, attributes_lines, xml_mapping)
253
+ abstract_klass_name = get_klass_name_from_node(@abstract_klass_node)
254
+ root_tag_line = "def self.root_tag; \"#{node_name}\"; end"
255
+
256
+ KLASS_TEMPLATE
257
+ .gsub("#KLASS_NAME#", Shale::Utils.classify(node_name))
258
+ .gsub("#FROM_KLASS#", Shale::Utils.classify(abstract_klass_name))
259
+ .gsub("#ROOT_TAG_LINE#", root_tag_line)
260
+ .gsub("#ATTRIBUTES#", attributes_lines.rstrip)
261
+ .gsub("#XML_MAPPING#", "\n\n#{xml_mapping}")
262
+ end
263
+
264
+ def gen_generic_klasses(xmi_doc)
265
+ nodes = xmi_doc.xpath("//UMLProfiles//Stereotypes//Stereotype[not(contains(@isAbstract, 'true'))]")
266
+ klasses_lines = ""
267
+
268
+ nodes.each do |node|
269
+ # check baseStereotypes is abstract class
270
+ base_stereotypes = node.attribute_nodes.find do |attr|
271
+ attr.name == "baseStereotypes" && attr.value == get_klass_name_from_node(@abstract_klass_node)
272
+ end
273
+ next if base_stereotypes.nil?
274
+
275
+ klasses_lines += "#{gen_generic_klass(node)}\n"
276
+ end
277
+
278
+ klasses_lines
279
+ end
280
+
281
+ def gen_klasses(xmi_doc)
282
+ @abstract_klass_node = get_abstract_klass_node(xmi_doc)
283
+ klasses_lines = ""
284
+ klasses_lines += "#{gen_abstract_klass}\n"
285
+ klasses_lines += gen_generic_klasses(xmi_doc).rstrip
286
+ klasses_lines
287
+ end
288
+
289
+ def gen_module(xmi_doc, module_name)
290
+ MODULE_TEMPLATE
291
+ .gsub("#MODULE_NAME#", module_name)
292
+ .gsub("#KLASSES#", gen_klasses(xmi_doc))
293
+ end
294
+
295
+ def get_mdg_namespace(xmi_doc)
296
+ node = xmi_doc.at_xpath("//UMLProfile/Documentation")
297
+ namespace_key = node.attribute_nodes.find do |attr|
298
+ attr.name == "name"
299
+ end.value
300
+ namespace_uri = node.attribute_nodes.find do |attr|
301
+ attr.name == "URI"
302
+ end.value
303
+
304
+ { name: namespace_key, uri: namespace_uri }
305
+ end
306
+
307
+ def gen_content(options)
308
+ xml = options[:input_xml_path]
309
+ module_name = options[:module_name].capitalize
310
+ xmi_doc = Nokogiri::XML(File.open(xml).read)
311
+ @mdg_namespace = get_mdg_namespace(xmi_doc)
312
+ gen_module(xmi_doc, module_name)
313
+ end
314
+ end
315
+ end
316
+ end
data/lib/xmi/extension.rb CHANGED
@@ -17,12 +17,12 @@ module Xmi
17
17
  root "Extension"
18
18
  namespace "http://www.omg.org/spec/XMI/20131001", "xmi"
19
19
 
20
- map_attribute "id", to: :id, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
21
- map_attribute "label", to: :label, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
22
- map_attribute "uuid", to: :uuid, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
20
+ map_attribute "id", to: :id
21
+ map_attribute "label", to: :label
22
+ map_attribute "uuid", to: :uuid
23
23
  map_attribute "href", to: :href
24
- map_attribute "idref", to: :idref, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
25
- map_attribute "type", to: :type, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
24
+ map_attribute "idref", to: :idref
25
+ map_attribute "type", to: :type
26
26
  map_attribute "extender", to: :extender
27
27
  map_attribute "extenderID", to: :extender_id
28
28
  end
data/lib/xmi/root.rb CHANGED
@@ -5,38 +5,61 @@ require_relative "documentation"
5
5
  require_relative "uml"
6
6
 
7
7
  module Xmi
8
+ module RootAttributes
9
+ def self.included(klass)
10
+ klass.class_eval do
11
+ attribute :id, Shale::Type::String
12
+ attribute :label, Shale::Type::String
13
+ attribute :uuid, Shale::Type::String
14
+ attribute :href, Shale::Type::String
15
+ attribute :idref, Shale::Type::String
16
+ attribute :type, Shale::Type::String
17
+ attribute :documentation, Documentation
18
+ end
19
+ end
20
+ end
21
+
8
22
  class Root < Shale::Mapper
9
- attribute :id, Shale::Type::String
10
- attribute :label, Shale::Type::String
11
- attribute :uuid, Shale::Type::String
12
- attribute :href, Shale::Type::String
13
- attribute :idref, Shale::Type::String
14
- attribute :type, Shale::Type::String
15
- attribute :documentation, Documentation
23
+ include RootAttributes
16
24
  attribute :model, Uml::UmlModel
17
- attribute :extension, Extension
18
25
 
19
26
  xml do
20
27
  root "XMI"
21
28
  namespace "http://www.omg.org/spec/XMI/20131001", "xmi"
22
29
 
23
- map_attribute "id", to: :id, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
24
- map_attribute "label", to: :label, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
25
- map_attribute "uuid", to: :uuid, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
26
- map_attribute "href", to: :href
27
- map_attribute "idref", to: :idref, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
28
- map_attribute "type", to: :type, prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
29
-
30
- map_element "Documentation", to: :documentation,
31
- prefix: "xmi", namespace: "http://www.omg.org/spec/XMI/20131001"
30
+ map_attribute "id", to: :id
31
+ map_attribute "label", to: :label
32
+ map_attribute "uuid", to: :uuid
33
+ map_attribute "href", to: :href, namespace: nil, prefix: nil
34
+ map_attribute "idref", to: :idref
35
+ map_attribute "type", to: :type
32
36
 
37
+ map_element "Documentation", to: :documentation
33
38
  map_element "Model", to: :model,
34
39
  namespace: "http://www.omg.org/spec/UML/20161101",
35
40
  prefix: "uml"
41
+ end
42
+ end
43
+
44
+ class Root2013 < Shale::Mapper
45
+ include RootAttributes
46
+ attribute :model, Uml::UmlModel2013
36
47
 
37
- map_element "Extension", to: :extension,
38
- namespace: "http://www.omg.org/spec/XMI/20131001",
39
- prefix: "xmi"
48
+ xml do
49
+ root "XMI"
50
+ namespace "http://www.omg.org/spec/XMI/20131001", "xmi"
51
+
52
+ map_attribute "id", to: :id
53
+ map_attribute "label", to: :label
54
+ map_attribute "uuid", to: :uuid
55
+ map_attribute "href", to: :href, namespace: nil, prefix: nil
56
+ map_attribute "idref", to: :idref
57
+ map_attribute "type", to: :type
58
+
59
+ map_element "Documentation", to: :documentation
60
+ map_element "Model", to: :model,
61
+ namespace: "http://www.omg.org/spec/UML/20131001",
62
+ prefix: "uml"
40
63
  end
41
64
  end
42
65
  end
data/lib/xmi/root13.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  require "shale"
4
4
 
5
5
  module Xmi
6
-
7
6
  # OMG 1.3
8
7
  class EaXmiHeaderDocumentation < Shale::Mapper
9
8
  attribute :exporter, Shale::Type::String