lutaml-uml 0.4.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +22 -0
- data/Gemfile +1 -5
- data/README.adoc +4 -42
- data/Rakefile +0 -5
- data/lutaml-uml.gemspec +23 -38
- metadata +20 -292
- data/.github/workflows/macos.yml +0 -38
- data/.github/workflows/ubuntu.yml +0 -40
- data/.github/workflows/windows.yml +0 -51
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.travis.yml +0 -6
- data/CODE_OF_CONDUCT.md +0 -74
- data/LUTAML.adoc +0 -344
- data/bin/console +0 -15
- data/bin/folder_yaml2lutaml.sh +0 -6
- data/bin/plantuml2lutaml +0 -59
- data/bin/setup +0 -8
- data/bin/yaml2lutaml +0 -144
- data/exe/lutaml-wsd2uml +0 -59
- data/exe/lutaml-yaml2uml +0 -144
- data/lib/lutaml/layout/engine.rb +0 -15
- data/lib/lutaml/layout/graph_viz_engine.rb +0 -19
- data/lib/lutaml/uml/abstraction.rb +0 -11
- data/lib/lutaml/uml/activity.rb +0 -11
- data/lib/lutaml/uml/actor.rb +0 -19
- data/lib/lutaml/uml/association.rb +0 -41
- data/lib/lutaml/uml/behavior.rb +0 -11
- data/lib/lutaml/uml/class.rb +0 -83
- data/lib/lutaml/uml/classifier.rb +0 -11
- data/lib/lutaml/uml/connector.rb +0 -21
- data/lib/lutaml/uml/constraint.rb +0 -12
- data/lib/lutaml/uml/constructor_end.rb +0 -16
- data/lib/lutaml/uml/data_type.rb +0 -75
- data/lib/lutaml/uml/dependency.rb +0 -21
- data/lib/lutaml/uml/diagram.rb +0 -8
- data/lib/lutaml/uml/document.rb +0 -81
- data/lib/lutaml/uml/enum.rb +0 -45
- data/lib/lutaml/uml/event.rb +0 -12
- data/lib/lutaml/uml/final_state.rb +0 -11
- data/lib/lutaml/uml/formatter/base.rb +0 -67
- data/lib/lutaml/uml/formatter/graphviz.rb +0 -334
- data/lib/lutaml/uml/formatter.rb +0 -21
- data/lib/lutaml/uml/has_attributes.rb +0 -14
- data/lib/lutaml/uml/has_members.rb +0 -30
- data/lib/lutaml/uml/instance.rb +0 -17
- data/lib/lutaml/uml/model.rb +0 -13
- data/lib/lutaml/uml/node/base.rb +0 -21
- data/lib/lutaml/uml/node/class_node.rb +0 -57
- data/lib/lutaml/uml/node/class_relationship.rb +0 -14
- data/lib/lutaml/uml/node/document.rb +0 -18
- data/lib/lutaml/uml/node/field.rb +0 -34
- data/lib/lutaml/uml/node/has_name.rb +0 -15
- data/lib/lutaml/uml/node/has_type.rb +0 -15
- data/lib/lutaml/uml/node/method.rb +0 -29
- data/lib/lutaml/uml/node/method_argument.rb +0 -16
- data/lib/lutaml/uml/node/relationship.rb +0 -28
- data/lib/lutaml/uml/opaque_behavior.rb +0 -11
- data/lib/lutaml/uml/operation.rb +0 -31
- data/lib/lutaml/uml/package.rb +0 -53
- data/lib/lutaml/uml/parsers/attribute.rb +0 -70
- data/lib/lutaml/uml/parsers/dsl.rb +0 -413
- data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +0 -59
- data/lib/lutaml/uml/parsers/dsl_transform.rb +0 -27
- data/lib/lutaml/uml/parsers/yaml.rb +0 -46
- data/lib/lutaml/uml/port.rb +0 -8
- data/lib/lutaml/uml/primitive_type.rb +0 -14
- data/lib/lutaml/uml/property.rb +0 -27
- data/lib/lutaml/uml/pseudostate.rb +0 -11
- data/lib/lutaml/uml/realization.rb +0 -11
- data/lib/lutaml/uml/region.rb +0 -12
- 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/state.rb +0 -12
- data/lib/lutaml/uml/state_machine.rb +0 -12
- data/lib/lutaml/uml/top_element.rb +0 -58
- data/lib/lutaml/uml/top_element_attribute.rb +0 -37
- data/lib/lutaml/uml/transition.rb +0 -12
- data/lib/lutaml/uml/trigger.rb +0 -12
- data/lib/lutaml/uml/value.rb +0 -30
- data/lib/lutaml/uml/version.rb +0 -7
- data/lib/lutaml/uml/vertex.rb +0 -11
- data/lib/lutaml/uml.rb +0 -13
- data/spec/fixtures/datamodel/models/AddressClassProfile.yml +0 -90
- data/spec/fixtures/datamodel/models/AddressComponentProfile.yml +0 -63
- data/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +0 -15
- data/spec/fixtures/datamodel/models/AddressProfile.yml +0 -36
- data/spec/fixtures/datamodel/models/AttributeProfile.yml +0 -32
- data/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +0 -79
- data/spec/fixtures/datamodel/models/Localization copy.yml +0 -23
- data/spec/fixtures/datamodel/models/Localization.yml +0 -23
- data/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +0 -36
- data/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +0 -15
- data/spec/fixtures/datamodel/models/Signature.yml +0 -20
- data/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +0 -20
- data/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +0 -16
- data/spec/fixtures/datamodel/models/TextDirectionCode.yml +0 -16
- data/spec/fixtures/datamodel/models/Validity.yml +0 -14
- data/spec/fixtures/datamodel/models/iso19160-1/Address.yml +0 -22
- data/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +0 -2
- data/spec/fixtures/datamodel/style.uml.inc +0 -37
- data/spec/fixtures/datamodel/views/AddressClassProfile.yml +0 -12
- data/spec/fixtures/datamodel/views/AddressProfile.yml +0 -3
- data/spec/fixtures/datamodel/views/CommonModels.yml +0 -9
- data/spec/fixtures/datamodel/views/TopDown.yml +0 -62
- data/spec/fixtures/dsl/broken_diagram.lutaml +0 -34
- data/spec/fixtures/dsl/diagram.lutaml +0 -3
- data/spec/fixtures/dsl/diagram_attributes.lutaml +0 -5
- data/spec/fixtures/dsl/diagram_blank_definion.lutaml +0 -6
- data/spec/fixtures/dsl/diagram_blank_entities.lutaml +0 -8
- data/spec/fixtures/dsl/diagram_class_assocation.lutaml +0 -29
- data/spec/fixtures/dsl/diagram_class_fields.lutaml +0 -25
- data/spec/fixtures/dsl/diagram_commented_includes.lutaml +0 -5
- data/spec/fixtures/dsl/diagram_comments.lutaml +0 -28
- data/spec/fixtures/dsl/diagram_concept_model.lutaml +0 -132
- data/spec/fixtures/dsl/diagram_data_types.lutaml +0 -44
- data/spec/fixtures/dsl/diagram_definitions.lutaml +0 -25
- data/spec/fixtures/dsl/diagram_includes.lutaml +0 -6
- data/spec/fixtures/dsl/diagram_multiply_classes.lutaml +0 -7
- data/spec/fixtures/dsl/diagram_non_existing_include.lutaml +0 -6
- data/spec/fixtures/dsl/shared.lutaml +0 -3
- data/spec/fixtures/dsl/shared1.lutaml +0 -4
- data/spec/fixtures/generated_dot/AddressClassProfile.dot +0 -170
- data/spec/fixtures/generated_dot/AddressProfile.dot +0 -34
- data/spec/lutaml/layout/graph_viz_engine_spec.rb +0 -31
- data/spec/lutaml/uml/formatter/graphviz_spec.rb +0 -41
- data/spec/lutaml/uml/parsers/dsl_spec.rb +0 -343
- data/spec/lutaml/uml/parsers/yaml_spec.rb +0 -18
- data/spec/lutaml/uml/serializers/yaml_view_spec.rb +0 -20
- data/spec/lutaml/uml_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -25
@@ -1,67 +0,0 @@
|
|
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
|
@@ -1,334 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "open3"
|
4
|
-
require "lutaml/uml/formatter/base"
|
5
|
-
require "lutaml/layout/graph_viz_engine"
|
6
|
-
|
7
|
-
module Lutaml
|
8
|
-
module Uml
|
9
|
-
module Formatter
|
10
|
-
class Graphviz < Base
|
11
|
-
class Attributes < Hash
|
12
|
-
def to_s
|
13
|
-
to_a
|
14
|
-
.reject { |(_k, val)| val.nil? }
|
15
|
-
.map { |(a, b)| "#{a}=#{b.inspect}" }
|
16
|
-
.join(" ")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
ACCESS_SYMBOLS = {
|
21
|
-
"public" => "+",
|
22
|
-
"protected" => "#",
|
23
|
-
"private" => "-",
|
24
|
-
}.freeze
|
25
|
-
DEFAULT_CLASS_FONT = "Helvetica".freeze
|
26
|
-
|
27
|
-
VALID_TYPES = %i[
|
28
|
-
dot
|
29
|
-
xdot
|
30
|
-
ps
|
31
|
-
pdf
|
32
|
-
svg
|
33
|
-
svgz
|
34
|
-
fig
|
35
|
-
png
|
36
|
-
gif
|
37
|
-
jpg
|
38
|
-
jpeg
|
39
|
-
json
|
40
|
-
imap
|
41
|
-
cmapx
|
42
|
-
].freeze
|
43
|
-
|
44
|
-
def initialize(attributes = {})
|
45
|
-
super
|
46
|
-
|
47
|
-
@graph = Attributes.new
|
48
|
-
# Associations lines style, `true` gives curved lines
|
49
|
-
# https://graphviz.org/doc/info/attrs.html#d:splines
|
50
|
-
@graph["splines"] = "ortho"
|
51
|
-
# Padding between outside of picture and nodes
|
52
|
-
@graph["pad"] = 0.5
|
53
|
-
# Padding between levels
|
54
|
-
@graph["ranksep"] = "1.2.equally"
|
55
|
-
# Padding between nodes
|
56
|
-
@graph["nodesep"] = "1.2.equally"
|
57
|
-
# TODO: set rankdir
|
58
|
-
# @graph['rankdir'] = 'BT'
|
59
|
-
|
60
|
-
@edge = Attributes.new
|
61
|
-
@edge["color"] = "gray50"
|
62
|
-
|
63
|
-
@node = Attributes.new
|
64
|
-
@node["shape"] = "box"
|
65
|
-
|
66
|
-
@type = :dot
|
67
|
-
end
|
68
|
-
|
69
|
-
attr_reader :graph
|
70
|
-
attr_reader :edge
|
71
|
-
attr_reader :node
|
72
|
-
|
73
|
-
def type=(value)
|
74
|
-
super
|
75
|
-
|
76
|
-
@type = :dot unless VALID_TYPES.include?(@type)
|
77
|
-
end
|
78
|
-
|
79
|
-
def format(node)
|
80
|
-
dot = super.lines.map(&:rstrip).join("\n")
|
81
|
-
|
82
|
-
generate_from_dot(dot)
|
83
|
-
end
|
84
|
-
|
85
|
-
def escape_html_chars(text)
|
86
|
-
text
|
87
|
-
.gsub(/</, "<")
|
88
|
-
.gsub(/>/, ">")
|
89
|
-
.gsub(/\[/, "[")
|
90
|
-
.gsub(/\]/, "]")
|
91
|
-
end
|
92
|
-
|
93
|
-
def format_field(node)
|
94
|
-
symbol = ACCESS_SYMBOLS[node.visibility]
|
95
|
-
result = "#{symbol}#{node.name}"
|
96
|
-
if node.type
|
97
|
-
keyword = node.keyword ? "«#{node.keyword}»" : ""
|
98
|
-
result += " : #{keyword}#{node.type}"
|
99
|
-
end
|
100
|
-
if node.cardinality
|
101
|
-
result += "[#{node.cardinality[:min]}..#{node.cardinality[:max]}]"
|
102
|
-
end
|
103
|
-
result = escape_html_chars(result)
|
104
|
-
result = "<U>#{result}</U>" if node.static
|
105
|
-
|
106
|
-
result
|
107
|
-
end
|
108
|
-
|
109
|
-
def format_method(node)
|
110
|
-
symbol = ACCESS_SYMBOLS[node.access]
|
111
|
-
result = "#{symbol} #{node.name}"
|
112
|
-
if node.arguments
|
113
|
-
arguments = node.arguments.map do |argument|
|
114
|
-
"#{argument.name}#{" : #{argument.type}" if argument.type}"
|
115
|
-
end.join(", ")
|
116
|
-
end
|
117
|
-
|
118
|
-
result << "(#{arguments})"
|
119
|
-
result << " : #{node.type}" if node.type
|
120
|
-
result = "<U>#{result}</U>" if node.static
|
121
|
-
result = "<I>#{result}</I>" if node.abstract
|
122
|
-
|
123
|
-
result
|
124
|
-
end
|
125
|
-
|
126
|
-
def format_relationship(node)
|
127
|
-
graph_parent_name = generate_graph_name(node.owner_end)
|
128
|
-
graph_node_name = generate_graph_name(node.member_end)
|
129
|
-
attributes = generate_graph_relationship_attributes(node)
|
130
|
-
graph_attributes = " [#{attributes}]" unless attributes.empty?
|
131
|
-
|
132
|
-
%{#{graph_parent_name} -> #{graph_node_name}#{graph_attributes}}
|
133
|
-
end
|
134
|
-
|
135
|
-
def generate_graph_relationship_attributes(node)
|
136
|
-
attributes = Attributes.new
|
137
|
-
if %w[dependency realizes].include?(node.member_end_type)
|
138
|
-
attributes["style"] = "dashed"
|
139
|
-
end
|
140
|
-
attributes["dir"] = if node.owner_end_type && node.member_end_type
|
141
|
-
"both"
|
142
|
-
elsif node.owner_end_type
|
143
|
-
"back"
|
144
|
-
else
|
145
|
-
"direct"
|
146
|
-
end
|
147
|
-
attributes["label"] = node.action if node.action
|
148
|
-
if node.owner_end_attribute_name
|
149
|
-
attributes["headlabel"] = format_label(
|
150
|
-
node.owner_end_attribute_name,
|
151
|
-
node.owner_end_cardinality
|
152
|
-
)
|
153
|
-
end
|
154
|
-
if node.member_end_attribute_name
|
155
|
-
attributes["taillabel"] = format_label(
|
156
|
-
node.member_end_attribute_name,
|
157
|
-
node.member_end_cardinality
|
158
|
-
)
|
159
|
-
end
|
160
|
-
|
161
|
-
attributes["arrowtail"] = case node.owner_end_type
|
162
|
-
when "composition"
|
163
|
-
"diamond"
|
164
|
-
when "aggregation"
|
165
|
-
"odiamond"
|
166
|
-
when "direct"
|
167
|
-
"vee"
|
168
|
-
else
|
169
|
-
"onormal"
|
170
|
-
end
|
171
|
-
|
172
|
-
attributes["arrowhead"] = case node.member_end_type
|
173
|
-
when "composition"
|
174
|
-
"diamond"
|
175
|
-
when "aggregation"
|
176
|
-
"odiamond"
|
177
|
-
when "direct"
|
178
|
-
"vee"
|
179
|
-
else
|
180
|
-
"onormal"
|
181
|
-
end
|
182
|
-
# swap labels and arrows if `dir` eq to `back`
|
183
|
-
if attributes["dir"] == "back"
|
184
|
-
attributes["arrowhead"], attributes["arrowtail"] =
|
185
|
-
[attributes["arrowtail"], attributes["arrowhead"]]
|
186
|
-
attributes["headlabel"], attributes["taillabel"] =
|
187
|
-
[attributes["taillabel"], attributes["headlabel"]]
|
188
|
-
end
|
189
|
-
attributes
|
190
|
-
end
|
191
|
-
|
192
|
-
def format_label(name, cardinality = {})
|
193
|
-
res = "+#{name}"
|
194
|
-
if cardinality.nil? ||
|
195
|
-
(cardinality["min"].nil? || cardinality["max"].nil?)
|
196
|
-
return res
|
197
|
-
end
|
198
|
-
|
199
|
-
"#{res} #{cardinality['min']}..#{cardinality['max']}"
|
200
|
-
end
|
201
|
-
|
202
|
-
def format_member_rows(members, hide_members)
|
203
|
-
unless !hide_members && members && members.length.positive?
|
204
|
-
return <<~HEREDOC.chomp
|
205
|
-
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
|
206
|
-
<TR><TD ALIGN="LEFT"></TD></TR>
|
207
|
-
</TABLE>
|
208
|
-
HEREDOC
|
209
|
-
end
|
210
|
-
|
211
|
-
field_rows = members.map do |field|
|
212
|
-
%{<TR><TD ALIGN="LEFT">#{format_field(field)}</TD></TR>}
|
213
|
-
end
|
214
|
-
field_table = <<~HEREDOC.chomp
|
215
|
-
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
|
216
|
-
#{field_rows.map { |row| ' ' * 10 + row }.join("\n")}
|
217
|
-
</TABLE>
|
218
|
-
HEREDOC
|
219
|
-
field_table << "\n" << " " * 6
|
220
|
-
field_table
|
221
|
-
end
|
222
|
-
|
223
|
-
def format_class(node, hide_members)
|
224
|
-
name = ["<B>#{node.name}</B>"]
|
225
|
-
name.unshift("«#{node.keyword}»") if node.keyword
|
226
|
-
name_html = <<~HEREDOC
|
227
|
-
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
|
228
|
-
#{name.map { |n| %(<TR><TD ALIGN="CENTER">#{n}</TD></TR>) }.join('\n')}
|
229
|
-
</TABLE>
|
230
|
-
HEREDOC
|
231
|
-
|
232
|
-
field_table = format_member_rows(node.attributes, hide_members)
|
233
|
-
method_table = format_member_rows(node.methods, hide_members)
|
234
|
-
table_body = [name_html, field_table, method_table].map do |type|
|
235
|
-
next if type.nil?
|
236
|
-
|
237
|
-
<<~TEXT
|
238
|
-
<TR>
|
239
|
-
<TD>#{type}</TD>
|
240
|
-
</TR>
|
241
|
-
TEXT
|
242
|
-
end
|
243
|
-
|
244
|
-
<<~HEREDOC.chomp
|
245
|
-
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
|
246
|
-
#{table_body.compact.join("\n")}
|
247
|
-
</TABLE>
|
248
|
-
HEREDOC
|
249
|
-
end
|
250
|
-
|
251
|
-
def format_document(node)
|
252
|
-
@fontname = node.fontname || DEFAULT_CLASS_FONT
|
253
|
-
@node["fontname"] = "#{@fontname}-bold"
|
254
|
-
|
255
|
-
if node.fidelity
|
256
|
-
hide_members = node.fidelity["hideMembers"]
|
257
|
-
hide_other_classes = node.fidelity["hideOtherClasses"]
|
258
|
-
end
|
259
|
-
classes = (node.classes +
|
260
|
-
node.enums +
|
261
|
-
node.data_types +
|
262
|
-
node.primitives).map do |class_node|
|
263
|
-
graph_node_name = generate_graph_name(class_node.name)
|
264
|
-
|
265
|
-
<<~HEREDOC
|
266
|
-
#{graph_node_name} [
|
267
|
-
shape="plain"
|
268
|
-
fontname="#{@fontname || DEFAULT_CLASS_FONT}"
|
269
|
-
label=<#{format_class(class_node, hide_members)}>]
|
270
|
-
HEREDOC
|
271
|
-
end.join("\n")
|
272
|
-
associations = node.classes.map(&:associations).compact.flatten +
|
273
|
-
node.associations
|
274
|
-
if node.groups
|
275
|
-
associations = sort_by_document_groupping(node.groups,
|
276
|
-
associations)
|
277
|
-
end
|
278
|
-
classes_names = node.classes.map(&:name)
|
279
|
-
associations = associations.map do |assoc_node|
|
280
|
-
if hide_other_classes &&
|
281
|
-
!classes_names.include?(assoc_node.member_end)
|
282
|
-
next
|
283
|
-
end
|
284
|
-
|
285
|
-
format_relationship(assoc_node)
|
286
|
-
end.join("\n")
|
287
|
-
|
288
|
-
classes = classes.lines.map { |line| " #{line}" }.join.chomp
|
289
|
-
associations = associations
|
290
|
-
.lines.map { |line| " #{line}" }.join.chomp
|
291
|
-
|
292
|
-
<<~HEREDOC
|
293
|
-
digraph G {
|
294
|
-
graph [#{@graph}]
|
295
|
-
edge [#{@edge}]
|
296
|
-
node [#{@node}]
|
297
|
-
|
298
|
-
#{classes}
|
299
|
-
|
300
|
-
#{associations}
|
301
|
-
}
|
302
|
-
HEREDOC
|
303
|
-
end
|
304
|
-
|
305
|
-
protected
|
306
|
-
|
307
|
-
def sort_by_document_groupping(groups, associations)
|
308
|
-
result = []
|
309
|
-
groups.each do |batch|
|
310
|
-
batch.each do |group_name|
|
311
|
-
associations
|
312
|
-
.select { |assc| assc.owner_end == group_name }
|
313
|
-
.each do |association|
|
314
|
-
result.push(association) unless result.include?(association)
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
associations.each do |association|
|
319
|
-
result.push(association) unless result.include?(association)
|
320
|
-
end
|
321
|
-
result
|
322
|
-
end
|
323
|
-
|
324
|
-
def generate_from_dot(input)
|
325
|
-
Lutaml::Layout::GraphVizEngine.new(input: input).render(@type)
|
326
|
-
end
|
327
|
-
|
328
|
-
def generate_graph_name(name)
|
329
|
-
name.gsub(/[^0-9a-zA-Z]/i, "")
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
end
|
334
|
-
end
|
data/lib/lutaml/uml/formatter.rb
DELETED
@@ -1,21 +0,0 @@
|
|
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"
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lutaml
|
4
|
-
module Uml
|
5
|
-
module HasAttributes
|
6
|
-
def update_attributes(attributes = {})
|
7
|
-
attributes.to_h.each do |name, value|
|
8
|
-
value = value.respond_to?(:str) ? value.str : value
|
9
|
-
public_send("#{name}=", value)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lutaml
|
4
|
-
module Uml
|
5
|
-
module HasMembers
|
6
|
-
class UnknownMemberTypeError < StandardError; end
|
7
|
-
|
8
|
-
# TODO: move to Parslet::Transform
|
9
|
-
def members=(value)
|
10
|
-
value.group_by { |member| member.keys.first }
|
11
|
-
.each do |(type, group)|
|
12
|
-
attribute_value = group.map(&:values).flatten
|
13
|
-
if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash)
|
14
|
-
next public_send("#{associtaion_type(type)}=", attribute_value.first)
|
15
|
-
end
|
16
|
-
|
17
|
-
public_send("#{associtaion_type(type)}=", attribute_value)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def associtaion_type(type)
|
24
|
-
return type if respond_to?("#{type}=")
|
25
|
-
|
26
|
-
raise(UnknownMemberTypeError, "Unknown member type: #{type}")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/lutaml/uml/instance.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lutaml
|
4
|
-
module Uml
|
5
|
-
class Instance < TopElement
|
6
|
-
attr_accessor :classifier, :slot
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@name = nil
|
10
|
-
@xmi_id = nil
|
11
|
-
@xmi_uuid = nil
|
12
|
-
@classifier = nil
|
13
|
-
@slot = []
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/lutaml/uml/model.rb
DELETED
data/lib/lutaml/uml/node/base.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "lutaml/uml/has_attributes"
|
4
|
-
|
5
|
-
module Lutaml
|
6
|
-
module Uml
|
7
|
-
module Node
|
8
|
-
class Base
|
9
|
-
include HasAttributes
|
10
|
-
|
11
|
-
# rubocop:disable Rails/ActiveRecordAliases
|
12
|
-
def initialize(attributes = {})
|
13
|
-
update_attributes(attributes)
|
14
|
-
end
|
15
|
-
# rubocop:enable Rails/ActiveRecordAliases
|
16
|
-
|
17
|
-
attr_accessor :parent
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "lutaml/uml/node/base"
|
4
|
-
require "lutaml/uml/node/field"
|
5
|
-
require "lutaml/uml/node/method"
|
6
|
-
require "lutaml/uml/node/relationship"
|
7
|
-
require "lutaml/uml/node/class_relationship"
|
8
|
-
require "lutaml/uml/node/has_name"
|
9
|
-
|
10
|
-
module Lutaml
|
11
|
-
module Uml
|
12
|
-
module Node
|
13
|
-
class ClassNode < Base
|
14
|
-
include HasName
|
15
|
-
|
16
|
-
attr_reader :modifier
|
17
|
-
|
18
|
-
def modifier=(value)
|
19
|
-
@modifier = value.to_s # TODO: Validate?
|
20
|
-
end
|
21
|
-
|
22
|
-
attr_reader :members
|
23
|
-
|
24
|
-
def members=(value)
|
25
|
-
@members = value.to_a.map do |member|
|
26
|
-
type = member.to_a[0][0] # TODO: This is dumb
|
27
|
-
attributes = member.to_a[0][1]
|
28
|
-
attributes[:parent] = self
|
29
|
-
|
30
|
-
case type
|
31
|
-
when :field then Field.new(attributes)
|
32
|
-
when :method then Method.new(attributes)
|
33
|
-
when :relationship then Relationship.new(attributes)
|
34
|
-
when :class_relationship then ClassRelationship.new(attributes)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def fields
|
40
|
-
@members.select { |member| member.class == Field }
|
41
|
-
end
|
42
|
-
|
43
|
-
def methods
|
44
|
-
@members.select { |member| member.class == Method }
|
45
|
-
end
|
46
|
-
|
47
|
-
def relationships
|
48
|
-
@members.select { |member| member.class == Relationship }
|
49
|
-
end
|
50
|
-
|
51
|
-
def class_relationships
|
52
|
-
@members.select { |member| member.class == ClassRelationship }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "lutaml/uml/node/base"
|
4
|
-
require "lutaml/uml/node/class_node"
|
5
|
-
|
6
|
-
module Lutaml
|
7
|
-
module Uml
|
8
|
-
module Node
|
9
|
-
class Document < Base
|
10
|
-
attr_reader :classes
|
11
|
-
|
12
|
-
def classes=(value)
|
13
|
-
@classes = value.to_a.map { |attributes| ClassNode.new(attributes) }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "lutaml/uml/node/base"
|
4
|
-
require "lutaml/uml/node/has_name"
|
5
|
-
require "lutaml/uml/node/has_type"
|
6
|
-
|
7
|
-
module Lutaml
|
8
|
-
module Uml
|
9
|
-
module Node
|
10
|
-
class Field < Base
|
11
|
-
include HasName
|
12
|
-
include HasType
|
13
|
-
|
14
|
-
def initialize(attributes = {})
|
15
|
-
@access = "public"
|
16
|
-
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_reader :static
|
21
|
-
|
22
|
-
def static=(value)
|
23
|
-
@static = !!value
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_reader :access
|
27
|
-
|
28
|
-
def access=(value)
|
29
|
-
@access = value.to_s # TODO: Validate?
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|