lutaml 0.9.39 → 0.9.41
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.
- checksums.yaml +4 -4
- data/README.adoc +7 -1
- data/docs/lutaml-express.adoc +35 -0
- data/docs/lutaml-sysml.adoc +10 -0
- data/docs/lutaml-uml.adoc +111 -0
- data/docs/lutaml-xmi.adoc +33 -0
- data/exe/lutaml-yaml2uml +1 -1
- data/lib/lutaml/command_line.rb +1 -1
- data/lib/lutaml/converter/dsl_to_uml.rb +235 -0
- data/lib/lutaml/converter/xmi_hash_to_uml.rb +196 -0
- data/lib/lutaml/express.rb +0 -1
- data/lib/lutaml/formatter/base.rb +7 -7
- data/lib/lutaml/formatter/graphviz.rb +19 -8
- data/lib/lutaml/formatter.rb +0 -2
- data/lib/lutaml/parser.rb +1 -1
- data/lib/lutaml/sysml/allocate.rb +1 -1
- data/lib/lutaml/sysml/allocated.rb +1 -1
- data/lib/lutaml/sysml/binding_connector.rb +1 -1
- data/lib/lutaml/sysml/block.rb +1 -1
- data/lib/lutaml/sysml/constraint_block.rb +1 -1
- data/lib/lutaml/sysml/copy.rb +1 -1
- data/lib/lutaml/sysml/derive_requirement.rb +1 -1
- data/lib/lutaml/sysml/nested_connector_end.rb +1 -1
- data/lib/lutaml/sysml/refine.rb +1 -1
- data/lib/lutaml/sysml/requirement_related.rb +1 -1
- data/lib/lutaml/sysml/satisfy.rb +1 -1
- data/lib/lutaml/sysml/test_case.rb +1 -1
- data/lib/lutaml/sysml/trace.rb +1 -1
- data/lib/lutaml/sysml/verify.rb +1 -1
- data/lib/lutaml/sysml/xmi_file.rb +1 -1
- data/lib/lutaml/sysml.rb +0 -1
- data/lib/lutaml/uml/action.rb +15 -0
- data/lib/lutaml/uml/actor.rb +0 -8
- data/lib/lutaml/uml/association.rb +25 -34
- data/lib/lutaml/uml/cardinality.rb +10 -0
- data/lib/lutaml/uml/class.rb +43 -68
- data/lib/lutaml/uml/classifier.rb +5 -3
- data/lib/lutaml/uml/connector.rb +5 -8
- data/lib/lutaml/uml/connector_end.rb +20 -0
- data/lib/lutaml/uml/constraint.rb +11 -1
- data/lib/lutaml/uml/data_type.rb +48 -64
- data/lib/lutaml/uml/dependency.rb +5 -8
- data/lib/lutaml/uml/document.rb +46 -73
- data/lib/lutaml/uml/enum.rb +12 -35
- data/lib/lutaml/uml/event.rb +0 -1
- data/lib/lutaml/uml/fidelity.rb +10 -0
- data/lib/lutaml/uml/group.rb +17 -0
- data/lib/lutaml/uml/instance.rb +5 -7
- data/lib/lutaml/uml/model.rb +3 -3
- data/lib/lutaml/uml/namespace.rb +10 -0
- data/lib/lutaml/uml/node/base.rb +1 -1
- data/lib/lutaml/uml/operation.rb +6 -22
- data/lib/lutaml/uml/package.rb +23 -44
- data/lib/lutaml/uml/parsers/dsl.rb +5 -2
- data/lib/lutaml/uml/parsers/yaml.rb +2 -28
- data/lib/lutaml/uml/primitive_type.rb +3 -4
- data/lib/lutaml/uml/property.rb +15 -17
- data/lib/lutaml/uml/region.rb +0 -1
- data/lib/lutaml/uml/state.rb +9 -1
- data/lib/lutaml/uml/state_machine.rb +0 -1
- data/lib/lutaml/uml/top_element.rb +61 -39
- data/lib/lutaml/uml/top_element_attribute.rb +33 -22
- data/lib/lutaml/uml/transition.rb +11 -1
- data/lib/lutaml/uml/trigger.rb +5 -1
- data/lib/lutaml/uml/value.rb +18 -14
- data/lib/lutaml/uml.rb +40 -2
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +2 -1
- data/lib/lutaml/xmi/parsers/xmi_base.rb +20 -2
- data/lib/lutaml/xmi/parsers/xml.rb +5 -4
- metadata +15 -19
- data/lib/lutaml/express/README.adoc +0 -55
- data/lib/lutaml/express/version.rb +0 -7
- data/lib/lutaml/sysml/README.md +0 -40
- data/lib/lutaml/sysml/version.rb +0 -5
- data/lib/lutaml/uml/README.adoc +0 -44
- data/lib/lutaml/uml/constructor_end.rb +0 -16
- data/lib/lutaml/uml/formatter/base.rb +0 -67
- data/lib/lutaml/uml/formatter/graphviz.rb +0 -332
- data/lib/lutaml/uml/formatter.rb +0 -21
- data/lib/lutaml/uml/serializers/association.rb +0 -58
- data/lib/lutaml/uml/serializers/base.rb +0 -16
- data/lib/lutaml/uml/serializers/class.rb +0 -29
- data/lib/lutaml/uml/serializers/top_element_attribute.rb +0 -14
- data/lib/lutaml/uml/serializers/yaml_view.rb +0 -18
- data/lib/lutaml/uml/version.rb +0 -7
- data/lib/lutaml/xmi/README.adoc +0 -24
- /data/{LUTAML.adoc → docs/lutaml_syntax.adoc} +0 -0
data/lib/lutaml/uml/data_type.rb
CHANGED
@@ -1,75 +1,59 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "lutaml/uml/
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
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
|
-
|
9
|
+
attribute :client, :string, collection: true, default: -> { [] }
|
10
|
+
attribute :supplier, :string, collection: true, default: -> { [] }
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
data/lib/lutaml/uml/document.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
79
|
-
@associations || []
|
52
|
+
model.associations = associations
|
80
53
|
end
|
81
54
|
end
|
82
55
|
end
|
data/lib/lutaml/uml/enum.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
40
|
-
|
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
|
data/lib/lutaml/uml/event.rb
CHANGED
@@ -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
|
data/lib/lutaml/uml/instance.rb
CHANGED
@@ -3,14 +3,12 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module Uml
|
5
5
|
class Instance < TopElement
|
6
|
-
|
6
|
+
attribute :classifier, :string
|
7
|
+
attribute :slot, :string, collection: true, default: -> { [] }
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
data/lib/lutaml/uml/model.rb
CHANGED
data/lib/lutaml/uml/node/base.rb
CHANGED
data/lib/lutaml/uml/operation.rb
CHANGED
@@ -2,29 +2,13 @@
|
|
2
2
|
|
3
3
|
module Lutaml
|
4
4
|
module Uml
|
5
|
-
class Operation
|
6
|
-
|
7
|
-
|
5
|
+
class Operation < TopElement
|
6
|
+
attribute :return_type, :string
|
7
|
+
attribute :parameter_type, :string
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
:parameter_type
|
13
|
-
|
14
|
-
# rubocop:disable Rails/ActiveRecordAliases
|
15
|
-
def initialize(attributes = {})
|
16
|
-
update_attributes(attributes)
|
17
|
-
end
|
18
|
-
# rubocop:enable Rails/ActiveRecordAliases
|
19
|
-
|
20
|
-
def definition=(value)
|
21
|
-
@definition = value
|
22
|
-
.to_s
|
23
|
-
.gsub(/\\}/, "}")
|
24
|
-
.gsub(/\\{/, "{")
|
25
|
-
.split("\n")
|
26
|
-
.map(&:strip)
|
27
|
-
.join("\n")
|
9
|
+
yaml do
|
10
|
+
map "return_type", to: :return_type
|
11
|
+
map "parameter_type", to: :parameter_type
|
28
12
|
end
|
29
13
|
end
|
30
14
|
end
|
data/lib/lutaml/uml/package.rb
CHANGED
@@ -1,55 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "lutaml/uml/class"
|
4
|
+
require "lutaml/uml/enum"
|
5
|
+
require "lutaml/uml/data_type"
|
6
|
+
require "lutaml/uml/diagram"
|
7
|
+
|
3
8
|
module Lutaml
|
4
9
|
module Uml
|
5
10
|
class Package < TopElement
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
attribute :contents, :string, collection: true, default: -> { [] }
|
12
|
+
attribute :classes, Class, collection: true, default: -> { [] }
|
13
|
+
attribute :enums, Enum, collection: true, default: -> { [] }
|
14
|
+
attribute :data_types, DataType, collection: true, default: -> { [] }
|
15
|
+
attribute :packages, Package, collection: true, default: -> { [] }
|
16
|
+
attribute :diagrams, Diagram, collection: true, default: -> { [] }
|
17
|
+
|
18
|
+
yaml do
|
19
|
+
map "contents", to: :contents
|
20
|
+
map "classes", to: :classes
|
21
|
+
map "enums", to: :enums
|
22
|
+
map "data_types", to: :data_types
|
23
|
+
map "packages", to: :packages
|
24
|
+
map "diagrams", to: :diagrams
|
25
|
+
end
|
26
|
+
|
27
|
+
def children_packages
|
28
|
+
packages.map do |pkg|
|
14
29
|
[pkg, pkg.packages, pkg.packages.map(&:children_packages)]
|
15
30
|
end.flatten.uniq
|
16
31
|
end
|
17
|
-
|
18
|
-
def classes=(value)
|
19
|
-
@classes = value.to_a.map { |attributes| Class.new(attributes) }
|
20
|
-
end
|
21
|
-
|
22
|
-
def enums=(value)
|
23
|
-
@enums = value.to_a.map { |attributes| Enum.new(attributes) }
|
24
|
-
end
|
25
|
-
|
26
|
-
def data_types=(value)
|
27
|
-
@data_types = value.to_a.map { |attributes| DataType.new(attributes) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def packages=(value)
|
31
|
-
@packages = value.to_a.map { |attributes| Package.new(attributes) }
|
32
|
-
end
|
33
|
-
|
34
|
-
def diagrams=(value)
|
35
|
-
@diagrams = value.to_a.map { |attributes| Diagram.new(attributes) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def classes
|
39
|
-
@classes || []
|
40
|
-
end
|
41
|
-
|
42
|
-
def enums
|
43
|
-
@enums || []
|
44
|
-
end
|
45
|
-
|
46
|
-
def packages
|
47
|
-
@packages || []
|
48
|
-
end
|
49
|
-
|
50
|
-
def diagrams
|
51
|
-
@diagrams || []
|
52
|
-
end
|
53
32
|
end
|
54
33
|
end
|
55
34
|
end
|
@@ -5,6 +5,7 @@ require "parslet/convenience"
|
|
5
5
|
require "lutaml/uml/parsers/dsl_preprocessor"
|
6
6
|
require "lutaml/uml/parsers/dsl_transform"
|
7
7
|
require "lutaml/uml/node/document"
|
8
|
+
require "lutaml/converter/dsl_to_uml"
|
8
9
|
|
9
10
|
module Lutaml
|
10
11
|
module Uml
|
@@ -13,6 +14,8 @@ module Lutaml
|
|
13
14
|
|
14
15
|
# Class for parsing LutaML dsl into Lutaml::Uml::Document
|
15
16
|
class Dsl < Parslet::Parser
|
17
|
+
include Lutaml::Converter::DslToUml
|
18
|
+
|
16
19
|
# @param [String] io - LutaML string representation
|
17
20
|
# [Hash] options - options for parsing
|
18
21
|
#
|
@@ -27,8 +30,8 @@ module Lutaml
|
|
27
30
|
# Parslet::ErrorReporter::Deepest allows more
|
28
31
|
# detailed display of error
|
29
32
|
reporter = Parslet::ErrorReporter::Deepest.new
|
30
|
-
|
31
|
-
|
33
|
+
hash = DslTransform.new.apply(super(data, reporter: reporter))
|
34
|
+
create_uml_document(hash)
|
32
35
|
rescue Parslet::ParseFailed => e
|
33
36
|
raise(ParsingError,
|
34
37
|
"#{e.message}\ncause: #{e.parse_failure_cause.ascii_tree}")
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "yaml"
|
4
|
-
require "lutaml/uml
|
5
|
-
require "lutaml/uml/document"
|
6
|
-
require "lutaml/uml/serializers/yaml_view"
|
4
|
+
require "lutaml/uml"
|
7
5
|
|
8
6
|
module Lutaml
|
9
7
|
module Uml
|
@@ -14,31 +12,7 @@ module Lutaml
|
|
14
12
|
end
|
15
13
|
|
16
14
|
def parse(yaml_path, _options = {})
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def yaml_parse(yaml_path)
|
21
|
-
yaml_content = YAML.safe_load(File.read(yaml_path))
|
22
|
-
serialized_yaml = Lutaml::Uml::Serializers::YamlView
|
23
|
-
.new(yaml_content)
|
24
|
-
result = Lutaml::Uml::Document.new(serialized_yaml)
|
25
|
-
result.classes = imports_to_classes(yaml_content, yaml_path)
|
26
|
-
result
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def imports_to_classes(yaml_content, yaml_path)
|
32
|
-
models_path = File.join(File.dirname(yaml_path), "..", "models")
|
33
|
-
yaml_content["imports"].map do |(klass_name, _)|
|
34
|
-
klass_attrs = YAML.safe_load(
|
35
|
-
File.read(
|
36
|
-
File.join(models_path, "#{klass_name}.yml"),
|
37
|
-
),
|
38
|
-
)
|
39
|
-
klass_attrs["name"] = klass_name if klass_attrs["name"].nil?
|
40
|
-
Lutaml::Uml::Serializers::Class.new(klass_attrs)
|
41
|
-
end
|
15
|
+
Lutaml::Uml::Document.from_yaml(File.read(yaml_path))
|
42
16
|
end
|
43
17
|
end
|
44
18
|
end
|
@@ -3,11 +3,10 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module Uml
|
5
5
|
class PrimitiveType < DataType
|
6
|
-
|
6
|
+
attribute :keyword, :string, default: "primitive"
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
@keyword = "primitive"
|
8
|
+
yaml do
|
9
|
+
map "keyword", to: :keyword
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|