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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +22 -0
  3. data/Gemfile +1 -5
  4. data/README.adoc +4 -42
  5. data/Rakefile +0 -5
  6. data/lutaml-uml.gemspec +23 -38
  7. metadata +20 -292
  8. data/.github/workflows/macos.yml +0 -38
  9. data/.github/workflows/ubuntu.yml +0 -40
  10. data/.github/workflows/windows.yml +0 -51
  11. data/.gitignore +0 -12
  12. data/.rspec +0 -3
  13. data/.travis.yml +0 -6
  14. data/CODE_OF_CONDUCT.md +0 -74
  15. data/LUTAML.adoc +0 -344
  16. data/bin/console +0 -15
  17. data/bin/folder_yaml2lutaml.sh +0 -6
  18. data/bin/plantuml2lutaml +0 -59
  19. data/bin/setup +0 -8
  20. data/bin/yaml2lutaml +0 -144
  21. data/exe/lutaml-wsd2uml +0 -59
  22. data/exe/lutaml-yaml2uml +0 -144
  23. data/lib/lutaml/layout/engine.rb +0 -15
  24. data/lib/lutaml/layout/graph_viz_engine.rb +0 -19
  25. data/lib/lutaml/uml/abstraction.rb +0 -11
  26. data/lib/lutaml/uml/activity.rb +0 -11
  27. data/lib/lutaml/uml/actor.rb +0 -19
  28. data/lib/lutaml/uml/association.rb +0 -41
  29. data/lib/lutaml/uml/behavior.rb +0 -11
  30. data/lib/lutaml/uml/class.rb +0 -83
  31. data/lib/lutaml/uml/classifier.rb +0 -11
  32. data/lib/lutaml/uml/connector.rb +0 -21
  33. data/lib/lutaml/uml/constraint.rb +0 -12
  34. data/lib/lutaml/uml/constructor_end.rb +0 -16
  35. data/lib/lutaml/uml/data_type.rb +0 -75
  36. data/lib/lutaml/uml/dependency.rb +0 -21
  37. data/lib/lutaml/uml/diagram.rb +0 -8
  38. data/lib/lutaml/uml/document.rb +0 -81
  39. data/lib/lutaml/uml/enum.rb +0 -45
  40. data/lib/lutaml/uml/event.rb +0 -12
  41. data/lib/lutaml/uml/final_state.rb +0 -11
  42. data/lib/lutaml/uml/formatter/base.rb +0 -67
  43. data/lib/lutaml/uml/formatter/graphviz.rb +0 -334
  44. data/lib/lutaml/uml/formatter.rb +0 -21
  45. data/lib/lutaml/uml/has_attributes.rb +0 -14
  46. data/lib/lutaml/uml/has_members.rb +0 -30
  47. data/lib/lutaml/uml/instance.rb +0 -17
  48. data/lib/lutaml/uml/model.rb +0 -13
  49. data/lib/lutaml/uml/node/base.rb +0 -21
  50. data/lib/lutaml/uml/node/class_node.rb +0 -57
  51. data/lib/lutaml/uml/node/class_relationship.rb +0 -14
  52. data/lib/lutaml/uml/node/document.rb +0 -18
  53. data/lib/lutaml/uml/node/field.rb +0 -34
  54. data/lib/lutaml/uml/node/has_name.rb +0 -15
  55. data/lib/lutaml/uml/node/has_type.rb +0 -15
  56. data/lib/lutaml/uml/node/method.rb +0 -29
  57. data/lib/lutaml/uml/node/method_argument.rb +0 -16
  58. data/lib/lutaml/uml/node/relationship.rb +0 -28
  59. data/lib/lutaml/uml/opaque_behavior.rb +0 -11
  60. data/lib/lutaml/uml/operation.rb +0 -31
  61. data/lib/lutaml/uml/package.rb +0 -53
  62. data/lib/lutaml/uml/parsers/attribute.rb +0 -70
  63. data/lib/lutaml/uml/parsers/dsl.rb +0 -413
  64. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +0 -59
  65. data/lib/lutaml/uml/parsers/dsl_transform.rb +0 -27
  66. data/lib/lutaml/uml/parsers/yaml.rb +0 -46
  67. data/lib/lutaml/uml/port.rb +0 -8
  68. data/lib/lutaml/uml/primitive_type.rb +0 -14
  69. data/lib/lutaml/uml/property.rb +0 -27
  70. data/lib/lutaml/uml/pseudostate.rb +0 -11
  71. data/lib/lutaml/uml/realization.rb +0 -11
  72. data/lib/lutaml/uml/region.rb +0 -12
  73. data/lib/lutaml/uml/serializers/association.rb +0 -58
  74. data/lib/lutaml/uml/serializers/base.rb +0 -16
  75. data/lib/lutaml/uml/serializers/class.rb +0 -29
  76. data/lib/lutaml/uml/serializers/top_element_attribute.rb +0 -14
  77. data/lib/lutaml/uml/serializers/yaml_view.rb +0 -18
  78. data/lib/lutaml/uml/state.rb +0 -12
  79. data/lib/lutaml/uml/state_machine.rb +0 -12
  80. data/lib/lutaml/uml/top_element.rb +0 -58
  81. data/lib/lutaml/uml/top_element_attribute.rb +0 -37
  82. data/lib/lutaml/uml/transition.rb +0 -12
  83. data/lib/lutaml/uml/trigger.rb +0 -12
  84. data/lib/lutaml/uml/value.rb +0 -30
  85. data/lib/lutaml/uml/version.rb +0 -7
  86. data/lib/lutaml/uml/vertex.rb +0 -11
  87. data/lib/lutaml/uml.rb +0 -13
  88. data/spec/fixtures/datamodel/models/AddressClassProfile.yml +0 -90
  89. data/spec/fixtures/datamodel/models/AddressComponentProfile.yml +0 -63
  90. data/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +0 -15
  91. data/spec/fixtures/datamodel/models/AddressProfile.yml +0 -36
  92. data/spec/fixtures/datamodel/models/AttributeProfile.yml +0 -32
  93. data/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +0 -79
  94. data/spec/fixtures/datamodel/models/Localization copy.yml +0 -23
  95. data/spec/fixtures/datamodel/models/Localization.yml +0 -23
  96. data/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +0 -36
  97. data/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +0 -15
  98. data/spec/fixtures/datamodel/models/Signature.yml +0 -20
  99. data/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +0 -20
  100. data/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +0 -16
  101. data/spec/fixtures/datamodel/models/TextDirectionCode.yml +0 -16
  102. data/spec/fixtures/datamodel/models/Validity.yml +0 -14
  103. data/spec/fixtures/datamodel/models/iso19160-1/Address.yml +0 -22
  104. data/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +0 -2
  105. data/spec/fixtures/datamodel/style.uml.inc +0 -37
  106. data/spec/fixtures/datamodel/views/AddressClassProfile.yml +0 -12
  107. data/spec/fixtures/datamodel/views/AddressProfile.yml +0 -3
  108. data/spec/fixtures/datamodel/views/CommonModels.yml +0 -9
  109. data/spec/fixtures/datamodel/views/TopDown.yml +0 -62
  110. data/spec/fixtures/dsl/broken_diagram.lutaml +0 -34
  111. data/spec/fixtures/dsl/diagram.lutaml +0 -3
  112. data/spec/fixtures/dsl/diagram_attributes.lutaml +0 -5
  113. data/spec/fixtures/dsl/diagram_blank_definion.lutaml +0 -6
  114. data/spec/fixtures/dsl/diagram_blank_entities.lutaml +0 -8
  115. data/spec/fixtures/dsl/diagram_class_assocation.lutaml +0 -29
  116. data/spec/fixtures/dsl/diagram_class_fields.lutaml +0 -25
  117. data/spec/fixtures/dsl/diagram_commented_includes.lutaml +0 -5
  118. data/spec/fixtures/dsl/diagram_comments.lutaml +0 -28
  119. data/spec/fixtures/dsl/diagram_concept_model.lutaml +0 -132
  120. data/spec/fixtures/dsl/diagram_data_types.lutaml +0 -44
  121. data/spec/fixtures/dsl/diagram_definitions.lutaml +0 -25
  122. data/spec/fixtures/dsl/diagram_includes.lutaml +0 -6
  123. data/spec/fixtures/dsl/diagram_multiply_classes.lutaml +0 -7
  124. data/spec/fixtures/dsl/diagram_non_existing_include.lutaml +0 -6
  125. data/spec/fixtures/dsl/shared.lutaml +0 -3
  126. data/spec/fixtures/dsl/shared1.lutaml +0 -4
  127. data/spec/fixtures/generated_dot/AddressClassProfile.dot +0 -170
  128. data/spec/fixtures/generated_dot/AddressProfile.dot +0 -34
  129. data/spec/lutaml/layout/graph_viz_engine_spec.rb +0 -31
  130. data/spec/lutaml/uml/formatter/graphviz_spec.rb +0 -41
  131. data/spec/lutaml/uml/parsers/dsl_spec.rb +0 -343
  132. data/spec/lutaml/uml/parsers/yaml_spec.rb +0 -18
  133. data/spec/lutaml/uml/serializers/yaml_view_spec.rb +0 -20
  134. data/spec/lutaml/uml_spec.rb +0 -7
  135. data/spec/spec_helper.rb +0 -25
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at ronald.tse@ribose.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/LUTAML.adoc DELETED
@@ -1,344 +0,0 @@
1
- = LutaML syntax
2
-
3
- == `diagram` syntax
4
-
5
- `diagram` is a root element for each diagram.
6
-
7
- [source,java]
8
- ----
9
- diagram MyView {
10
- title "My diagram"
11
- caption "My custom caption"
12
- fontname "Helvetica"
13
- }
14
- ----
15
-
16
- where:
17
-
18
- * `fontname` - optional, configuration option to use supplied font name
19
- * `title` - optional, set custom title for diagram
20
- * `caption` - optional, set custom caption for diagram
21
-
22
- == DataTypes
23
-
24
- Lutaml supports 3 types of data_types: `data_type`, `primitive` and `enum`. Example of data types declaration:
25
-
26
- [source,java]
27
- ----
28
- diagram MyView {
29
- enum MyEnum {}
30
-
31
- enum AddressClassProfile {
32
- +addressClassProfile: CharacterString
33
- }
34
-
35
- data_type "Banking Information" {
36
- "art code"
37
- "CCT Number"
38
- }
39
-
40
- primitive Integer
41
-
42
- enum Profile {
43
- imlicistAttributeProfile: CharacterString
44
- +attributeProfile: CharacterString
45
- -privateAttributeProfile: CharacterString
46
- ~friendlyAttributeProfile: CharacterString
47
- #protectedAttributeProfile: CharacterString
48
- }
49
- }
50
- ----
51
-
52
- == Associations
53
-
54
- === Explicit declaration
55
-
56
- Syntax:
57
-
58
- [source,java]
59
- ----
60
- association name {
61
- owned_type association|composition|aggregation|generalization|uses
62
- member_type association|composition|aggregation|generalization|uses
63
- owned association_name[#attribute_name] [{property_string}][cardinality]
64
- member association_name[#attribute_name] [{property_string}][cardinality]
65
- }
66
- ----
67
-
68
- where:
69
-
70
- * `owned_type` - optional, use to define bidirectional association(association|composition|aggregation|generalization|uses)
71
- * `member_type` - association type(association|composition|aggregation|generalization|uses)
72
- * `owned|member` - end of association, use `\#attribute_name` to set a role name
73
- * `property_string` - property string for attibutes associations
74
- * `cardinality` - examples: '1..*', '*'
75
-
76
- Example:
77
-
78
- [source,java]
79
- ----
80
- class Association {
81
- +association:
82
- }
83
- class Type {
84
- +endType:
85
- }
86
-
87
- association AssociatingTypeAndAssociation {
88
- type uses
89
- from Association#+association {subsets relationship}[*]
90
- to Type#+/endType {readOnly, subsets relatedElement} [1..*]
91
- }
92
- ----
93
-
94
- === Undirected associations
95
-
96
- The simplest way to define relationship between two classes is to use `generalize` keyword:
97
-
98
- [source,java]
99
- ----
100
- class Pet {}
101
- class Cat {
102
- generalize Pet
103
- }
104
- ----
105
-
106
- === Attribute relationship
107
-
108
- Derived attribute `relatedElement` can have 1 to many `Element` associated with it through `union`
109
-
110
- [source,java]
111
- ----
112
- class Relationship {
113
- +/relatedElement: Element[1..*] {union}
114
- }
115
- class Element {}
116
- ----
117
-
118
- == Class' multiline "definition" property
119
-
120
- === Definition
121
-
122
- Full syntax:
123
-
124
- [source,java]
125
- ----
126
- definition {
127
- inner text
128
- }
129
- ----
130
-
131
-
132
- == Attributes/entries
133
-
134
- === Definition
135
-
136
- Full syntax:
137
-
138
- [source,java]
139
- ----
140
- [visibility][/][attribute] name [:type][multiplicity][=initial value][{attribute body}]
141
- ----
142
-
143
- where:
144
-
145
- * `visibility` can be equal to `-` - private, `+` - public, `#` - protected, `~` - friendly
146
- * `attribute` - attrbute keyword
147
- * `/` - symbolizes a derived attribute.
148
- * `multiplicity` - Multiplicity is in square brackets (e.g. [1..*]).
149
- * `initial value` - Default value specifies the initial value of the attribute.
150
- * `{attribute body}` - Body of attribute, additional properties for attribute
151
-
152
-
153
- One can use explicit or implicit syntax for attribute definition
154
-
155
- explicit syntax:
156
-
157
- [source,java]
158
- ----
159
- class A {
160
- attribute my_attribute
161
- }
162
-
163
- enum A {
164
- entry my_val2
165
- }
166
- ----
167
-
168
- implicit syntax:
169
-
170
- [source,java]
171
- ----
172
- class A {
173
- my_attribute
174
- }
175
-
176
- enum A {
177
- my_val2
178
- }
179
- ----
180
-
181
- === Attribute visibility
182
-
183
- Syntax for defining visibility: [+|-|#|~] [attribute] attribute_name. LutaML uses these modificators to define attribute(entry) visbility:
184
-
185
- + => public
186
- - => private
187
- # => protected
188
- ~ => package
189
-
190
- example:
191
-
192
- [source,java]
193
- ----
194
- class Figure {
195
- // Public attribute `radius`
196
- + radius
197
- // private attribute `filled`
198
- - filled
199
- // protected attribute `length`
200
- # length
201
- }
202
- ----
203
-
204
- === Additional attribute' properties
205
-
206
- example:
207
-
208
- [source,java]
209
- ----
210
- class Figure {
211
- + radius {
212
- definition {
213
- Radius of the Figure
214
- }
215
- }
216
- }
217
- ----
218
-
219
- == Methods
220
-
221
- Syntax for defining methods:
222
-
223
- [source,java]
224
- ----
225
- [visbility] method-name (parameter-list): return type {property-modifier}
226
- ----
227
-
228
- where:
229
- - `visibility` can be equal to `-` - private, `+` - public, `#` - protected, `~` - friendly
230
- - `parameter-list` - parameter list
231
- - `property-modifier` - can be equal to `redefines`, `query`, `ordered`(`unordered`), `unique`(`nonunique`)
232
-
233
- Syntax for a `parameter-list`:
234
-
235
- [source,java]
236
- ----
237
- [direction] name:type [multiplicity] [=default] [{property string}]
238
- ----
239
-
240
- where:
241
- - `direction` - can be equal to `in`, `out`, `inout` or `return`
242
-
243
- == import files
244
-
245
- Use `include` special word:
246
-
247
- [source,java]
248
- ----
249
- include path/to/file
250
- ----
251
-
252
- == Package syntax
253
-
254
- Namespaces
255
- Def.-A named element is an element that can have a name and a defined visibility (public, private, protected, package):
256
-
257
- [source,java]
258
- ----
259
- + => public
260
- - => private
261
- # => protected
262
- ~ => package
263
- ----
264
-
265
- The name of the element and its visibility are optional.
266
-
267
- [source,java]
268
- ----
269
- package Customers {
270
- class Insurance {}
271
- - class PrivateInsurance {}
272
- # class ProtectedInsurance {}
273
- }
274
- ----
275
-
276
- == Code comments
277
-
278
- Use `//` notation for LutaML comments skipped by parser, example:
279
-
280
- [source,java]
281
- ----
282
- // TODO: implement
283
- abstract class Pet {}
284
- ----
285
-
286
- == Comment objects diagram
287
-
288
- Use `\**`(one line comment) or `*| |*`(multiline comment) to create comment object for diagram entry.
289
- If this syntax used inside class/enum/association block it will be created for owner of this block.
290
-
291
- [source,java]
292
- ----
293
- ** I am a document comment
294
-
295
- *|
296
- This is a
297
- multiply
298
- lines document comment.
299
- *|
300
-
301
- class A
302
- enum B {
303
- ** one line enum comment
304
- foo
305
- *|
306
- This is a
307
- multiply
308
- lines class comment.
309
- *|
310
- bar
311
- }
312
- ----
313
-
314
- == Syntax comments
315
-
316
- Use `//` to create syntax comment, chars after // will be ignored during processing
317
-
318
- [source,java]
319
- ----
320
- // TODO: attributes
321
- class A
322
- enum B {
323
- // Write docs
324
- foo
325
- bar
326
- }
327
- ----
328
-
329
- == Value specification
330
-
331
- A value specification indicates one or several values in a model. Examples for value specifications include simple, mathematical expressions, such as 4+2, and expressions with values from the object model, Integer::MAX_INT-1
332
-
333
- [source,java]
334
- ----
335
- class {Class name, if any} {as ref name, optional} {
336
- {attribute name} = {attribute value}
337
- {attribute name}:{attribute class} = {attribute value}
338
- }
339
-
340
- instance :{Class name, if any} {as ref name, optional} {
341
- {attribute name} = {attribute value}
342
- {attribute name}:{attribute class} = {attribute value}
343
- }
344
- ----
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "lutaml/uml"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
@@ -1,6 +0,0 @@
1
- script_full_path=$(dirname "$0")
2
-
3
- for i in $1/*.yml
4
- do
5
- $script_full_path/yaml2lutaml $i > "$1/$(basename -s .yml $i).lutaml"
6
- done
data/bin/plantuml2lutaml DELETED
@@ -1,59 +0,0 @@
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
- line = line.gsub(/^\s*'/, '** ').gsub(/\|[\sa-zA-Z]+$/, '')
31
- return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? { |key| line =~ key }
32
-
33
- owner_type, member_type = ASSOCIATION_MAPPINGS.detect { |(key, _value)| line =~ key }.last.split(",")
34
- blocks = line.split(" ")
35
- owner = blocks.first
36
- member = blocks.last
37
- sync_puts("association {", 2)
38
- sync_puts("owner #{owner}", 4)
39
- sync_puts("member #{member}", 4)
40
- sync_puts("owner_type #{owner_type}", 4) if !owner_type.to_s.empty?
41
- sync_puts("member_type #{member_type}", 4) if !member_type.to_s.empty?
42
- sync_puts("}", 2)
43
- end
44
-
45
- sync_puts("diagram #{FILE_NAME} {")
46
- wsd_file.readlines.each do |line|
47
- if line.match?(COMMENT_START)
48
- in_comment_block = true
49
- end
50
-
51
- if line.match?(COMMENT_END)
52
- in_comment_block = false
53
- end
54
-
55
- next if in_comment_block || line =~ SKIPPED_LINES_REGEXP
56
-
57
- transform_line(line)
58
- end
59
- sync_puts("}")
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/bin/yaml2lutaml DELETED
@@ -1,144 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # Script to convert datamodel yaml files into LutaML syntax
6
- # Usage: bin/yaml2lutaml /path/to/datamodel/view/file.yml
7
-
8
- require "yaml"
9
-
10
- view_yaml = YAML.safe_load(File.read(ARGV[0]))
11
- models_path = File.expand_path("../../models", ARGV[0])
12
-
13
- def sync_puts(line, level = 0)
14
- $stdout.puts("#{''.rjust(level)}#{line}")
15
- $stdout.flush
16
- end
17
-
18
- encountered_relations = Hash.new { |h, key| h[key] = [] }
19
- # relations:
20
- # - target: AttributeProfile
21
- # relationship:
22
- # source:
23
- # type: aggregation
24
- # attribute:
25
- # addressClassProfile:
26
- # target:
27
- # type: direct
28
- # attribute:
29
- # attributeProfile:
30
- # cardinality:
31
- # min: 0
32
- # max: '*'
33
- def process_association(owner, values, encountered_relations)
34
- target_name = values["target"]
35
- return if encountered_relations[owner].include?(target_name)
36
-
37
- encountered_relations[owner].push(target_name)
38
- sync_puts("association {", 2)
39
-
40
- relationship_block = values["relationship"] || {}
41
-
42
- if relationship_block["source"] && relationship_block["source"]["type"]
43
- source = relationship_block["source"]
44
- sync_puts("owner_type #{source['type']}", 4)
45
- if source["attribute"]
46
- source_attribute_name = source["attribute"].keys.first
47
- owner += "##{source_attribute_name}"
48
- if source["attribute"][source_attribute_name] && source["attribute"][source_attribute_name]["cardinality"]
49
- cardinality = source["attribute"][source_attribute_name]["cardinality"]
50
- owner += " [#{cardinality['min']}..#{cardinality['max']}]"
51
- end
52
- end
53
- end
54
- sync_puts("owner #{owner}", 4)
55
-
56
- member = target_name
57
- if relationship_block["target"]
58
- target = relationship_block["target"]
59
- type = target["type"] || "direct"
60
- sync_puts("member_type #{type}", 4)
61
- if target["attribute"]
62
- target_attribute_name = target["attribute"].keys.first
63
- member += "##{target_attribute_name}"
64
- if target["attribute"][target_attribute_name] && target["attribute"][target_attribute_name]["cardinality"]
65
- cardinality = target["attribute"][target_attribute_name]["cardinality"]
66
- member += " [#{cardinality['min']}..#{cardinality['max']}]"
67
- end
68
- end
69
- else
70
- sync_puts("member_type direct", 4)
71
- end
72
- sync_puts("member #{member}", 4)
73
-
74
- sync_puts("}", 2)
75
- end
76
- sync_puts("diagram #{File.basename(ARGV[0], 'yml')[0..-2]} {")
77
- sync_puts("title '#{view_yaml['title']}'", 2)
78
- sync_puts("caption '#{view_yaml['caption']}'", 2)
79
-
80
- # Class associations notations
81
- view_yaml["relations"]&.each do |values|
82
- process_association(values["source"], values, encountered_relations)
83
- end
84
-
85
- view_yaml["imports"].keys.each do |entry|
86
- import = YAML.safe_load(File.read(File.join(models_path, "#{entry}.yml")))
87
- import_name = import["name"] || File.basename(entry)
88
- # Class notation
89
- sync_puts("#{import['modelType']} #{import_name} {", 2)
90
- if import["definition"]
91
- definition = <<~TEXT
92
- definition {
93
- #{import['definition']}
94
- }
95
- TEXT
96
- sync_puts(definition, 4)
97
- end
98
- import["values"]&.each_pair do |key, values|
99
- result_string = key
100
- if values["definition"]
101
- result_string += <<~TEXT
102
- {
103
- definition {
104
- #{values['definition']}
105
- }
106
- }
107
- TEXT
108
- end
109
- sync_puts(result_string, 4)
110
- end
111
- import["attributes"]&.each_pair do |key, values|
112
- definition = values["definition"]
113
- cardinality = if values["cardinality"]
114
- cardinality_val = values["cardinality"]
115
- "[#{cardinality_val['min']}..#{cardinality_val['max']}]"
116
- else
117
- ""
118
- end
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)
136
- end
137
- sync_puts("}", 2)
138
-
139
- # Associations notations
140
- import["relations"]&.each do |values|
141
- process_association(import_name, values, encountered_relations)
142
- end
143
- end
144
- sync_puts("}")
data/exe/lutaml-wsd2uml DELETED
@@ -1,59 +0,0 @@
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
- line = line.gsub(/^\s*'/, '** ').gsub(/\|[\sa-zA-Z]+$/, '').gsub(/\r/, '')
31
- return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? { |key| line =~ key }
32
-
33
- owner_type, member_type = ASSOCIATION_MAPPINGS.detect { |(key, _value)| line =~ key }.last.split(",")
34
- blocks = line.split(" ")
35
- owner = blocks.first
36
- member = blocks.last
37
- sync_puts("association {", 2)
38
- sync_puts("owner #{owner}", 4)
39
- sync_puts("member #{member}", 4)
40
- sync_puts("owner_type #{owner_type}", 4) if !owner_type.to_s.empty?
41
- sync_puts("member_type #{member_type}", 4) if !member_type.to_s.empty?
42
- sync_puts("}", 2)
43
- end
44
-
45
- sync_puts("diagram #{FILE_NAME} {")
46
- wsd_file.readlines.each do |line|
47
- if line.match?(COMMENT_START)
48
- in_comment_block = true
49
- end
50
-
51
- if line.match?(COMMENT_END)
52
- in_comment_block = false
53
- end
54
-
55
- next if in_comment_block || line =~ SKIPPED_LINES_REGEXP
56
-
57
- transform_line(line)
58
- end
59
- sync_puts("}")