lutaml-uml 0.1.0 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +38 -0
  3. data/.github/workflows/ubuntu.yml +40 -0
  4. data/.github/workflows/windows.yml +51 -0
  5. data/.gitignore +1 -0
  6. data/Gemfile +2 -1
  7. data/LUTAML.adoc +339 -0
  8. data/{README.md → README.adoc} +15 -16
  9. data/Rakefile +3 -1
  10. data/bin/console +1 -0
  11. data/bin/folder_yaml2lutaml.sh +6 -0
  12. data/bin/plantuml2lutaml +58 -0
  13. data/bin/yaml2lutaml +144 -0
  14. data/exe/lutaml-uml +4 -3
  15. data/lib/lutaml/layout/engine.rb +15 -0
  16. data/lib/lutaml/layout/graph_viz_engine.rb +19 -0
  17. data/lib/lutaml/uml.rb +4 -0
  18. data/lib/lutaml/uml/abstraction.rb +7 -5
  19. data/lib/lutaml/uml/activity.rb +7 -5
  20. data/lib/lutaml/uml/actor.rb +14 -12
  21. data/lib/lutaml/uml/association.rb +40 -14
  22. data/lib/lutaml/uml/behavior.rb +7 -5
  23. data/lib/lutaml/uml/class.rb +61 -16
  24. data/lib/lutaml/uml/classifier.rb +9 -6
  25. data/lib/lutaml/uml/connector.rb +16 -12
  26. data/lib/lutaml/uml/constraint.rb +8 -7
  27. data/lib/lutaml/uml/constructor_end.rb +11 -8
  28. data/lib/lutaml/uml/data_type.rb +12 -4
  29. data/lib/lutaml/uml/dependency.rb +16 -13
  30. data/lib/lutaml/uml/document.rb +71 -0
  31. data/lib/lutaml/uml/enum.rb +40 -0
  32. data/lib/lutaml/uml/event.rb +7 -5
  33. data/lib/lutaml/uml/final_state.rb +7 -5
  34. data/lib/lutaml/uml/formatter.rb +21 -0
  35. data/lib/lutaml/uml/formatter/base.rb +67 -0
  36. data/lib/lutaml/uml/formatter/graphviz.rb +334 -0
  37. data/lib/lutaml/uml/has_attributes.rb +14 -0
  38. data/lib/lutaml/uml/has_members.rb +30 -0
  39. data/lib/lutaml/uml/instance.rb +15 -10
  40. data/lib/lutaml/uml/interface/base.rb +28 -0
  41. data/lib/lutaml/uml/interface/command_line.rb +265 -0
  42. data/lib/lutaml/uml/lutaml_path/document_wrapper.rb +15 -0
  43. data/lib/lutaml/uml/model.rb +11 -8
  44. data/lib/lutaml/uml/node/base.rb +21 -0
  45. data/lib/lutaml/uml/node/class_node.rb +57 -0
  46. data/lib/lutaml/uml/node/class_relationship.rb +14 -0
  47. data/lib/lutaml/uml/node/document.rb +18 -0
  48. data/lib/lutaml/uml/node/field.rb +34 -0
  49. data/lib/lutaml/uml/node/has_name.rb +15 -0
  50. data/lib/lutaml/uml/node/has_type.rb +15 -0
  51. data/lib/lutaml/uml/node/method.rb +29 -0
  52. data/lib/lutaml/uml/node/method_argument.rb +16 -0
  53. data/lib/lutaml/uml/node/relationship.rb +28 -0
  54. data/lib/lutaml/uml/opaque_behavior.rb +7 -6
  55. data/lib/lutaml/uml/package.rb +16 -13
  56. data/lib/lutaml/uml/parsers/attribute.rb +70 -0
  57. data/lib/lutaml/uml/parsers/dsl.rb +399 -0
  58. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +44 -0
  59. data/lib/lutaml/uml/parsers/dsl_transform.rb +27 -0
  60. data/lib/lutaml/uml/parsers/yaml.rb +46 -0
  61. data/lib/lutaml/uml/port.rb +6 -4
  62. data/lib/lutaml/uml/primitive_type.rb +11 -3
  63. data/lib/lutaml/uml/property.rb +25 -15
  64. data/lib/lutaml/uml/pseudostate.rb +7 -6
  65. data/lib/lutaml/uml/realization.rb +7 -5
  66. data/lib/lutaml/uml/region.rb +7 -6
  67. data/lib/lutaml/uml/serializers/association.rb +58 -0
  68. data/lib/lutaml/uml/serializers/base.rb +16 -0
  69. data/lib/lutaml/uml/serializers/class.rb +29 -0
  70. data/lib/lutaml/uml/serializers/top_element_attribute.rb +14 -0
  71. data/lib/lutaml/uml/serializers/yaml_view.rb +18 -0
  72. data/lib/lutaml/uml/state.rb +8 -6
  73. data/lib/lutaml/uml/state_machine.rb +7 -5
  74. data/lib/lutaml/uml/top_element.rb +45 -35
  75. data/lib/lutaml/uml/top_element_attribute.rb +26 -0
  76. data/lib/lutaml/uml/transition.rb +8 -6
  77. data/lib/lutaml/uml/trigger.rb +8 -6
  78. data/lib/lutaml/uml/version.rb +3 -1
  79. data/lib/lutaml/uml/vertex.rb +7 -5
  80. data/lutaml-uml.gemspec +11 -3
  81. data/spec/fixtures/datamodel/models/AddressClassProfile.yml +90 -0
  82. data/spec/fixtures/datamodel/models/AddressComponentProfile.yml +63 -0
  83. data/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +15 -0
  84. data/spec/fixtures/datamodel/models/AddressProfile.yml +36 -0
  85. data/spec/fixtures/datamodel/models/AttributeProfile.yml +32 -0
  86. data/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +79 -0
  87. data/spec/fixtures/datamodel/models/Localization copy.yml +23 -0
  88. data/spec/fixtures/datamodel/models/Localization.yml +23 -0
  89. data/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +36 -0
  90. data/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +15 -0
  91. data/spec/fixtures/datamodel/models/Signature.yml +20 -0
  92. data/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +20 -0
  93. data/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +16 -0
  94. data/spec/fixtures/datamodel/models/TextDirectionCode.yml +16 -0
  95. data/spec/fixtures/datamodel/models/Validity.yml +14 -0
  96. data/spec/fixtures/datamodel/models/iso19160-1/Address.yml +22 -0
  97. data/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +2 -0
  98. data/spec/fixtures/datamodel/style.uml.inc +37 -0
  99. data/spec/fixtures/datamodel/views/AddressClassProfile.yml +12 -0
  100. data/spec/fixtures/datamodel/views/AddressProfile.yml +3 -0
  101. data/spec/fixtures/datamodel/views/CommonModels.yml +9 -0
  102. data/spec/fixtures/datamodel/views/TopDown.yml +62 -0
  103. data/spec/fixtures/dsl/diagram.lutaml +3 -0
  104. data/spec/fixtures/dsl/diagram_attributes.lutaml +5 -0
  105. data/spec/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
  106. data/spec/fixtures/dsl/diagram_class_fields.lutaml +19 -0
  107. data/spec/fixtures/dsl/diagram_comments.lutaml +28 -0
  108. data/spec/fixtures/dsl/diagram_concept_model.lutaml +132 -0
  109. data/spec/fixtures/dsl/diagram_data_types.lutaml +24 -0
  110. data/spec/fixtures/dsl/diagram_definitions.lutaml +20 -0
  111. data/spec/fixtures/dsl/diagram_includes.lutaml +6 -0
  112. data/spec/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
  113. data/spec/fixtures/dsl/shared.lutaml +3 -0
  114. data/spec/fixtures/dsl/shared1.lutaml +4 -0
  115. data/spec/fixtures/generated_dot/AddressClassProfile.dot +170 -0
  116. data/spec/fixtures/generated_dot/AddressProfile.dot +34 -0
  117. data/spec/lutaml/layout/graph_viz_engine_spec.rb +31 -0
  118. data/spec/lutaml/uml/formatter/graphviz_spec.rb +41 -0
  119. data/spec/lutaml/uml/parsers/dsl_spec.rb +276 -0
  120. data/spec/lutaml/uml/parsers/yaml_spec.rb +18 -0
  121. data/spec/lutaml/uml/serializers/yaml_view_spec.rb +20 -0
  122. data/spec/lutaml/uml_spec.rb +2 -4
  123. data/spec/spec_helper.rb +11 -0
  124. metadata +182 -17
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class Behavior < Class
6
+ module Lutaml
7
+ module Uml
8
+ class Behavior < Class
9
+ end
10
+ end
7
11
  end
8
-
9
- end
@@ -1,17 +1,62 @@
1
- module Lutaml::Uml
2
-
3
- class Class < Classifier
4
- attr_accessor :nested_classifier, :is_abstract
5
- def initialize
6
- @name = nil
7
- @xmi_id = nil
8
- @xmi_uuid = nil
9
- @nested_classifier = []
10
- @stereotype = []
11
- @generalization = []
12
- @namespace = nil
13
- @is_abstract = false
14
- end
15
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/uml/has_members"
4
+ require "lutaml/uml/classifier"
5
+ require "lutaml/uml/association"
6
+ require "lutaml/uml/top_element_attribute"
7
+
8
+ module Lutaml
9
+ module Uml
10
+ class Class < Classifier
11
+ include HasMembers
12
+
13
+ attr_accessor :nested_classifier,
14
+ :is_abstract,
15
+ :type
16
+
17
+ attr_reader :associations,
18
+ :attributes,
19
+ :definition,
20
+ :members,
21
+ :modifier
22
+
23
+ def initialize(attributes = {})
24
+ @nested_classifier = []
25
+ @stereotype = []
26
+ @generalization = []
27
+ @is_abstract = false
28
+ super
29
+ end
16
30
 
17
- end
31
+ def modifier=(value)
32
+ @modifier = value.to_s # TODO: Validate?
33
+ end
34
+
35
+ def definition=(value)
36
+ @definition = value.to_s
37
+ end
38
+
39
+ def attributes=(value)
40
+ @attributes = value.to_a.map do |attr|
41
+ TopElementAttribute.new(attr)
42
+ end
43
+ end
44
+
45
+ def associations=(value)
46
+ @associations = value.to_a.map do |attr|
47
+ Association.new(attr.to_h.merge(owner_end: name))
48
+ end
49
+ end
50
+
51
+ def methods
52
+ # @members&.select { |member| member.class == Method }
53
+ []
54
+ end
55
+
56
+ def relationships
57
+ # @members&.select { |member| member.class == ClassRelationship }
58
+ []
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,8 +1,11 @@
1
- module Lutaml::Uml
2
-
3
- class Classifier < TopElement
4
- attr_accessor :generalization
5
- end
1
+ # frozen_string_literal: true
6
2
 
3
+ require "lutaml/uml/top_element"
7
4
 
8
- end
5
+ module Lutaml
6
+ module Uml
7
+ class Classifier < TopElement
8
+ attr_accessor :generalization
9
+ end
10
+ end
11
+ end
@@ -1,17 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class Connector < TopElement
7
- attr_accessor :kind, :connector_end
8
- def initialize
9
- @name = nil
10
- @xmi_id = nil
11
- @xmi_uuid = nil
12
- @connector_end = []
13
- @namespace = nil
14
- @kind = nil
15
- end
6
+ module Lutaml
7
+ module Uml
8
+ class Connector < TopElement
9
+ attr_accessor :kind, :connector_end
16
10
 
11
+ def initialize
12
+ @name = nil
13
+ @xmi_id = nil
14
+ @xmi_uuid = nil
15
+ @connector_end = []
16
+ @namespace = nil
17
+ @kind = nil
18
+ end
19
+ end
20
+ end
17
21
  end
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class Constraint < TopElement
7
- attr_accessor :body
8
- end
9
-
10
-
6
+ module Lutaml
7
+ module Uml
8
+ class Constraint < TopElement
9
+ attr_accessor :body
10
+ end
11
+ end
11
12
  end
@@ -1,13 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
6
+ module Lutaml
7
+ module Uml
8
+ class ConnectorEnd < TopElement
9
+ attr_accessor :role, :part_with_port, :connector
5
10
 
6
- class ConnectorEnd < TopElement
7
- attr_accessor :role, :part_with_port, :connector
8
- def initialize
9
- @role = nil
10
- end
11
+ def initialize
12
+ @role = nil
13
+ end
14
+ end
15
+ end
11
16
  end
12
-
13
- end
@@ -1,6 +1,14 @@
1
- module Lutaml::Uml
1
+ # frozen_string_literal: true
2
2
 
3
- class DataType < Class
4
- end
3
+ module Lutaml
4
+ module Uml
5
+ class DataType < Class
6
+ attr_reader :keyword
5
7
 
6
- end
8
+ def initialize(attributes = {})
9
+ super
10
+ @keyword = "dataType"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,18 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class Dependency < TopElement
7
- attr_accessor :client, :supplier
8
- def initialize
9
- @name = nil
10
- @xmi_id = nil
11
- @xmi_uuid = nil
12
- @client = []
13
- @supplier = []
14
- @namespace = nil
15
- end
16
- end
6
+ module Lutaml
7
+ module Uml
8
+ class Dependency < TopElement
9
+ attr_accessor :client, :supplier
17
10
 
11
+ def initialize
12
+ @name = nil
13
+ @xmi_id = nil
14
+ @xmi_uuid = nil
15
+ @client = []
16
+ @supplier = []
17
+ @namespace = nil
18
+ end
19
+ end
20
+ end
18
21
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/uml/class"
4
+ require "lutaml/uml/enum"
5
+ require "lutaml/uml/data_type"
6
+ require "lutaml/uml/primitive_type"
7
+
8
+ module Lutaml
9
+ module Uml
10
+ class Document
11
+ include HasAttributes
12
+ include HasMembers
13
+
14
+ attr_accessor :name,
15
+ :title,
16
+ :caption,
17
+ :groups,
18
+ :fidelity,
19
+ :fontname,
20
+ :comments
21
+
22
+ # rubocop:disable Rails/ActiveRecordAliases
23
+ def initialize(attributes = {})
24
+ update_attributes(attributes)
25
+ end
26
+ # rubocop:enable Rails/ActiveRecordAliases
27
+
28
+ def classes=(value)
29
+ @classes = value.to_a.map { |attributes| Class.new(attributes) }
30
+ end
31
+
32
+ def enums=(value)
33
+ @enums = value.to_a.map { |attributes| Enum.new(attributes) }
34
+ end
35
+
36
+ def data_types=(value)
37
+ @data_types = value.to_a.map { |attributes| DataType.new(attributes) }
38
+ end
39
+
40
+ def primitives=(value)
41
+ @primitives = value.to_a.map { |attributes| PrimitiveType.new(attributes) }
42
+ end
43
+
44
+ def associations=(value)
45
+ @associations = value.to_a.map do |attributes|
46
+ Association.new(attributes)
47
+ end
48
+ end
49
+
50
+ def classes
51
+ @classes || []
52
+ end
53
+
54
+ def enums
55
+ @enums || []
56
+ end
57
+
58
+ def data_types
59
+ @data_types || []
60
+ end
61
+
62
+ def primitives
63
+ @primitives || []
64
+ end
65
+
66
+ def associations
67
+ @associations || []
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/uml/has_members"
4
+ require "lutaml/uml/classifier"
5
+ require "lutaml/uml/association"
6
+ require "lutaml/uml/top_element_attribute"
7
+
8
+ module Lutaml
9
+ module Uml
10
+ class Enum < Classifier
11
+ include HasMembers
12
+
13
+ attr_reader :attributes,
14
+ :members,
15
+ :modifier,
16
+ :definition,
17
+ :keyword
18
+
19
+ def initialize(attributes = {})
20
+ super
21
+ @keyword = "enumeration"
22
+ end
23
+
24
+ def attributes=(value)
25
+ @attributes = value.to_a.map do |attr|
26
+ TopElementAttribute.new(attr)
27
+ end
28
+ end
29
+
30
+ def definition=(value)
31
+ @definition = value.to_s
32
+ end
33
+
34
+ # TODO: reserved name, change
35
+ def methods
36
+ []
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
6
 
5
- module Lutaml::Uml
6
-
7
- class Event < TopElement
7
+ module Lutaml
8
+ module Uml
9
+ class Event < TopElement
10
+ end
11
+ end
8
12
  end
9
-
10
- end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class FinalState < State
7
- end
8
-
6
+ module Lutaml
7
+ module Uml
8
+ class FinalState < State
9
+ end
10
+ end
9
11
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ module Formatter
6
+ class << self
7
+ def all
8
+ @all ||= []
9
+ end
10
+
11
+ def find_by_name(name)
12
+ name = name.to_sym
13
+
14
+ all.detect { |formatter_class| formatter_class.name == name }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ require "lutaml/uml/formatter/graphviz"
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/uml/formatter"
4
+ require "lutaml/uml/has_attributes"
5
+
6
+ module Lutaml
7
+ module Uml
8
+ module Formatter
9
+ class Base
10
+ class << self
11
+ def inherited(subclass)
12
+ Formatter.all << subclass
13
+ end
14
+
15
+ def format(node, attributes = {})
16
+ new(attributes).format(node)
17
+ end
18
+
19
+ def name
20
+ to_s.split("::").last.downcase.to_sym
21
+ end
22
+ end
23
+
24
+ include HasAttributes
25
+
26
+ # rubocop:disable Rails/ActiveRecordAliases
27
+ def initialize(attributes = {})
28
+ update_attributes(attributes)
29
+ end
30
+ # rubocop:enable Rails/ActiveRecordAliases
31
+
32
+ def name
33
+ self.class.name
34
+ end
35
+
36
+ attr_reader :type
37
+
38
+ def type=(value)
39
+ @type = value.to_s.strip.downcase.to_sym
40
+ end
41
+
42
+ def format(node)
43
+ case node
44
+ when Node::Field then format_field(node)
45
+ when Node::Method then format_method(node)
46
+ when Node::Relationship then format_relationship(node)
47
+ when Node::ClassRelationship then format_class_relationship(node)
48
+ when Node::ClassNode then format_class(node)
49
+ when Lutaml::Uml::Document then format_document(node)
50
+ end
51
+ end
52
+
53
+ def format_field(_node); raise NotImplementedError; end
54
+
55
+ def format_method(_node); raise NotImplementedError; end
56
+
57
+ def format_relationship(_node); raise NotImplementedError; end
58
+
59
+ def format_class_relationship(_node); raise NotImplementedError; end
60
+
61
+ def format_class(_node); raise NotImplementedError; end
62
+
63
+ def format_document(_node); raise NotImplementedError; end
64
+ end
65
+ end
66
+ end
67
+ end