lutaml-uml 0.2.0 → 0.2.5
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/.github/workflows/macos.yml +2 -0
- data/.github/workflows/ubuntu.yml +2 -0
- data/.github/workflows/windows.yml +10 -0
- data/.gitignore +1 -1
- data/LUTAML.adoc +31 -6
- data/bin/folder_yaml2lutaml.sh +6 -0
- data/bin/plantuml2lutaml +58 -0
- data/bin/yaml2lutaml +42 -6
- data/lib/lutaml/layout/graph_viz_engine.rb +6 -3
- data/lib/lutaml/uml/class.rb +5 -0
- data/lib/lutaml/uml/data_type.rb +5 -2
- data/lib/lutaml/uml/enum.rb +12 -5
- data/lib/lutaml/uml/formatter/graphviz.rb +11 -12
- data/lib/lutaml/uml/parsers/dsl.rb +29 -5
- data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +1 -1
- data/lib/lutaml/uml/primitive_type.rb +5 -2
- data/lib/lutaml/uml/top_element_attribute.rb +1 -0
- data/lib/lutaml/uml/version.rb +1 -1
- data/lutaml-uml.gemspec +3 -3
- data/spec/fixtures/dsl/diagram_definitions.lutaml +20 -0
- data/spec/lutaml/layout/graph_viz_engine_spec.rb +31 -0
- data/spec/lutaml/uml/parsers/dsl_spec.rb +24 -0
- metadata +31 -29
- data/bin/lutaml2dotpng +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dd197690f8da12b6b7ba5055db64eeb862717769f78ef7acf3477ce0a32f377
|
4
|
+
data.tar.gz: 400e3ead0e0d89f6a781a09a97967ed51d0d955015779334290829ed76d317da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb4a6abf3136b6d1b4e207bd14d889e43ce2be9f9c4f036956702c0f9430c22baebaabd7d281f57feaa923b9ab9531a43be5d7d88276cce0fc8b856a222c807a
|
7
|
+
data.tar.gz: 228355fdf7c6fcb51f5ec0958470d3e0f9ff6fc675f0a6029ecba4c22a597fdef6bdd4d9a2df76bb2d5e2141c5a4227bdd97c2269ec3e2628f9ef3eac8508b78
|
data/.github/workflows/macos.yml
CHANGED
@@ -36,6 +36,16 @@ jobs:
|
|
36
36
|
gem install bundler
|
37
37
|
bundle config --local path vendor/bundle
|
38
38
|
bundle install --jobs 4 --retry 3
|
39
|
+
- name: Install graphviz
|
40
|
+
uses: nick-invision/retry@v1
|
41
|
+
with:
|
42
|
+
polling_interval_seconds: 5
|
43
|
+
timeout_minutes: 5
|
44
|
+
max_attempts: 3
|
45
|
+
command: choco install --no-progress graphviz --version 2.38.0.20190211
|
46
|
+
- name: Check dot command
|
47
|
+
run: |
|
48
|
+
dot -?
|
39
49
|
- name: Run specs
|
40
50
|
run: |
|
41
51
|
bundle exec rake
|
data/.gitignore
CHANGED
data/LUTAML.adoc
CHANGED
@@ -110,6 +110,20 @@ class Relationship {
|
|
110
110
|
class Element {}
|
111
111
|
----
|
112
112
|
|
113
|
+
== Class' multiline "definition" property
|
114
|
+
|
115
|
+
=== Definition
|
116
|
+
|
117
|
+
Full syntax:
|
118
|
+
|
119
|
+
[source,java]
|
120
|
+
----
|
121
|
+
definition
|
122
|
+
inner text
|
123
|
+
end definition
|
124
|
+
----
|
125
|
+
|
126
|
+
|
113
127
|
== Attributes/entries
|
114
128
|
|
115
129
|
=== Definition
|
@@ -118,7 +132,7 @@ Full syntax:
|
|
118
132
|
|
119
133
|
[source,java]
|
120
134
|
----
|
121
|
-
[visibility][/][attribute] name [:type][multiplicity][=initial value][{
|
135
|
+
[visibility][/][attribute] name [:type][multiplicity][=initial value][{attribute body}]
|
122
136
|
----
|
123
137
|
|
124
138
|
where:
|
@@ -128,11 +142,7 @@ where:
|
|
128
142
|
* `/` - symbolizes a derived attribute.
|
129
143
|
* `multiplicity` - Multiplicity is in square brackets (e.g. [1..*]).
|
130
144
|
* `initial value` - Default value specifies the initial value of the attribute.
|
131
|
-
* `
|
132
|
-
** {readonly}: the property can be read but not changed.
|
133
|
-
** {union}: the property is a union of subsets.
|
134
|
-
** {subsets <property>}: the property is a subset of <property>.
|
135
|
-
** {redefines <property>}: the property is a new definition of <property> (overwritten by inheritance).
|
145
|
+
* `{attribute body}` - Body of attribute, additional properties for attribute
|
136
146
|
|
137
147
|
|
138
148
|
One can use explicit or implicit syntax for attribute definition
|
@@ -186,6 +196,21 @@ class Figure {
|
|
186
196
|
}
|
187
197
|
----
|
188
198
|
|
199
|
+
=== Additional attribute' properties
|
200
|
+
|
201
|
+
example:
|
202
|
+
|
203
|
+
[source,java]
|
204
|
+
----
|
205
|
+
class Figure {
|
206
|
+
+ radius {
|
207
|
+
definition
|
208
|
+
Radius of the Figure
|
209
|
+
end definition
|
210
|
+
}
|
211
|
+
}
|
212
|
+
----
|
213
|
+
|
189
214
|
== Methods
|
190
215
|
|
191
216
|
Syntax for defining methods:
|
data/bin/plantuml2lutaml
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# Script to convert plantuml files into LutaML syntax
|
6
|
+
# Usage: bin/plantuml2lutaml /path/to/plantuml.wsd
|
7
|
+
|
8
|
+
file_path = ARGV[0]
|
9
|
+
FILE_NAME = File.basename(file_path, ".wsd")
|
10
|
+
wsd_file = File.new(ARGV[0])
|
11
|
+
|
12
|
+
def sync_puts(line, level = 0)
|
13
|
+
$stdout.puts("#{''.rjust(level)}#{line}")
|
14
|
+
$stdout.flush
|
15
|
+
end
|
16
|
+
|
17
|
+
SKIPPED_LINES_REGEXP = /^(@startuml|'\*{7}|note|@enduml|\!|'\/)/
|
18
|
+
COMMENT_START = /\/'/
|
19
|
+
COMMENT_END = /'\//
|
20
|
+
ASSOCIATION_MAPPINGS = {
|
21
|
+
/-\|>/ => ",inheritance",
|
22
|
+
/<\|-/ => "inheritance,",
|
23
|
+
/->/ => ",direct",
|
24
|
+
/<-/ => "direct,",
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
in_comment_block = false
|
28
|
+
|
29
|
+
def transform_line(line)
|
30
|
+
return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? { |key| line =~ key }
|
31
|
+
|
32
|
+
owner_type, member_type = ASSOCIATION_MAPPINGS.detect { |(key, _value)| line =~ key }.last.split(",")
|
33
|
+
blocks = line.split(" ")
|
34
|
+
owner = blocks.first
|
35
|
+
member = blocks.last
|
36
|
+
sync_puts("association {", 2)
|
37
|
+
sync_puts("owner #{owner}", 4)
|
38
|
+
sync_puts("member #{member}", 4)
|
39
|
+
sync_puts("owner_type #{owner_type}", 4) if !owner_type.to_s.empty?
|
40
|
+
sync_puts("member_type #{member_type}", 4) if !member_type.to_s.empty?
|
41
|
+
sync_puts("}", 2)
|
42
|
+
end
|
43
|
+
|
44
|
+
sync_puts("diagram #{FILE_NAME} {")
|
45
|
+
wsd_file.readlines.each do |line|
|
46
|
+
if line.match?(COMMENT_START)
|
47
|
+
in_comment_block = true
|
48
|
+
end
|
49
|
+
|
50
|
+
if line.match?(COMMENT_END)
|
51
|
+
in_comment_block = false
|
52
|
+
end
|
53
|
+
|
54
|
+
next if in_comment_block || line =~ SKIPPED_LINES_REGEXP
|
55
|
+
|
56
|
+
transform_line(line)
|
57
|
+
end
|
58
|
+
sync_puts("}")
|
data/bin/yaml2lutaml
CHANGED
@@ -45,7 +45,7 @@ def process_association(owner, values, encountered_relations)
|
|
45
45
|
if source["attribute"]
|
46
46
|
source_attribute_name = source["attribute"].keys.first
|
47
47
|
owner += "##{source_attribute_name}"
|
48
|
-
if source["attribute"][source_attribute_name]["cardinality"]
|
48
|
+
if source["attribute"][source_attribute_name] && source["attribute"][source_attribute_name]["cardinality"]
|
49
49
|
cardinality = source["attribute"][source_attribute_name]["cardinality"]
|
50
50
|
owner += " [#{cardinality['min']}..#{cardinality['max']}]"
|
51
51
|
end
|
@@ -61,7 +61,7 @@ def process_association(owner, values, encountered_relations)
|
|
61
61
|
if target["attribute"]
|
62
62
|
target_attribute_name = target["attribute"].keys.first
|
63
63
|
member += "##{target_attribute_name}"
|
64
|
-
if target["attribute"][target_attribute_name]["cardinality"]
|
64
|
+
if target["attribute"][target_attribute_name] && target["attribute"][target_attribute_name]["cardinality"]
|
65
65
|
cardinality = target["attribute"][target_attribute_name]["cardinality"]
|
66
66
|
member += " [#{cardinality['min']}..#{cardinality['max']}]"
|
67
67
|
end
|
@@ -75,6 +75,7 @@ def process_association(owner, values, encountered_relations)
|
|
75
75
|
end
|
76
76
|
sync_puts("diagram #{File.basename(ARGV[0], 'yml')[0..-2]} {")
|
77
77
|
sync_puts("title '#{view_yaml['title']}'", 2)
|
78
|
+
sync_puts("caption '#{view_yaml['caption']}'", 2)
|
78
79
|
|
79
80
|
# Class associations notations
|
80
81
|
view_yaml["relations"]&.each do |values|
|
@@ -83,20 +84,55 @@ end
|
|
83
84
|
|
84
85
|
view_yaml["imports"].keys.each do |entry|
|
85
86
|
import = YAML.safe_load(File.read(File.join(models_path, "#{entry}.yml")))
|
86
|
-
import_name = import["name"]
|
87
|
+
import_name = import["name"] || File.basename(entry)
|
87
88
|
# Class notation
|
88
|
-
sync_puts("#{import['modelType']} #{
|
89
|
+
sync_puts("#{import['modelType']} #{import_name} {", 2)
|
90
|
+
if import["definition"]
|
91
|
+
definition = <<~TEXT
|
92
|
+
definition
|
93
|
+
#{import['definition']}
|
94
|
+
end definition
|
95
|
+
TEXT
|
96
|
+
sync_puts(definition, 4)
|
97
|
+
end
|
89
98
|
import["values"]&.each_pair do |key, values|
|
90
|
-
|
99
|
+
result_string = key
|
100
|
+
if values["definition"]
|
101
|
+
result_string += <<~TEXT
|
102
|
+
{
|
103
|
+
definition
|
104
|
+
#{values['definition']}
|
105
|
+
end definition
|
106
|
+
}
|
107
|
+
TEXT
|
108
|
+
end
|
109
|
+
sync_puts(result_string, 4)
|
91
110
|
end
|
92
111
|
import["attributes"]&.each_pair do |key, values|
|
112
|
+
definition = values["definition"]
|
93
113
|
cardinality = if values["cardinality"]
|
94
114
|
cardinality_val = values["cardinality"]
|
95
115
|
"[#{cardinality_val['min']}..#{cardinality_val['max']}]"
|
96
116
|
else
|
97
117
|
""
|
98
118
|
end
|
99
|
-
|
119
|
+
result_string = "+#{key}"
|
120
|
+
if values["type"]
|
121
|
+
result_string += ": #{values['type']}"
|
122
|
+
end
|
123
|
+
if cardinality
|
124
|
+
result_string += " #{cardinality}"
|
125
|
+
end
|
126
|
+
if definition
|
127
|
+
result_string += <<~TEXT
|
128
|
+
{
|
129
|
+
definition
|
130
|
+
#{definition}
|
131
|
+
end definition
|
132
|
+
}
|
133
|
+
TEXT
|
134
|
+
end
|
135
|
+
sync_puts(result_string, 4)
|
100
136
|
end
|
101
137
|
sync_puts("}", 2)
|
102
138
|
|
@@ -7,9 +7,12 @@ module Lutaml
|
|
7
7
|
module Layout
|
8
8
|
class GraphVizEngine < Engine
|
9
9
|
def render(type)
|
10
|
-
|
11
|
-
.
|
12
|
-
.
|
10
|
+
Open3.popen3("dot -T#{type}") do |stdin, stdout, _stderr, _wait|
|
11
|
+
stdin.puts(input)
|
12
|
+
stdin.close
|
13
|
+
# unless (err = stderr.read).empty? then raise err end
|
14
|
+
stdout.read
|
15
|
+
end
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
data/lib/lutaml/uml/class.rb
CHANGED
@@ -16,6 +16,7 @@ module Lutaml
|
|
16
16
|
|
17
17
|
attr_reader :associations,
|
18
18
|
:attributes,
|
19
|
+
:definition,
|
19
20
|
:members,
|
20
21
|
:modifier
|
21
22
|
|
@@ -31,6 +32,10 @@ module Lutaml
|
|
31
32
|
@modifier = value.to_s # TODO: Validate?
|
32
33
|
end
|
33
34
|
|
35
|
+
def definition=(value)
|
36
|
+
@definition = value.to_s
|
37
|
+
end
|
38
|
+
|
34
39
|
def attributes=(value)
|
35
40
|
@attributes = value.to_a.map do |attr|
|
36
41
|
TopElementAttribute.new(attr)
|
data/lib/lutaml/uml/data_type.rb
CHANGED
data/lib/lutaml/uml/enum.rb
CHANGED
@@ -12,7 +12,14 @@ module Lutaml
|
|
12
12
|
|
13
13
|
attr_reader :attributes,
|
14
14
|
:members,
|
15
|
-
:modifier
|
15
|
+
:modifier,
|
16
|
+
:definition,
|
17
|
+
:keyword
|
18
|
+
|
19
|
+
def initialize(attributes = {})
|
20
|
+
super
|
21
|
+
@keyword = "enumeration"
|
22
|
+
end
|
16
23
|
|
17
24
|
def attributes=(value)
|
18
25
|
@attributes = value.to_a.map do |attr|
|
@@ -20,14 +27,14 @@ module Lutaml
|
|
20
27
|
end
|
21
28
|
end
|
22
29
|
|
30
|
+
def definition=(value)
|
31
|
+
@definition = value.to_s
|
32
|
+
end
|
33
|
+
|
23
34
|
# TODO: reserved name, change
|
24
35
|
def methods
|
25
36
|
[]
|
26
37
|
end
|
27
|
-
|
28
|
-
def keyword
|
29
|
-
"enumeration"
|
30
|
-
end
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
@@ -181,8 +181,10 @@ module Lutaml
|
|
181
181
|
end
|
182
182
|
# swap labels and arrows if `dir` eq to `back`
|
183
183
|
if attributes["dir"] == "back"
|
184
|
-
attributes["arrowhead"], attributes["arrowtail"] =
|
185
|
-
|
184
|
+
attributes["arrowhead"], attributes["arrowtail"] =
|
185
|
+
[attributes["arrowtail"], attributes["arrowhead"]]
|
186
|
+
attributes["headlabel"], attributes["taillabel"] =
|
187
|
+
[attributes["taillabel"], attributes["headlabel"]]
|
186
188
|
end
|
187
189
|
attributes
|
188
190
|
end
|
@@ -226,8 +228,6 @@ module Lutaml
|
|
226
228
|
#{name.map { |n| %(<TR><TD ALIGN="CENTER">#{n}</TD></TR>) }.join('\n')}
|
227
229
|
</TABLE>
|
228
230
|
HEREDOC
|
229
|
-
# name = "«abstract»<BR/><I>#{name}</I>" if node.modifier == "abstract"
|
230
|
-
# name = "«interface»<BR/>#{name}" if node.modifier == "interface"
|
231
231
|
|
232
232
|
field_table = format_member_rows(node.attributes, hide_members)
|
233
233
|
method_table = format_member_rows(node.methods, hide_members)
|
@@ -256,7 +256,10 @@ module Lutaml
|
|
256
256
|
hide_members = node.fidelity["hideMembers"]
|
257
257
|
hide_other_classes = node.fidelity["hideOtherClasses"]
|
258
258
|
end
|
259
|
-
classes = (node.classes +
|
259
|
+
classes = (node.classes +
|
260
|
+
node.enums +
|
261
|
+
node.data_types +
|
262
|
+
node.primitives).map do |class_node|
|
260
263
|
graph_node_name = generate_graph_name(class_node.name)
|
261
264
|
|
262
265
|
<<~HEREDOC
|
@@ -269,7 +272,8 @@ module Lutaml
|
|
269
272
|
associations = node.classes.map(&:associations).compact.flatten +
|
270
273
|
node.associations
|
271
274
|
if node.groups
|
272
|
-
associations = sort_by_document_groupping(node.groups,
|
275
|
+
associations = sort_by_document_groupping(node.groups,
|
276
|
+
associations)
|
273
277
|
end
|
274
278
|
classes_names = node.classes.map(&:name)
|
275
279
|
associations = associations.map do |assoc_node|
|
@@ -318,12 +322,7 @@ module Lutaml
|
|
318
322
|
end
|
319
323
|
|
320
324
|
def generate_from_dot(input)
|
321
|
-
|
322
|
-
# Ruby-Graphviz has an old bug when html labels was not displayed
|
323
|
-
# property because of `<` and `>` characters escape, add additional
|
324
|
-
# `<` and `>` symbols to workaround it
|
325
|
-
escaped_dot = input.gsub("<<", "<<<").gsub(">>", ">>>")
|
326
|
-
Lutaml::Layout::GraphVizEngine.new(input: escaped_dot).render(@type)
|
325
|
+
Lutaml::Layout::GraphVizEngine.new(input: input).render(@type)
|
327
326
|
end
|
328
327
|
|
329
328
|
def generate_graph_name(name)
|
@@ -53,6 +53,7 @@ module Lutaml
|
|
53
53
|
realizes
|
54
54
|
static
|
55
55
|
title
|
56
|
+
caption
|
56
57
|
].freeze
|
57
58
|
|
58
59
|
KEYWORDS.each do |keyword|
|
@@ -61,7 +62,9 @@ module Lutaml
|
|
61
62
|
|
62
63
|
rule(:spaces) { match("\s").repeat(1) }
|
63
64
|
rule(:spaces?) { spaces.maybe }
|
64
|
-
rule(:whitespace)
|
65
|
+
rule(:whitespace) do
|
66
|
+
(match("\s") | match("\r?\n") | match("\r") | str(";")).repeat(1)
|
67
|
+
end
|
65
68
|
rule(:whitespace?) { whitespace.maybe }
|
66
69
|
rule(:name) { match["a-zA-Z0-9 _-"].repeat(1) }
|
67
70
|
rule(:newline) { str("\n") >> str("\r").maybe }
|
@@ -104,7 +107,7 @@ module Lutaml
|
|
104
107
|
rule(:method_abstract) { (kw_abstract.as(:abstract) >> spaces).maybe }
|
105
108
|
rule(:attribute_keyword) do
|
106
109
|
str("<<") >>
|
107
|
-
match['a-zA-Z0-9_
|
110
|
+
match['a-zA-Z0-9_\-\/'].repeat(1).as(:keyword) >>
|
108
111
|
str(">>")
|
109
112
|
end
|
110
113
|
rule(:attribute_keyword?) { attribute_keyword.maybe }
|
@@ -130,7 +133,8 @@ module Lutaml
|
|
130
133
|
attribute_name >>
|
131
134
|
match['"\''].maybe >>
|
132
135
|
attribute_type? >>
|
133
|
-
cardinality?
|
136
|
+
cardinality? >>
|
137
|
+
class_body?)
|
134
138
|
.as(:attributes)
|
135
139
|
end
|
136
140
|
|
@@ -141,6 +145,13 @@ module Lutaml
|
|
141
145
|
match['"\''].maybe
|
142
146
|
end
|
143
147
|
rule(:title_definition) { title_keyword >> title_text }
|
148
|
+
rule(:caption_keyword) { kw_caption >> spaces }
|
149
|
+
rule(:caption_text) do
|
150
|
+
match['"\''].maybe >>
|
151
|
+
match['a-zA-Z0-9_\- '].repeat(1).as(:caption) >>
|
152
|
+
match['"\''].maybe
|
153
|
+
end
|
154
|
+
rule(:caption_definition) { caption_keyword >> caption_text }
|
144
155
|
|
145
156
|
rule(:fontname_keyword) { kw_fontname >> spaces }
|
146
157
|
rule(:fontname_text) do
|
@@ -250,7 +261,8 @@ module Lutaml
|
|
250
261
|
end
|
251
262
|
rule(:class_keyword) { kw_class >> spaces }
|
252
263
|
rule(:class_inner_definitions) do
|
253
|
-
|
264
|
+
definition_body |
|
265
|
+
attribute_definition |
|
254
266
|
comment_definition |
|
255
267
|
comment_multiline_definition
|
256
268
|
end
|
@@ -274,10 +286,21 @@ module Lutaml
|
|
274
286
|
class_body?
|
275
287
|
end
|
276
288
|
|
289
|
+
# -- Definition
|
290
|
+
rule(:definition_body) do
|
291
|
+
spaces? >>
|
292
|
+
str("definition") >>
|
293
|
+
whitespace? >>
|
294
|
+
(str("end definition").absent? >> any).repeat.as(:definition) >>
|
295
|
+
whitespace? >>
|
296
|
+
str("end definition")
|
297
|
+
end
|
298
|
+
|
277
299
|
# -- Enum
|
278
300
|
rule(:enum_keyword) { kw_enum >> spaces }
|
279
301
|
rule(:enum_inner_definitions) do
|
280
|
-
|
302
|
+
definition_body |
|
303
|
+
attribute_definition |
|
281
304
|
comment_definition |
|
282
305
|
comment_multiline_definition
|
283
306
|
end
|
@@ -337,6 +360,7 @@ module Lutaml
|
|
337
360
|
rule(:diagram_keyword) { kw_diagram >> spaces? }
|
338
361
|
rule(:diagram_inner_definitions) do
|
339
362
|
title_definition |
|
363
|
+
caption_definition |
|
340
364
|
fontname_definition |
|
341
365
|
class_definition.as(:classes) |
|
342
366
|
enum_definition.as(:enums) |
|
@@ -27,7 +27,7 @@ module Lutaml
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def process_include_line(include_root, line)
|
30
|
-
include_path_match = line.match(
|
30
|
+
include_path_match = line.match(/^\s*include\s+(.+)/)
|
31
31
|
return line if include_path_match.nil?
|
32
32
|
|
33
33
|
path_to_file = include_path_match[1].strip
|
data/lib/lutaml/uml/version.rb
CHANGED
data/lutaml-uml.gemspec
CHANGED
@@ -29,12 +29,12 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency "parslet", "~> 1.7.1"
|
30
30
|
spec.add_runtime_dependency "ruby-graphviz", "~> 1.2"
|
31
31
|
spec.add_runtime_dependency "thor", "~> 1.0"
|
32
|
-
spec.add_development_dependency "byebug"
|
33
|
-
spec.add_development_dependency "nokogiri", "~> 1.10"
|
34
|
-
spec.add_development_dependency "rubocop", "~> 0.54.0"
|
35
32
|
|
36
33
|
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
+
spec.add_development_dependency "byebug"
|
35
|
+
spec.add_development_dependency "nokogiri", "~> 1.10"
|
37
36
|
spec.add_development_dependency "pry", "~> 0.12.2"
|
38
37
|
spec.add_development_dependency "rake", "~> 10.0"
|
39
38
|
spec.add_development_dependency "rspec", "~> 3.0"
|
39
|
+
spec.add_development_dependency "rubocop", "~> 0.54.0"
|
40
40
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
diagram MyView {
|
2
|
+
title "my diagram"
|
3
|
+
|
4
|
+
class AddressClassProfile {
|
5
|
+
definition
|
6
|
+
this is multiline with `ascidoc`
|
7
|
+
comments
|
8
|
+
and list
|
9
|
+
end definition
|
10
|
+
+addressClassProfile: CharacterString [0..1]
|
11
|
+
}
|
12
|
+
|
13
|
+
class AttributeProfile {
|
14
|
+
imlicistAttributeProfile: CharacterString [0..1] {
|
15
|
+
definition this is attribute definition
|
16
|
+
with multiply lines
|
17
|
+
end definition
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.describe Lutaml::Layout::GraphVizEngine do
|
6
|
+
describe "#render" do
|
7
|
+
subject(:render) do
|
8
|
+
described_class.new(input: input).render(type)
|
9
|
+
end
|
10
|
+
let(:input) do
|
11
|
+
File.read(fixtures_path("generated_dot/AddressClassProfile.dot"))
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when png output type" do
|
15
|
+
let(:type) { "png" }
|
16
|
+
let(:png_header) { "\x89PNG" }
|
17
|
+
|
18
|
+
it "renders input as png binary string" do
|
19
|
+
expect(render[0..3]).to(eq(png_header))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when dot output type" do
|
24
|
+
let(:type) { "dot" }
|
25
|
+
|
26
|
+
it "renders input as dot string" do
|
27
|
+
expect(render).to(match("digraph G {"))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -248,5 +248,29 @@ RSpec.describe Lutaml::Uml::Parsers::Dsl do
|
|
248
248
|
|
249
249
|
it_behaves_like "the correct graphviz formatting"
|
250
250
|
end
|
251
|
+
|
252
|
+
context "when defninition directives included" do
|
253
|
+
let(:content) do
|
254
|
+
File.new(fixtures_path("dsl/diagram_definitions.lutaml"))
|
255
|
+
end
|
256
|
+
let(:class_definition) do
|
257
|
+
"this is multiline with `ascidoc`\n comments\n and list"
|
258
|
+
end
|
259
|
+
let(:attribute_definition) do
|
260
|
+
"this is attribute definition\n with multiply lines"
|
261
|
+
end
|
262
|
+
|
263
|
+
it "create comments for document and classes" do
|
264
|
+
expect(by_name(parse.classes, "AddressClassProfile").definition)
|
265
|
+
.to(eq(class_definition))
|
266
|
+
expect(by_name(parse.classes, "AttributeProfile")
|
267
|
+
.attributes
|
268
|
+
.first
|
269
|
+
.definition)
|
270
|
+
.to(eq(attribute_definition))
|
271
|
+
end
|
272
|
+
|
273
|
+
it_behaves_like "the correct graphviz formatting"
|
274
|
+
end
|
251
275
|
end
|
252
276
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml-uml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -81,61 +81,47 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: nokogiri
|
84
|
+
name: bundler
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '2.0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '2.0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: byebug
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- - "
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
103
|
+
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- - "
|
108
|
+
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0
|
110
|
+
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: nokogiri
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
117
|
+
version: '1.10'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
124
|
+
version: '1.10'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: pry
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +164,20 @@ dependencies:
|
|
178
164
|
- - "~>"
|
179
165
|
- !ruby/object:Gem::Version
|
180
166
|
version: '3.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.54.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.54.0
|
181
181
|
description: UML model module for LutaML.
|
182
182
|
email:
|
183
183
|
- open.source@ribose.com'
|
@@ -194,12 +194,12 @@ files:
|
|
194
194
|
- ".travis.yml"
|
195
195
|
- CODE_OF_CONDUCT.md
|
196
196
|
- Gemfile
|
197
|
-
- Gemfile.lock
|
198
197
|
- LUTAML.adoc
|
199
198
|
- README.adoc
|
200
199
|
- Rakefile
|
201
200
|
- bin/console
|
202
|
-
- bin/
|
201
|
+
- bin/folder_yaml2lutaml.sh
|
202
|
+
- bin/plantuml2lutaml
|
203
203
|
- bin/setup
|
204
204
|
- bin/yaml2lutaml
|
205
205
|
- exe/lutaml-uml
|
@@ -297,12 +297,14 @@ files:
|
|
297
297
|
- spec/fixtures/dsl/diagram_comments.lutaml
|
298
298
|
- spec/fixtures/dsl/diagram_concept_model.lutaml
|
299
299
|
- spec/fixtures/dsl/diagram_data_types.lutaml
|
300
|
+
- spec/fixtures/dsl/diagram_definitions.lutaml
|
300
301
|
- spec/fixtures/dsl/diagram_includes.lutaml
|
301
302
|
- spec/fixtures/dsl/diagram_multiply_classes.lutaml
|
302
303
|
- spec/fixtures/dsl/shared.lutaml
|
303
304
|
- spec/fixtures/dsl/shared1.lutaml
|
304
305
|
- spec/fixtures/generated_dot/AddressClassProfile.dot
|
305
306
|
- spec/fixtures/generated_dot/AddressProfile.dot
|
307
|
+
- spec/lutaml/layout/graph_viz_engine_spec.rb
|
306
308
|
- spec/lutaml/uml/formatter/graphviz_spec.rb
|
307
309
|
- spec/lutaml/uml/parsers/dsl_spec.rb
|
308
310
|
- spec/lutaml/uml/parsers/yaml_spec.rb
|
data/bin/lutaml2dotpng
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# Script to convert lutaml files into dot and png files
|
6
|
-
# Usage: bin/lutaml2dotpng /path/to/lutaml/folder/
|
7
|
-
require "bundler/setup"
|
8
|
-
require "lutaml/uml"
|
9
|
-
|
10
|
-
basedir = ARGV[0]
|
11
|
-
Dir["#{basedir}/*.lutaml"].each do |filename|
|
12
|
-
puts(filename)
|
13
|
-
base_filename = File.basename(filename, '.lutaml')
|
14
|
-
File.open("#{basedir}/#{base_filename}.dot", 'w') do |file|
|
15
|
-
file
|
16
|
-
.puts(Lutaml::Uml::Formatter::Graphviz
|
17
|
-
.new
|
18
|
-
.format_document(
|
19
|
-
Lutaml::Uml::Parsers::Dsl
|
20
|
-
.parse(File.read("#{basedir}/#{base_filename}.lutaml"))))
|
21
|
-
end
|
22
|
-
`dot -T png #{"#{basedir}/#{base_filename}.dot"} > "#{basedir}/#{base_filename}.png"`
|
23
|
-
end
|