lutaml-uml 0.2.2 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b549fe48dc2957bc3f44d69d32f0727af97ec27755e35f47a2580a307e01edb6
4
- data.tar.gz: f9ce93042ba36d940323413f03ffc952b1c174beedc81441a2cd7e7b37a4fa5d
3
+ metadata.gz: caa272840dbf2e26c09465e9fc43ce87e27264d1304f3e517177e1c2aeb5ddd5
4
+ data.tar.gz: 63accfb7dc6651f7df5a2fa16e1f3049efeac98f2b7c45ab33797e5589955011
5
5
  SHA512:
6
- metadata.gz: e3070e60d69100ce2696ab9e4e9efb89ad6331fcf962da7b16222107a18b681faddae48cad66ea2b0d6a03c5871583a299d6d5ab9a41ea8f4451844cfa5d9023
7
- data.tar.gz: f09245563a2441c7a3714763e820998341d949d6c2c51b4e12599109c3583513cbe1a85c0d3fca3407fe6b5c2c2bd743e679e39a1755c565b7fd1b4b6bd58df7
6
+ metadata.gz: 60f0496d0d68e7ec42f96d2dea4e28b2f48be4ff46f079afc0a0041a31e9a0a32d6353f8a208a7194585c4e95a31a7fdaeb5e8bc21e94752b9ce8953d8b4655e
7
+ data.tar.gz: f1c58b701b5eff18c42c4fb8a38c9beab572663a345ea048abc112993f671b38e17ff8af9852951cc7650969715130996639bb4cb1eb517ba3cae83a023ee30e
@@ -36,9 +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 Grpahviz Windows
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
40
47
  run: |
41
- cinst -y graphviz
48
+ dot -?
42
49
  - name: Run specs
43
50
  run: |
44
51
  bundle exec rake
@@ -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
+ }
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][{property string}]
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
- * `property string` - Property string indicates a modifier that applies to the attribute:
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
+ }
210
+ }
211
+ }
212
+ ----
213
+
189
214
  == Methods
190
215
 
191
216
  Syntax for defining methods:
@@ -6,7 +6,7 @@
6
6
  # Usage: bin/plantuml2lutaml /path/to/plantuml.wsd
7
7
 
8
8
  file_path = ARGV[0]
9
- FILE_NAME = File.basename(file_path, '.wsd')
9
+ FILE_NAME = File.basename(file_path, ".wsd")
10
10
  wsd_file = File.new(ARGV[0])
11
11
 
12
12
  def sync_puts(line, level = 0)
@@ -18,36 +18,36 @@ SKIPPED_LINES_REGEXP = /^(@startuml|'\*{7}|note|@enduml|\!|'\/)/
18
18
  COMMENT_START = /\/'/
19
19
  COMMENT_END = /'\//
20
20
  ASSOCIATION_MAPPINGS = {
21
- /-\|>/ => ',inheritance',
22
- /<\|-/ => 'inheritance,',
23
- /->/ => ',direct',
24
- /<-/ => 'direct,'
25
- }
21
+ /-\|>/ => ",inheritance",
22
+ /<\|-/ => "inheritance,",
23
+ /->/ => ",direct",
24
+ /<-/ => "direct,",
25
+ }.freeze
26
26
 
27
27
  in_comment_block = false
28
28
 
29
29
  def transform_line(line)
30
30
  return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? { |key| line =~ key }
31
31
 
32
- owner_type, member_type = ASSOCIATION_MAPPINGS.find { |(key,value)| line =~ key }.last.split(',')
33
- blocks = line.split(' ')
32
+ owner_type, member_type = ASSOCIATION_MAPPINGS.detect { |(key, _value)| line =~ key }.last.split(",")
33
+ blocks = line.split(" ")
34
34
  owner = blocks.first
35
35
  member = blocks.last
36
36
  sync_puts("association {", 2)
37
37
  sync_puts("owner #{owner}", 4)
38
38
  sync_puts("member #{member}", 4)
39
- sync_puts("owner_type #{owner_type}", 4) if owner_type.to_s.length > 0
40
- sync_puts("member_type #{member_type}", 4) if member_type.to_s.length > 0
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
41
  sync_puts("}", 2)
42
42
  end
43
43
 
44
44
  sync_puts("diagram #{FILE_NAME} {")
45
45
  wsd_file.readlines.each do |line|
46
- if line =~ COMMENT_START
46
+ if line.match?(COMMENT_START)
47
47
  in_comment_block = true
48
48
  end
49
49
 
50
- if line =~ COMMENT_END
50
+ if line.match?(COMMENT_END)
51
51
  in_comment_block = false
52
52
  end
53
53
 
@@ -55,4 +55,4 @@ wsd_file.readlines.each do |line|
55
55
 
56
56
  transform_line(line)
57
57
  end
58
- sync_puts("}")
58
+ sync_puts("}")
@@ -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"] || File.basename(entry)
87
+ import_name = import["name"] || File.basename(entry)
87
88
  # Class notation
88
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
89
98
  import["values"]&.each_pair do |key, values|
90
- sync_puts("#{key}", 4)
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
- sync_puts("+#{key}: #{values['type']} #{cardinality}", 4)
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
 
@@ -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)
@@ -3,8 +3,11 @@
3
3
  module Lutaml
4
4
  module Uml
5
5
  class DataType < Class
6
- def keyword
7
- "dataType"
6
+ attr_reader :keyword
7
+
8
+ def initialize(attributes = {})
9
+ super
10
+ @keyword = "dataType"
8
11
  end
9
12
  end
10
13
  end
@@ -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
@@ -322,12 +322,7 @@ module Lutaml
322
322
  end
323
323
 
324
324
  def generate_from_dot(input)
325
- # https://github.com/glejeune/Ruby-Graphviz/issues/78
326
- # Ruby-Graphviz has an old bug when html labels was not displayed
327
- # property because of `<` and `>` characters escape, add additional
328
- # `<` and `>` symbols to workaround it
329
- escaped_dot = input.gsub("<<", "<<<").gsub(">>", ">>>")
330
- Lutaml::Layout::GraphVizEngine.new(input: escaped_dot).render(@type)
325
+ Lutaml::Layout::GraphVizEngine.new(input: input).render(@type)
331
326
  end
332
327
 
333
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|
@@ -132,7 +133,8 @@ module Lutaml
132
133
  attribute_name >>
133
134
  match['"\''].maybe >>
134
135
  attribute_type? >>
135
- cardinality?)
136
+ cardinality? >>
137
+ class_body?)
136
138
  .as(:attributes)
137
139
  end
138
140
 
@@ -143,6 +145,13 @@ module Lutaml
143
145
  match['"\''].maybe
144
146
  end
145
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 }
146
155
 
147
156
  rule(:fontname_keyword) { kw_fontname >> spaces }
148
157
  rule(:fontname_text) do
@@ -252,7 +261,8 @@ module Lutaml
252
261
  end
253
262
  rule(:class_keyword) { kw_class >> spaces }
254
263
  rule(:class_inner_definitions) do
255
- attribute_definition |
264
+ definition_body |
265
+ attribute_definition |
256
266
  comment_definition |
257
267
  comment_multiline_definition
258
268
  end
@@ -276,10 +286,23 @@ module Lutaml
276
286
  class_body?
277
287
  end
278
288
 
289
+ # -- Definition
290
+ rule(:definition_body) do
291
+ spaces? >>
292
+ str("definition") >>
293
+ whitespace? >>
294
+ str("{") >>
295
+ whitespace? >>
296
+ (str("}").absent? >> any).repeat.as(:definition) >>
297
+ whitespace? >>
298
+ str("}")
299
+ end
300
+
279
301
  # -- Enum
280
302
  rule(:enum_keyword) { kw_enum >> spaces }
281
303
  rule(:enum_inner_definitions) do
282
- attribute_definition |
304
+ definition_body |
305
+ attribute_definition |
283
306
  comment_definition |
284
307
  comment_multiline_definition
285
308
  end
@@ -339,6 +362,7 @@ module Lutaml
339
362
  rule(:diagram_keyword) { kw_diagram >> spaces? }
340
363
  rule(:diagram_inner_definitions) do
341
364
  title_definition |
365
+ caption_definition |
342
366
  fontname_definition |
343
367
  class_definition.as(:classes) |
344
368
  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(/\s*include\s+(.+)/)
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
@@ -3,8 +3,11 @@
3
3
  module Lutaml
4
4
  module Uml
5
5
  class PrimitiveType < DataType
6
- def keyword
7
- "primitive"
6
+ attr_reader :keyword
7
+
8
+ def initialize(attributes = {})
9
+ super
10
+ @keyword = "primitive"
8
11
  end
9
12
  end
10
13
  end
@@ -4,6 +4,7 @@ module Lutaml
4
4
  module Uml
5
5
  class TopElementAttribute
6
6
  include HasAttributes
7
+ include HasMembers
7
8
 
8
9
  attr_accessor :name,
9
10
  :visibility,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Uml
5
- VERSION = "0.2.2"
5
+ VERSION = "0.2.7"
6
6
  end
7
7
  end
@@ -24,17 +24,16 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
  spec.executables = %w[lutaml-uml]
26
26
 
27
- spec.add_runtime_dependency "activesupport", "~> 5.0"
28
27
  spec.add_runtime_dependency "hashie", "~> 4.1.0"
29
28
  spec.add_runtime_dependency "parslet", "~> 1.7.1"
30
29
  spec.add_runtime_dependency "ruby-graphviz", "~> 1.2"
31
30
  spec.add_runtime_dependency "thor", "~> 1.0"
32
31
 
32
+ spec.add_development_dependency "bundler", "~> 2.0"
33
33
  spec.add_development_dependency "byebug"
34
34
  spec.add_development_dependency "nokogiri", "~> 1.10"
35
- spec.add_development_dependency "rubocop", "~> 0.54.0"
36
- spec.add_development_dependency "bundler", "~> 2.0"
37
35
  spec.add_development_dependency "pry", "~> 0.12.2"
38
36
  spec.add_development_dependency "rake", "~> 10.0"
39
37
  spec.add_development_dependency "rspec", "~> 3.0"
38
+ spec.add_development_dependency "rubocop", "~> 0.54.0"
40
39
  end
@@ -0,0 +1,23 @@
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
+ }
10
+ +addressClassProfile: CharacterString [0..1]
11
+ }
12
+
13
+ class AttributeProfile {
14
+ imlicistAttributeProfile: CharacterString [0..1] {
15
+ definition
16
+ {
17
+ this is attribute definition
18
+ with multiply lines
19
+ end definition
20
+ }
21
+ }
22
+ }
23
+ }
@@ -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\n end definition"
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,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-uml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.7
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-20 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '5.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '5.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: hashie
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -81,61 +67,47 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '1.0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: byebug
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
70
+ name: bundler
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - "~>"
102
74
  - !ruby/object:Gem::Version
103
- version: '1.10'
75
+ version: '2.0'
104
76
  type: :development
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - "~>"
109
81
  - !ruby/object:Gem::Version
110
- version: '1.10'
82
+ version: '2.0'
111
83
  - !ruby/object:Gem::Dependency
112
- name: rubocop
84
+ name: byebug
113
85
  requirement: !ruby/object:Gem::Requirement
114
86
  requirements:
115
- - - "~>"
87
+ - - ">="
116
88
  - !ruby/object:Gem::Version
117
- version: 0.54.0
89
+ version: '0'
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
93
  requirements:
122
- - - "~>"
94
+ - - ">="
123
95
  - !ruby/object:Gem::Version
124
- version: 0.54.0
96
+ version: '0'
125
97
  - !ruby/object:Gem::Dependency
126
- name: bundler
98
+ name: nokogiri
127
99
  requirement: !ruby/object:Gem::Requirement
128
100
  requirements:
129
101
  - - "~>"
130
102
  - !ruby/object:Gem::Version
131
- version: '2.0'
103
+ version: '1.10'
132
104
  type: :development
133
105
  prerelease: false
134
106
  version_requirements: !ruby/object:Gem::Requirement
135
107
  requirements:
136
108
  - - "~>"
137
109
  - !ruby/object:Gem::Version
138
- version: '2.0'
110
+ version: '1.10'
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: pry
141
113
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +150,20 @@ dependencies:
178
150
  - - "~>"
179
151
  - !ruby/object:Gem::Version
180
152
  version: '3.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.54.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.54.0
181
167
  description: UML model module for LutaML.
182
168
  email:
183
169
  - open.source@ribose.com'
@@ -297,6 +283,7 @@ files:
297
283
  - spec/fixtures/dsl/diagram_comments.lutaml
298
284
  - spec/fixtures/dsl/diagram_concept_model.lutaml
299
285
  - spec/fixtures/dsl/diagram_data_types.lutaml
286
+ - spec/fixtures/dsl/diagram_definitions.lutaml
300
287
  - spec/fixtures/dsl/diagram_includes.lutaml
301
288
  - spec/fixtures/dsl/diagram_multiply_classes.lutaml
302
289
  - spec/fixtures/dsl/shared.lutaml