lutaml-uml 0.2.10 → 0.4.0

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: 2a4318a33ee0facc590ee478a533551314aa96290ff3f9beb2a8506518f107fb
4
- data.tar.gz: 18164bb8e957223dc1f1fdeacd7603f61705482d3299de01edcd6c96bb1860a4
3
+ metadata.gz: 57797f5d5a65a5bb7e781509a44460e16877d85c9becb6b6147d43a6180a931c
4
+ data.tar.gz: caa53fbea010657d6dd53db86460ba5dd4a991076ab078bf08a72f553e5c40da
5
5
  SHA512:
6
- metadata.gz: fcb70562cec32586375a93e1a80a575bd6dc3b7150d2867046447af6461dec4af6e0c59ed179607dc03408e285c8cb6f1c627004f36118372027c8e9b9890bc2
7
- data.tar.gz: 304d5c7326dbe2378a431c07cb50f0f21596a18dca6e0d694b2c7de26d1726a30e3932b3b2fd52f7f404a0a0453d7d7ec098b731f9460bab8eb24dd61939cbff
6
+ metadata.gz: 0ec63f9b0992f1ebab8b2c3116e49514cd5753fe4d1e327a40465c001711e0c0bf86410eba964c6aea1514e8bba91297f19d8a615e9e352d296386ab348bd6fa
7
+ data.tar.gz: 3971b17f96585427e99b3e4000824e99560ed096bea8489dbb62dd7dcba44eca3acd5a5a6ebc55b224aafffae9a963c866f3ca12a365bdc8dd0c54985c93f52e
data/README.adoc CHANGED
@@ -1,5 +1,11 @@
1
1
  # Lutaml::Uml
2
2
 
3
+ image:https://badge.fury.io/rb/lutaml-uml.svg["Gem Version", link="https://badge.fury.io/rb/lutaml-uml"]
4
+
5
+ image:https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml/badge.svg["macos", link="https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml"]
6
+ image:https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml/badge.svg["ubuntu", link="https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml"]
7
+ image:https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml/badge.svg["windows", link="https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml"]
8
+
3
9
  Lutaml is a language for specifying UML class diagrams and a tool for converting it into various different formats.
4
10
 
5
11
  ## Install
@@ -35,4 +41,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
35
41
 
36
42
  ## Code of Conduct
37
43
 
38
- Everyone interacting in the Lutaml::Uml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md).
44
+ Everyone interacting in the Lutaml::Uml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md).
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/uml/has_members"
4
3
  require "lutaml/uml/classifier"
4
+
5
+ require "lutaml/uml/has_members"
5
6
  require "lutaml/uml/association"
7
+ require "lutaml/uml/constraint"
8
+ require "lutaml/uml/data_type"
9
+ require "lutaml/uml/operation"
6
10
  require "lutaml/uml/top_element_attribute"
7
11
 
8
12
  module Lutaml
@@ -12,12 +16,16 @@ module Lutaml
12
16
 
13
17
  attr_accessor :nested_classifier,
14
18
  :is_abstract,
15
- :type
19
+ :type,
20
+ :package
16
21
 
17
22
  attr_reader :associations,
18
23
  :attributes,
19
24
  :members,
20
- :modifier
25
+ :modifier,
26
+ :constraints,
27
+ :operations,
28
+ :data_types
21
29
 
22
30
  def initialize(attributes = {})
23
31
  @nested_classifier = []
@@ -43,6 +51,24 @@ module Lutaml
43
51
  end
44
52
  end
45
53
 
54
+ def constraints=(value)
55
+ @constraints = value.to_a.map do |attr|
56
+ Constraint.new(attr)
57
+ end
58
+ end
59
+
60
+ def operations=(value)
61
+ @operations = value.to_a.map do |attr|
62
+ Operation.new(attr)
63
+ end
64
+ end
65
+
66
+ def data_types=(value)
67
+ @data_types = value.to_a.map do |attr|
68
+ DataType.new(attr)
69
+ end
70
+ end
71
+
46
72
  def methods
47
73
  # @members&.select { |member| member.class == Method }
48
74
  []
@@ -1,14 +1,75 @@
1
1
  # frozen_string_literal: true
2
+ require "lutaml/uml/classifier"
2
3
 
3
4
  module Lutaml
4
5
  module Uml
5
- class DataType < Class
6
- attr_reader :keyword
6
+ class DataType < Classifier
7
+ include HasMembers
8
+
9
+ attr_accessor :nested_classifier,
10
+ :is_abstract,
11
+ :type
12
+
13
+ attr_reader :associations,
14
+ :attributes,
15
+ :members,
16
+ :modifier,
17
+ :constraints,
18
+ :operations,
19
+ :data_types
7
20
 
8
21
  def initialize(attributes = {})
22
+ @nested_classifier = []
23
+ @stereotype = []
24
+ @generalization = []
25
+ @is_abstract = false
9
26
  super
10
27
  @keyword = "dataType"
11
28
  end
29
+
30
+ def modifier=(value)
31
+ @modifier = value.to_s # TODO: Validate?
32
+ end
33
+
34
+ def attributes=(value)
35
+ @attributes = value.to_a.map do |attr|
36
+ TopElementAttribute.new(attr)
37
+ end
38
+ end
39
+
40
+ def associations=(value)
41
+ @associations = value.to_a.map do |attr|
42
+ Association.new(attr.to_h.merge(owner_end: name))
43
+ end
44
+ end
45
+
46
+ def constraints=(value)
47
+ @constraints = value.to_a.map do |attr|
48
+ Constraint.new(attr)
49
+ end
50
+ end
51
+
52
+ def operations=(value)
53
+ @operations = value.to_a.map do |attr|
54
+ Operation.new(attr)
55
+ end
56
+ end
57
+
58
+ def data_types=(value)
59
+ @data_types = value.to_a.map do |attr|
60
+ DataType.new(attr)
61
+ end
62
+ end
63
+
64
+ def methods
65
+ # @members&.select { |member| member.class == Method }
66
+ []
67
+ end
68
+
69
+ def relationships
70
+ # @members&.select { |member| member.class == ClassRelationship }
71
+ []
72
+ end
12
73
  end
13
74
  end
14
75
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ class Diagram < TopElement
6
+ end
7
+ end
8
+ end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "lutaml/uml/class"
4
- require "lutaml/uml/enum"
5
4
  require "lutaml/uml/data_type"
5
+ require "lutaml/uml/enum"
6
+ require "lutaml/uml/diagram"
7
+ require "lutaml/uml/package"
6
8
  require "lutaml/uml/primitive_type"
7
9
 
8
10
  module Lutaml
@@ -18,23 +20,27 @@ module Lutaml
18
20
  :fidelity,
19
21
  :fontname,
20
22
  :comments
23
+ attr_reader :packages
21
24
 
22
25
  # rubocop:disable Rails/ActiveRecordAliases
23
26
  def initialize(attributes = {})
24
27
  update_attributes(attributes)
25
28
  end
26
29
  # rubocop:enable Rails/ActiveRecordAliases
27
-
28
30
  def classes=(value)
29
31
  @classes = value.to_a.map { |attributes| Class.new(attributes) }
30
32
  end
31
33
 
34
+ def data_types=(value)
35
+ @data_types = value.to_a.map { |attributes| DataType.new(attributes) }
36
+ end
37
+
32
38
  def enums=(value)
33
39
  @enums = value.to_a.map { |attributes| Enum.new(attributes) }
34
40
  end
35
41
 
36
- def data_types=(value)
37
- @data_types = value.to_a.map { |attributes| DataType.new(attributes) }
42
+ def packages=(value)
43
+ @packages = value.to_a.map { |attributes| Package.new(attributes) }
38
44
  end
39
45
 
40
46
  def primitives=(value)
@@ -59,6 +65,10 @@ module Lutaml
59
65
  @data_types || []
60
66
  end
61
67
 
68
+ def packages
69
+ @packages || []
70
+ end
71
+
62
72
  def primitives
63
73
  @primitives || []
64
74
  end
@@ -4,6 +4,7 @@ require "lutaml/uml/has_members"
4
4
  require "lutaml/uml/classifier"
5
5
  require "lutaml/uml/association"
6
6
  require "lutaml/uml/top_element_attribute"
7
+ require "lutaml/uml/value"
7
8
 
8
9
  module Lutaml
9
10
  module Uml
@@ -14,19 +15,27 @@ module Lutaml
14
15
  :members,
15
16
  :modifier,
16
17
  :definition,
17
- :keyword
18
+ :keyword,
19
+ :values
18
20
 
19
21
  def initialize(attributes = {})
20
22
  super
21
23
  @keyword = "enumeration"
22
24
  end
23
25
 
26
+ # TODO: delete?
24
27
  def attributes=(value)
25
28
  @attributes = value.to_a.map do |attr|
26
29
  TopElementAttribute.new(attr)
27
30
  end
28
31
  end
29
32
 
33
+ def values=(value)
34
+ @values = value.to_a.map do |attr|
35
+ Value.new(attr)
36
+ end
37
+ end
38
+
30
39
  # TODO: reserved name, change
31
40
  def methods
32
41
  []
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ class Operation
6
+ include HasAttributes
7
+ include HasMembers
8
+
9
+ attr_accessor :definition,
10
+ :name,
11
+ :return_type,
12
+ :parameter_type
13
+
14
+ # rubocop:disable Rails/ActiveRecordAliases
15
+ def initialize(attributes = {})
16
+ update_attributes(attributes)
17
+ end
18
+ # rubocop:enable Rails/ActiveRecordAliases
19
+
20
+ def definition=(value)
21
+ @definition = value
22
+ .to_s
23
+ .gsub(/\\}/, '}')
24
+ .gsub(/\\{/, '{')
25
+ .split("\n")
26
+ .map(&:strip)
27
+ .join("\n")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,16 +3,50 @@
3
3
  module Lutaml
4
4
  module Uml
5
5
  class Package < TopElement
6
+ include HasAttributes
7
+
6
8
  attr_accessor :imports, :contents
9
+ attr_reader :classes, :enums, :data_types, :children_packages
10
+
11
+ def initialize(attributes)
12
+ update_attributes(attributes)
13
+ @children_packages ||= packages.map { |pkg| [pkg, pkg.packages.map(&:children_packages)] }.flatten
14
+ end
15
+
16
+ def classes=(value)
17
+ @classes = value.to_a.map { |attributes| Class.new(attributes) }
18
+ end
19
+
20
+ def enums=(value)
21
+ @enums = value.to_a.map { |attributes| Enum.new(attributes) }
22
+ end
23
+
24
+ def data_types=(value)
25
+ @data_types = value.to_a.map { |attributes| DataType.new(attributes) }
26
+ end
27
+
28
+ def packages=(value)
29
+ @packages = value.to_a.map { |attributes| Package.new(attributes) }
30
+ end
31
+
32
+ def diagrams=(value)
33
+ @diagrams = value.to_a.map { |attributes| Diagram.new(attributes) }
34
+ end
35
+
36
+ def classes
37
+ @classes || []
38
+ end
39
+
40
+ def enums
41
+ @enums || []
42
+ end
43
+
44
+ def packages
45
+ @packages || []
46
+ end
7
47
 
8
- def initialize
9
- @imports = []
10
- @contents = []
11
- @name = nil
12
- @xmi_id = nil
13
- @xmi_uuid = nil
14
- @namespace = nil
15
- @href = nil
48
+ def diagrams
49
+ @diagrams || []
16
50
  end
17
51
  end
18
52
  end
@@ -117,7 +117,7 @@ module Lutaml
117
117
  attribute_keyword? >>
118
118
  spaces? >>
119
119
  match['"\''].maybe >>
120
- match['a-zA-Z0-9_\- \/'].repeat(1).as(:type) >>
120
+ match['a-zA-Z0-9_\- \/\+'].repeat(1).as(:type) >>
121
121
  match['"\''].maybe >>
122
122
  spaces?
123
123
  )
@@ -126,7 +126,7 @@ module Lutaml
126
126
  attribute_type.maybe
127
127
  end
128
128
 
129
- rule(:attribute_name) { match['a-zA-Z0-9_\- \/'].repeat(1).as(:name) }
129
+ rule(:attribute_name) { match['a-zA-Z0-9_\- \/\+'].repeat(1).as(:name) }
130
130
  rule(:attribute_definition) do
131
131
  (visibility?.as(:visibility) >>
132
132
  match['"\''].maybe >>
@@ -329,7 +329,10 @@ module Lutaml
329
329
  # -- data_type
330
330
  rule(:data_type_keyword) { kw_data_type >> spaces }
331
331
  rule(:data_type_inner_definitions) do
332
- attribute_definition
332
+ definition_body |
333
+ attribute_definition |
334
+ comment_definition |
335
+ comment_multiline_definition
333
336
  end
334
337
  rule(:data_type_inner_definition) do
335
338
  data_type_inner_definitions >> whitespace?
@@ -347,6 +350,7 @@ module Lutaml
347
350
  match['"\''].maybe >>
348
351
  class_name.as(:name) >>
349
352
  match['"\''].maybe >>
353
+ attribute_keyword? >>
350
354
  data_type_body?
351
355
  end
352
356
 
@@ -13,7 +13,8 @@ module Lutaml
13
13
  :contain,
14
14
  :static,
15
15
  :cardinality,
16
- :keyword
16
+ :keyword,
17
+ :is_derived
17
18
 
18
19
  # rubocop:disable Rails/ActiveRecordAliases
19
20
  def initialize(attributes = {})
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ class Value
6
+ include HasAttributes
7
+ include HasMembers
8
+
9
+ attr_accessor :definition,
10
+ :name,
11
+ :type
12
+
13
+ # rubocop:disable Rails/ActiveRecordAliases
14
+ def initialize(attributes = {})
15
+ update_attributes(attributes)
16
+ end
17
+ # rubocop:enable Rails/ActiveRecordAliases
18
+
19
+ def definition=(value)
20
+ @definition = value
21
+ .to_s
22
+ .gsub(/\\}/, '}')
23
+ .gsub(/\\{/, '{')
24
+ .split("\n")
25
+ .map(&:strip)
26
+ .join("\n")
27
+ end
28
+ end
29
+ end
30
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Uml
5
- VERSION = "0.2.10"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
data/lutaml-uml.gemspec CHANGED
@@ -28,10 +28,10 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency "parslet", "~> 1.7.1"
29
29
  spec.add_runtime_dependency "ruby-graphviz", "~> 1.2"
30
30
  spec.add_runtime_dependency "thor", "~> 1.0"
31
+ spec.add_runtime_dependency "nokogiri", "~> 1.10"
31
32
 
32
33
  spec.add_development_dependency "bundler", "~> 2.0"
33
34
  spec.add_development_dependency "byebug"
34
- spec.add_development_dependency "nokogiri", "~> 1.10"
35
35
  spec.add_development_dependency "pry", "~> 0.12.2"
36
36
  spec.add_development_dependency "rake", "~> 10.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -17,5 +17,9 @@ diagram MyView {
17
17
  #protectedAttributeProfile: CharacterString
18
18
  type/text: String
19
19
  slashType: slash/type
20
+ application/docbook+xml
21
+ application/tei+xml
22
+ text/x-asciidoc
23
+ application/x-isodoc+xml
20
24
  }
21
25
  }
@@ -8,10 +8,30 @@ diagram MyView {
8
8
  }
9
9
 
10
10
  data_type "Banking Information" {
11
- "art code"
11
+ definition {
12
+ Common code types used in banking.
13
+ }
14
+ "art code" {
15
+ definition {
16
+ The bank ART code.
17
+ }
18
+ }
12
19
  "CCT Number"
13
20
  }
14
21
 
22
+ data_type DateTimeType {
23
+ definition {
24
+ Type of date time value.
25
+ }
26
+ year {
27
+ definition {
28
+ The value only provides year.
29
+ }
30
+ }
31
+ monthYear
32
+ dayMonthYear
33
+ }
34
+
15
35
  primitive Integer
16
36
 
17
37
  enum Profile {
@@ -68,7 +68,7 @@ RSpec.describe Lutaml::Uml::Parsers::Dsl do
68
68
  expect(by_name(classes, "AddressClassProfile")
69
69
  .attributes.length).to eq(1)
70
70
  expect(by_name(classes, "AttributeProfile")
71
- .attributes.length).to eq(9)
71
+ .attributes.length).to eq(13)
72
72
  expect(by_name(classes, "AttributeProfile")
73
73
  .attributes.map(&:name))
74
74
  .to(eq(["imlicistAttributeProfile",
@@ -79,7 +79,11 @@ RSpec.describe Lutaml::Uml::Parsers::Dsl do
79
79
  "friendlyAttributeProfile1",
80
80
  "protectedAttributeProfile",
81
81
  "type/text",
82
- "slashType"]))
82
+ "slashType",
83
+ "application/docbook+xml",
84
+ "application/tei+xml",
85
+ "text/x-asciidoc",
86
+ "application/x-isodoc+xml"]))
83
87
  end
84
88
 
85
89
  it "creates the correct attributes with the correct visibility" do
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.10
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-17 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -67,47 +67,47 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bundler
70
+ name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
76
- type: :development
75
+ version: '1.10'
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: '1.10'
83
83
  - !ruby/object:Gem::Dependency
84
- name: byebug
84
+ name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '2.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '2.0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: nokogiri
98
+ name: byebug
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '1.10'
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '1.10'
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +206,7 @@ files:
206
206
  - lib/lutaml/uml/constructor_end.rb
207
207
  - lib/lutaml/uml/data_type.rb
208
208
  - lib/lutaml/uml/dependency.rb
209
+ - lib/lutaml/uml/diagram.rb
209
210
  - lib/lutaml/uml/document.rb
210
211
  - lib/lutaml/uml/enum.rb
211
212
  - lib/lutaml/uml/event.rb
@@ -228,6 +229,7 @@ files:
228
229
  - lib/lutaml/uml/node/method_argument.rb
229
230
  - lib/lutaml/uml/node/relationship.rb
230
231
  - lib/lutaml/uml/opaque_behavior.rb
232
+ - lib/lutaml/uml/operation.rb
231
233
  - lib/lutaml/uml/package.rb
232
234
  - lib/lutaml/uml/parsers/attribute.rb
233
235
  - lib/lutaml/uml/parsers/dsl.rb
@@ -251,6 +253,7 @@ files:
251
253
  - lib/lutaml/uml/top_element_attribute.rb
252
254
  - lib/lutaml/uml/transition.rb
253
255
  - lib/lutaml/uml/trigger.rb
256
+ - lib/lutaml/uml/value.rb
254
257
  - lib/lutaml/uml/version.rb
255
258
  - lib/lutaml/uml/vertex.rb
256
259
  - lutaml-uml.gemspec
@@ -319,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
322
  - !ruby/object:Gem::Version
320
323
  version: '0'
321
324
  requirements: []
322
- rubygems_version: 3.0.3
325
+ rubygems_version: 3.1.6
323
326
  signing_key:
324
327
  specification_version: 4
325
328
  summary: UML model module for LutaML.