lutaml 0.9.39 → 0.9.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lutaml/command_line.rb +1 -1
  3. data/lib/lutaml/converter/dsl_to_uml.rb +235 -0
  4. data/lib/lutaml/converter/xmi_hash_to_uml.rb +196 -0
  5. data/lib/lutaml/formatter/base.rb +7 -7
  6. data/lib/lutaml/formatter/graphviz.rb +19 -8
  7. data/lib/lutaml/formatter.rb +0 -2
  8. data/lib/lutaml/parser.rb +1 -1
  9. data/lib/lutaml/uml/action.rb +15 -0
  10. data/lib/lutaml/uml/actor.rb +0 -8
  11. data/lib/lutaml/uml/association.rb +25 -34
  12. data/lib/lutaml/uml/cardinality.rb +10 -0
  13. data/lib/lutaml/uml/class.rb +43 -68
  14. data/lib/lutaml/uml/classifier.rb +5 -3
  15. data/lib/lutaml/uml/connector.rb +5 -8
  16. data/lib/lutaml/uml/connector_end.rb +20 -0
  17. data/lib/lutaml/uml/constraint.rb +11 -1
  18. data/lib/lutaml/uml/data_type.rb +48 -64
  19. data/lib/lutaml/uml/dependency.rb +5 -8
  20. data/lib/lutaml/uml/document.rb +46 -73
  21. data/lib/lutaml/uml/enum.rb +12 -35
  22. data/lib/lutaml/uml/event.rb +0 -1
  23. data/lib/lutaml/uml/fidelity.rb +10 -0
  24. data/lib/lutaml/uml/group.rb +17 -0
  25. data/lib/lutaml/uml/instance.rb +5 -7
  26. data/lib/lutaml/uml/model.rb +3 -3
  27. data/lib/lutaml/uml/namespace.rb +10 -0
  28. data/lib/lutaml/uml/node/base.rb +1 -1
  29. data/lib/lutaml/uml/operation.rb +6 -22
  30. data/lib/lutaml/uml/package.rb +23 -44
  31. data/lib/lutaml/uml/parsers/dsl.rb +5 -2
  32. data/lib/lutaml/uml/parsers/yaml.rb +2 -28
  33. data/lib/lutaml/uml/primitive_type.rb +3 -4
  34. data/lib/lutaml/uml/property.rb +15 -17
  35. data/lib/lutaml/uml/region.rb +0 -1
  36. data/lib/lutaml/uml/state.rb +9 -1
  37. data/lib/lutaml/uml/state_machine.rb +0 -1
  38. data/lib/lutaml/uml/top_element.rb +61 -39
  39. data/lib/lutaml/uml/top_element_attribute.rb +33 -22
  40. data/lib/lutaml/uml/transition.rb +11 -1
  41. data/lib/lutaml/uml/trigger.rb +5 -1
  42. data/lib/lutaml/uml/value.rb +18 -14
  43. data/lib/lutaml/uml.rb +40 -2
  44. data/lib/lutaml/version.rb +1 -1
  45. data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
  46. data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +2 -1
  47. data/lib/lutaml/xmi/parsers/xmi_base.rb +20 -2
  48. data/lib/lutaml/xmi/parsers/xml.rb +5 -4
  49. metadata +11 -13
  50. data/lib/lutaml/uml/constructor_end.rb +0 -16
  51. data/lib/lutaml/uml/formatter/base.rb +0 -67
  52. data/lib/lutaml/uml/formatter/graphviz.rb +0 -332
  53. data/lib/lutaml/uml/formatter.rb +0 -21
  54. data/lib/lutaml/uml/serializers/association.rb +0 -58
  55. data/lib/lutaml/uml/serializers/base.rb +0 -16
  56. data/lib/lutaml/uml/serializers/class.rb +0 -29
  57. data/lib/lutaml/uml/serializers/top_element_attribute.rb +0 -14
  58. data/lib/lutaml/uml/serializers/yaml_view.rb +0 -18
  59. data/lib/lutaml/uml/version.rb +0 -7
  60. /data/{lib/lutaml/uml/README.adoc → docs/UML_README.adoc} +0 -0
@@ -1,82 +1,57 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/uml/classifier"
4
-
5
- require "lutaml/uml/has_members"
3
+ require "lutaml/uml/package"
6
4
  require "lutaml/uml/association"
7
5
  require "lutaml/uml/constraint"
8
- require "lutaml/uml/data_type"
9
6
  require "lutaml/uml/operation"
10
- require "lutaml/uml/top_element_attribute"
7
+ require "lutaml/uml/data_type"
11
8
 
12
9
  module Lutaml
13
10
  module Uml
14
11
  class Class < Classifier
15
- include HasMembers
16
-
17
- attr_accessor :nested_classifier,
18
- :is_abstract,
19
- :type,
20
- :package
21
-
22
- attr_reader :associations,
23
- :attributes,
24
- :members,
25
- :modifier,
26
- :constraints,
27
- :operations,
28
- :data_types
29
-
30
- def initialize(attributes = {})
31
- @nested_classifier = []
32
- @stereotype = []
33
- @generalization = []
34
- @is_abstract = false
35
- super
36
- end
37
-
38
- def modifier=(value)
39
- @modifier = value.to_s # TODO: Validate?
40
- end
41
-
42
- def attributes=(value)
43
- @attributes = value.to_a.map do |attr|
44
- TopElementAttribute.new(attr)
45
- end
46
- end
47
-
48
- def associations=(value)
49
- @associations = value.to_a.map do |attr|
50
- Association.new(attr.to_h.merge(owner_end: name))
12
+ attribute :nested_classifier, :string, collection: true,
13
+ default: -> { [] }
14
+ attribute :is_abstract, :boolean, default: false
15
+ attribute :type, :string
16
+ attribute :package, Package
17
+ attribute :attributes, TopElementAttribute, collection: true
18
+ attribute :modifier, :string
19
+ attribute :constraints, Constraint, collection: true
20
+ attribute :operations, Operation, collection: true
21
+ attribute :data_types, DataType, collection: true
22
+ attribute :methods, :string, collection: true, default: -> { [] }
23
+
24
+ attribute :associations, Association, collection: true
25
+
26
+ yaml do
27
+ map "nested_classifier", to: :nested_classifier
28
+ map "is_abstract", to: :is_abstract
29
+ map "type", to: :type
30
+ map "package", to: :package
31
+ map "attributes", to: :attributes
32
+ map "modifier", to: :modifier
33
+ map "constraints", to: :constraints
34
+ map "operations", to: :operations
35
+ map "data_types", to: :data_types
36
+ map "methods", to: :methods
37
+
38
+ map "associations", to: :associations, with: {
39
+ to: :associations_to_yaml, from: :associations_from_yaml
40
+ }
41
+ end
42
+
43
+ def associations_to_yaml(model, doc)
44
+ associations = model.associations.map(&:to_hash)
45
+ doc["associations"] = associations unless associations.empty?
46
+ end
47
+
48
+ def associations_from_yaml(model, values)
49
+ associations = values.map do |value|
50
+ value["owner_end"] = model.name if value["owner_end"].nil?
51
+ Association.from_yaml(value.to_yaml)
51
52
  end
52
- end
53
-
54
- def constraints=(value)
55
- @constraints = value.to_a.map do |attr|
56
- Constraint.new(attr)
57
- end
58
- end
59
-
60
- def operations=(value)
61
- @operations = value.to_a.map do |attr|
62
- Operation.new(attr)
63
- end
64
- end
65
-
66
- def data_types=(value)
67
- @data_types = value.to_a.map do |attr|
68
- DataType.new(attr)
69
- end
70
- end
71
-
72
- def methods
73
- # @members&.select { |member| member.class == Method }
74
- []
75
- end
76
53
 
77
- def relationships
78
- # @members&.select { |member| member.class == ClassRelationship }
79
- []
54
+ model.associations = associations
80
55
  end
81
56
  end
82
57
  end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/uml/top_element"
4
-
5
3
  module Lutaml
6
4
  module Uml
7
5
  class Classifier < TopElement
8
- attr_accessor :generalization
6
+ attribute :generalization, :string, collection: true, default: -> { [] }
7
+
8
+ yaml do
9
+ map "generalization", to: :generalization
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -6,15 +6,12 @@
6
6
  module Lutaml
7
7
  module Uml
8
8
  class Connector < TopElement
9
- attr_accessor :kind, :connector_end
9
+ attribute :kind, :string
10
+ attribute :connector_end, :string, collection: true, default: -> { [] }
10
11
 
11
- def initialize # rubocop:disable Lint/MissingSuper
12
- @name = nil
13
- @xmi_id = nil
14
- @xmi_uuid = nil
15
- @connector_end = []
16
- @namespace = nil
17
- @kind = nil
12
+ yaml do
13
+ map "kind", to: :kind
14
+ map "connector_end", to: :connector_end
18
15
  end
19
16
  end
20
17
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## Behaviour metamodel
5
+ ##
6
+ module Lutaml
7
+ module Uml
8
+ class ConnectorEnd < TopElement
9
+ attribute :role, :string
10
+ attribute :part_with_port, :string
11
+ attribute :connector, :string
12
+
13
+ yaml do
14
+ map "role", to: :role
15
+ map "part_with_port", to: :part_with_port
16
+ map "connector", to: :connector
17
+ end
18
+ end
19
+ end
20
+ end
@@ -6,7 +6,17 @@
6
6
  module Lutaml
7
7
  module Uml
8
8
  class Constraint < TopElement
9
- attr_accessor :body
9
+ attribute :body, :string
10
+ attribute :type, :string
11
+ attribute :weight, :string
12
+ attribute :status, :string
13
+
14
+ yaml do
15
+ map "body", to: :body
16
+ map "type", to: :type
17
+ map "weight", to: :weight
18
+ map "status", to: :status
19
+ end
10
20
  end
11
21
  end
12
22
  end
@@ -1,75 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/uml/classifier"
3
+ require "lutaml/uml/association"
4
+ require "lutaml/uml/constraint"
5
+ require "lutaml/uml/operation"
6
+ require "lutaml/uml/data_type"
4
7
 
5
8
  module Lutaml
6
9
  module Uml
7
10
  class DataType < Classifier
8
- include HasMembers
9
-
10
- attr_accessor :nested_classifier,
11
- :is_abstract,
12
- :type
13
-
14
- attr_reader :associations,
15
- :attributes,
16
- :members,
17
- :modifier,
18
- :constraints,
19
- :operations,
20
- :data_types
21
-
22
- def initialize(attributes = {})
23
- @nested_classifier = []
24
- @stereotype = []
25
- @generalization = []
26
- @is_abstract = false
27
- super
28
- @keyword = "dataType"
29
- end
30
-
31
- def modifier=(value)
32
- @modifier = value.to_s # TODO: Validate?
33
- end
34
-
35
- def attributes=(value)
36
- @attributes = value.to_a.map do |attr|
37
- TopElementAttribute.new(attr)
38
- end
39
- end
40
-
41
- def associations=(value)
42
- @associations = value.to_a.map do |attr|
43
- Association.new(attr.to_h.merge(owner_end: name))
44
- end
45
- end
46
-
47
- def constraints=(value)
48
- @constraints = value.to_a.map do |attr|
49
- Constraint.new(attr)
50
- end
51
- end
52
-
53
- def operations=(value)
54
- @operations = value.to_a.map do |attr|
55
- Operation.new(attr)
11
+ attribute :nested_classifier, :string, collection: true,
12
+ default: -> { [] }
13
+ attribute :is_abstract, :boolean, default: false
14
+ attribute :type, :string
15
+ attribute :attributes, TopElementAttribute, collection: true
16
+ attribute :modifier, :string
17
+ attribute :constraints, Constraint, collection: true
18
+ attribute :operations, Operation, collection: true
19
+ attribute :data_types, DataType, collection: true
20
+ attribute :methods, :string, collection: true, default: -> { [] }
21
+ attribute :relationships, :string, collection: true, default: -> { [] }
22
+ attribute :keyword, :string, default: "dataType"
23
+
24
+ attribute :associations, Association, collection: true
25
+
26
+ yaml do
27
+ map "nested_classifier", to: :nested_classifier
28
+ map "is_abstract", to: :is_abstract
29
+ map "type", to: :type
30
+
31
+ map "attributes", to: :attributes
32
+ map "modifier", to: :modifier
33
+ map "constraints", to: :constraints
34
+ map "operations", to: :operations
35
+ map "data_types", to: :data_types
36
+
37
+ map "methods", to: :methods
38
+ map "relationships", to: :relationships
39
+
40
+ map "associations", to: :associations, with: {
41
+ to: :associations_to_yaml, from: :associations_from_yaml
42
+ }
43
+ end
44
+
45
+ def associations_to_yaml(model, doc)
46
+ associations = model.associations.map(&:to_hash)
47
+ doc["associations"] = associations unless associations.empty?
48
+ end
49
+
50
+ def associations_from_yaml(model, values)
51
+ associations = values.map do |value|
52
+ value["owner_end"] = model.name if value["owner_end"].nil?
53
+ Association.from_yaml(value.to_yaml)
56
54
  end
57
- end
58
-
59
- def data_types=(value)
60
- @data_types = value.to_a.map do |attr|
61
- DataType.new(attr)
62
- end
63
- end
64
-
65
- def methods
66
- # @members&.select { |member| member.class == Method }
67
- []
68
- end
69
55
 
70
- def relationships
71
- # @members&.select { |member| member.class == ClassRelationship }
72
- []
56
+ model.associations = associations
73
57
  end
74
58
  end
75
59
  end
@@ -6,15 +6,12 @@
6
6
  module Lutaml
7
7
  module Uml
8
8
  class Dependency < TopElement
9
- attr_accessor :client, :supplier
9
+ attribute :client, :string, collection: true, default: -> { [] }
10
+ attribute :supplier, :string, collection: true, default: -> { [] }
10
11
 
11
- def initialize # rubocop:disable Lint/MissingSuper
12
- @name = nil
13
- @xmi_id = nil
14
- @xmi_uuid = nil
15
- @client = []
16
- @supplier = []
17
- @namespace = nil
12
+ yaml do
13
+ map "client", to: :client
14
+ map "supplier", to: :supplier
18
15
  end
19
16
  end
20
17
  end
@@ -1,82 +1,55 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/uml/class"
4
- require "lutaml/uml/data_type"
5
- require "lutaml/uml/enum"
6
- require "lutaml/uml/diagram"
7
- require "lutaml/uml/package"
8
- require "lutaml/uml/primitive_type"
9
-
10
3
  module Lutaml
11
4
  module Uml
12
- class Document
13
- include HasAttributes
14
- include HasMembers
15
-
16
- attr_accessor :name,
17
- :title,
18
- :caption,
19
- :groups,
20
- :fidelity,
21
- :fontname,
22
- :comments
23
-
24
- # rubocop:disable Rails/ActiveRecordAliases
25
- def initialize(attributes = {})
26
- update_attributes(attributes)
27
- end
28
-
29
- # rubocop:enable Rails/ActiveRecordAliases
30
- def classes=(value)
31
- @classes = value.to_a.map { |attributes| Class.new(attributes) }
32
- end
33
-
34
- def data_types=(value)
35
- @data_types = value.to_a.map { |attributes| DataType.new(attributes) }
36
- end
37
-
38
- def enums=(value)
39
- @enums = value.to_a.map { |attributes| Enum.new(attributes) }
40
- end
41
-
42
- def packages=(value)
43
- @packages = value.to_a.map { |attributes| Package.new(attributes) }
44
- end
45
-
46
- def primitives=(value)
47
- @primitives = value.to_a.map do |attributes|
48
- PrimitiveType.new(attributes)
5
+ class Document < Lutaml::Model::Serializable
6
+ attribute :name, :string
7
+ attribute :title, :string
8
+ attribute :caption, :string
9
+ attribute :groups, Group, collection: true
10
+ attribute :fidelity, Fidelity
11
+ attribute :fontname, :string
12
+ attribute :comments, :string, collection: true
13
+
14
+ attribute :classes, Class, collection: true, default: -> { [] }
15
+ attribute :data_types, DataType, collection: true, default: -> { [] }
16
+ attribute :enums, Enum, collection: true, default: -> { [] }
17
+ attribute :packages, Package, collection: true, default: -> { [] }
18
+ attribute :primitives, PrimitiveType, collection: true, default: -> { [] }
19
+ attribute :associations, Association, collection: true, default: -> { [] }
20
+
21
+ yaml do
22
+ map "name", to: :name
23
+ map "title", to: :title
24
+ map "caption", to: :caption
25
+ map "groups", to: :groups
26
+ map "fidelity", to: :fidelity
27
+ map "fontname", to: :fontname
28
+ map "comments", to: :comments
29
+
30
+ map "classes", to: :classes
31
+ map "data_types", to: :data_types
32
+ map "enums", to: :enums
33
+ map "packages", to: :packages
34
+ map "primitives", to: :primitives
35
+
36
+ map "associations", to: :associations, with: {
37
+ to: :associations_to_yaml, from: :associations_from_yaml
38
+ }
39
+ end
40
+
41
+ def associations_to_yaml(model, doc)
42
+ associations = model.associations.map(&:to_hash)
43
+ doc["associations"] = associations unless associations.empty?
44
+ end
45
+
46
+ def associations_from_yaml(model, values)
47
+ associations = values.map do |value|
48
+ value["owner_end"] = model.name if value["owner_end"].nil?
49
+ Association.from_yaml(value.to_yaml)
49
50
  end
50
- end
51
-
52
- def associations=(value)
53
- @associations = value.to_a.map do |attributes|
54
- Association.new(attributes)
55
- end
56
- end
57
-
58
- def classes
59
- @classes || []
60
- end
61
-
62
- def enums
63
- @enums || []
64
- end
65
-
66
- def data_types
67
- @data_types || []
68
- end
69
-
70
- def packages
71
- @packages || []
72
- end
73
-
74
- def primitives
75
- @primitives || []
76
- end
77
51
 
78
- def associations
79
- @associations || []
52
+ model.associations = associations
80
53
  end
81
54
  end
82
55
  end
@@ -1,44 +1,21 @@
1
1
  # frozen_string_literal: true
2
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
- require "lutaml/uml/value"
8
-
9
3
  module Lutaml
10
4
  module Uml
11
5
  class Enum < Classifier
12
- include HasMembers
13
-
14
- attr_reader :attributes,
15
- :members,
16
- :modifier,
17
- :definition,
18
- :keyword,
19
- :values
20
-
21
- def initialize(attributes = {})
22
- super
23
- @keyword = "enumeration"
24
- end
25
-
26
- # TODO: delete?
27
- def attributes=(value)
28
- @attributes = value.to_a.map do |attr|
29
- TopElementAttribute.new(attr)
30
- end
31
- end
32
-
33
- def values=(value)
34
- @values = value.to_a.map do |attr|
35
- Value.new(attr)
36
- end
37
- end
6
+ attribute :attributes, TopElementAttribute, collection: true,
7
+ default: -> { [] }
8
+ attribute :modifier, :string
9
+ attribute :keyword, :string, default: "enumeration"
10
+ attribute :values, Value, collection: true, default: -> { [] }
11
+ attribute :methods, :string, collection: true, default: -> { [] }
38
12
 
39
- # TODO: reserved name, change
40
- def methods
41
- []
13
+ yaml do
14
+ map "attributes", to: :attributes
15
+ map "modifier", to: :modifier
16
+ map "keyword", to: :keyword
17
+ map "values", to: :values
18
+ map "methods", to: :methods
42
19
  end
43
20
  end
44
21
  end
@@ -3,7 +3,6 @@
3
3
  ##
4
4
  ## Behaviour metamodel
5
5
  ##
6
-
7
6
  module Lutaml
8
7
  module Uml
9
8
  class Event < TopElement
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ class Fidelity < Lutaml::Model::Serializable
6
+ attribute :hideMembers, :boolean
7
+ attribute :hideOtherClasses, :boolean
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ class Group < Lutaml::Model::Serializable
6
+ attribute :id, :string
7
+ attribute :values, :string, collection: true
8
+ attribute :groups, Group, collection: true
9
+
10
+ yaml do
11
+ map "id", to: :id
12
+ map "values", to: :values
13
+ map "groups", to: :groups
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,14 +3,12 @@
3
3
  module Lutaml
4
4
  module Uml
5
5
  class Instance < TopElement
6
- attr_accessor :classifier, :slot
6
+ attribute :classifier, :string
7
+ attribute :slot, :string, collection: true, default: -> { [] }
7
8
 
8
- def initialize # rubocop:disable Lint/MissingSuper
9
- @name = nil
10
- @xmi_id = nil
11
- @xmi_uuid = nil
12
- @classifier = nil
13
- @slot = []
9
+ yaml do
10
+ map "classifier", to: :classifier
11
+ map "slot", to: :slot
14
12
  end
15
13
  end
16
14
  end
@@ -3,10 +3,10 @@
3
3
  module Lutaml
4
4
  module Uml
5
5
  class Model < Package
6
- attr_accessor :viewpoint
6
+ attribute :viewpoint, :string
7
7
 
8
- def initialize # rubocop:disable Lint/MissingSuper
9
- @contents = []
8
+ yaml do
9
+ map "viewpoint", to: :viewpoint
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ class NameSpace < Lutaml::Model::Serializable
6
+ attribute :name, :string
7
+ attribute :namespace, NameSpace
8
+ end
9
+ end
10
+ end
@@ -6,7 +6,7 @@ module Lutaml
6
6
  module Uml
7
7
  module Node
8
8
  class Base
9
- include HasAttributes
9
+ include ::Lutaml::Uml::HasAttributes
10
10
 
11
11
  # rubocop:disable Rails/ActiveRecordAliases
12
12
  def initialize(attributes = {})