lutaml 0.9.28 → 0.9.29

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/bin/plantuml2lutaml +11 -7
  3. data/bin/yaml2lutaml +1 -1
  4. data/exe/lutaml-sysml +4 -2
  5. data/exe/lutaml-wsd2uml +11 -7
  6. data/exe/lutaml-yaml2uml +1 -1
  7. data/lib/lutaml/express/parsers/exp.rb +4 -4
  8. data/lib/lutaml/formatter/graphviz.rb +7 -7
  9. data/lib/lutaml/sysml/allocate.rb +6 -7
  10. data/lib/lutaml/sysml/allocated.rb +6 -6
  11. data/lib/lutaml/sysml/binding_connector.rb +6 -6
  12. data/lib/lutaml/sysml/block.rb +28 -25
  13. data/lib/lutaml/sysml/constraint_block.rb +11 -11
  14. data/lib/lutaml/sysml/copy.rb +5 -5
  15. data/lib/lutaml/sysml/derive_requirement.rb +6 -6
  16. data/lib/lutaml/sysml/nested_connector_end.rb +9 -9
  17. data/lib/lutaml/sysml/refine.rb +6 -6
  18. data/lib/lutaml/sysml/requirement_related.rb +6 -6
  19. data/lib/lutaml/sysml/satisfy.rb +6 -6
  20. data/lib/lutaml/sysml/test_case.rb +20 -19
  21. data/lib/lutaml/sysml/trace.rb +6 -6
  22. data/lib/lutaml/sysml/verify.rb +5 -5
  23. data/lib/lutaml/sysml/version.rb +1 -1
  24. data/lib/lutaml/sysml/xmi_file.rb +455 -415
  25. data/lib/lutaml/sysml.rb +1 -1
  26. data/lib/lutaml/uml/association.rb +4 -3
  27. data/lib/lutaml/uml/data_type.rb +1 -0
  28. data/lib/lutaml/uml/document.rb +4 -1
  29. data/lib/lutaml/uml/formatter/graphviz.rb +11 -13
  30. data/lib/lutaml/uml/has_attributes.rb +2 -2
  31. data/lib/lutaml/uml/has_members.rb +4 -3
  32. data/lib/lutaml/uml/node/class_node.rb +5 -7
  33. data/lib/lutaml/uml/node/field.rb +1 -3
  34. data/lib/lutaml/uml/node/method.rb +1 -3
  35. data/lib/lutaml/uml/node/relationship.rb +1 -3
  36. data/lib/lutaml/uml/operation.rb +6 -6
  37. data/lib/lutaml/uml/package.rb +3 -1
  38. data/lib/lutaml/uml/parsers/attribute.rb +1 -3
  39. data/lib/lutaml/uml/parsers/dsl.rb +11 -10
  40. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +7 -6
  41. data/lib/lutaml/uml/parsers/yaml.rb +2 -2
  42. data/lib/lutaml/uml/serializers/class.rb +1 -1
  43. data/lib/lutaml/uml/top_element.rb +9 -9
  44. data/lib/lutaml/uml/top_element_attribute.rb +6 -6
  45. data/lib/lutaml/uml/value.rb +6 -6
  46. data/lib/lutaml/version.rb +1 -1
  47. data/lib/lutaml/xmi/liquid_drops/association_drop.rb +31 -11
  48. data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +29 -11
  49. data/lib/lutaml/xmi/liquid_drops/cardinality_drop.rb +8 -2
  50. data/lib/lutaml/xmi/liquid_drops/constraint_drop.rb +6 -4
  51. data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +76 -18
  52. data/lib/lutaml/xmi/liquid_drops/diagram_drop.rb +13 -6
  53. data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +16 -7
  54. data/lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb +10 -4
  55. data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +2 -0
  56. data/lib/lutaml/xmi/liquid_drops/generalization_drop.rb +10 -3
  57. data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +98 -24
  58. data/lib/lutaml/xmi/liquid_drops/operation_drop.rb +11 -5
  59. data/lib/lutaml/xmi/liquid_drops/package_drop.rb +61 -18
  60. data/lib/lutaml/xmi/liquid_drops/root_drop.rb +14 -4
  61. data/lib/lutaml/xmi/parsers/xmi_base.rb +1031 -0
  62. data/lib/lutaml/xmi/parsers/xml.rb +19 -1016
  63. data/lib/lutaml/xml/parsers/xml.rb +2 -2
  64. metadata +4 -3
data/lib/lutaml/sysml.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "lutaml/sysml/version"
2
2
  require "lutaml/uml"
3
- require 'nokogiri'
3
+ require "nokogiri"
4
4
 
5
5
  module Lutaml
6
6
  module Sysml
@@ -25,17 +25,18 @@ module Lutaml
25
25
  if %w[owner_end member_end].include?(type)
26
26
  group.each do |member|
27
27
  member.each_pair do |key, member_value|
28
- public_send("#{associtaion_type(key)}=", member_value)
28
+ public_send(:"#{associtaion_type(key)}=", member_value)
29
29
  end
30
30
  end
31
31
  next
32
32
  end
33
33
  attribute_value = group.map(&:values).flatten
34
34
  if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash)
35
- next public_send("#{associtaion_type(type)}=", attribute_value.first)
35
+ next public_send(:"#{associtaion_type(type)}=",
36
+ attribute_value.first)
36
37
  end
37
38
 
38
- public_send("#{associtaion_type(type)}=", attribute_value)
39
+ public_send(:"#{associtaion_type(type)}=", attribute_value)
39
40
  end
40
41
  end
41
42
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "lutaml/uml/classifier"
3
4
 
4
5
  module Lutaml
@@ -26,6 +26,7 @@ module Lutaml
26
26
  def initialize(attributes = {})
27
27
  update_attributes(attributes)
28
28
  end
29
+
29
30
  # rubocop:enable Rails/ActiveRecordAliases
30
31
  def classes=(value)
31
32
  @classes = value.to_a.map { |attributes| Class.new(attributes) }
@@ -44,7 +45,9 @@ module Lutaml
44
45
  end
45
46
 
46
47
  def primitives=(value)
47
- @primitives = value.to_a.map { |attributes| PrimitiveType.new(attributes) }
48
+ @primitives = value.to_a.map do |attributes|
49
+ PrimitiveType.new(attributes)
50
+ end
48
51
  end
49
52
 
50
53
  def associations=(value)
@@ -18,11 +18,11 @@ module Lutaml
18
18
  end
19
19
 
20
20
  ACCESS_SYMBOLS = {
21
- "public" => "+",
21
+ "public" => "+",
22
22
  "protected" => "#",
23
- "private" => "-",
23
+ "private" => "-",
24
24
  }.freeze
25
- DEFAULT_CLASS_FONT = "Helvetica".freeze
25
+ DEFAULT_CLASS_FONT = "Helvetica"
26
26
 
27
27
  VALID_TYPES = %i[
28
28
  dot
@@ -66,9 +66,7 @@ module Lutaml
66
66
  @type = :dot
67
67
  end
68
68
 
69
- attr_reader :graph
70
- attr_reader :edge
71
- attr_reader :node
69
+ attr_reader :graph, :edge, :node
72
70
 
73
71
  def type=(value)
74
72
  super
@@ -84,10 +82,10 @@ module Lutaml
84
82
 
85
83
  def escape_html_chars(text)
86
84
  text
87
- .gsub(/</, "&#60;")
88
- .gsub(/>/, "&#62;")
89
- .gsub(/\[/, "&#91;")
90
- .gsub(/\]/, "&#93;")
85
+ .gsub("<", "&#60;")
86
+ .gsub(">", "&#62;")
87
+ .gsub("[", "&#91;")
88
+ .gsub("]", "&#93;")
91
89
  end
92
90
 
93
91
  def format_field(node)
@@ -200,7 +198,7 @@ module Lutaml
200
198
  end
201
199
 
202
200
  def format_member_rows(members, hide_members)
203
- unless !hide_members && members && members.length.positive?
201
+ unless !hide_members && members&.length&.positive?
204
202
  return <<~HEREDOC.chomp
205
203
  <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
206
204
  <TR><TD ALIGN="LEFT"></TD></TR>
@@ -213,10 +211,10 @@ module Lutaml
213
211
  end
214
212
  field_table = <<~HEREDOC.chomp
215
213
  <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
216
- #{field_rows.map { |row| ' ' * 10 + row }.join("\n")}
214
+ #{field_rows.map { |row| (' ' * 10) + row }.join("\n")}
217
215
  </TABLE>
218
216
  HEREDOC
219
- field_table << "\n" << " " * 6
217
+ field_table << "\n" << (" " * 6)
220
218
  field_table
221
219
  end
222
220
 
@@ -5,8 +5,8 @@ module Lutaml
5
5
  module HasAttributes
6
6
  def update_attributes(attributes = {})
7
7
  attributes.to_h.each do |name, value|
8
- value = value.respond_to?(:str) ? value.str : value
9
- public_send("#{name}=", value)
8
+ value = value.str if value.respond_to?(:str)
9
+ public_send(:"#{name}=", value)
10
10
  end
11
11
  end
12
12
  end
@@ -11,17 +11,18 @@ module Lutaml
11
11
  .each do |(type, group)|
12
12
  attribute_value = group.map(&:values).flatten
13
13
  if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash)
14
- next public_send("#{associtaion_type(type)}=", attribute_value.first)
14
+ next public_send(:"#{associtaion_type(type)}=",
15
+ attribute_value.first)
15
16
  end
16
17
 
17
- public_send("#{associtaion_type(type)}=", attribute_value)
18
+ public_send(:"#{associtaion_type(type)}=", attribute_value)
18
19
  end
19
20
  end
20
21
 
21
22
  private
22
23
 
23
24
  def associtaion_type(type)
24
- return type if respond_to?("#{type}=")
25
+ return type if respond_to?(:"#{type}=")
25
26
 
26
27
  raise(UnknownMemberTypeError, "Unknown member type: #{type}")
27
28
  end
@@ -13,14 +13,12 @@ module Lutaml
13
13
  class ClassNode < Base
14
14
  include HasName
15
15
 
16
- attr_reader :modifier
16
+ attr_reader :modifier, :members
17
17
 
18
18
  def modifier=(value)
19
19
  @modifier = value.to_s # TODO: Validate?
20
20
  end
21
21
 
22
- attr_reader :members
23
-
24
22
  def members=(value)
25
23
  @members = value.to_a.map do |member|
26
24
  type = member.to_a[0][0] # TODO: This is dumb
@@ -37,19 +35,19 @@ module Lutaml
37
35
  end
38
36
 
39
37
  def fields
40
- @members.select { |member| member.class == Field }
38
+ @members.select { |member| member.instance_of?(Field) }
41
39
  end
42
40
 
43
41
  def methods
44
- @members.select { |member| member.class == Method }
42
+ @members.select { |member| member.instance_of?(Method) }
45
43
  end
46
44
 
47
45
  def relationships
48
- @members.select { |member| member.class == Relationship }
46
+ @members.select { |member| member.instance_of?(Relationship) }
49
47
  end
50
48
 
51
49
  def class_relationships
52
- @members.select { |member| member.class == ClassRelationship }
50
+ @members.select { |member| member.instance_of?(ClassRelationship) }
53
51
  end
54
52
  end
55
53
  end
@@ -17,14 +17,12 @@ module Lutaml
17
17
  super
18
18
  end
19
19
 
20
- attr_reader :static
20
+ attr_reader :static, :access
21
21
 
22
22
  def static=(value)
23
23
  @static = !!value
24
24
  end
25
25
 
26
- attr_reader :access
27
-
28
26
  def access=(value)
29
27
  @access = value.to_s # TODO: Validate?
30
28
  end
@@ -10,14 +10,12 @@ module Lutaml
10
10
  class Method < Field
11
11
  include HasName
12
12
 
13
- attr_reader :abstract
13
+ attr_reader :abstract, :arguments
14
14
 
15
15
  def abstract=(value)
16
16
  @abstract = !!value
17
17
  end
18
18
 
19
- attr_reader :arguments
20
-
21
19
  def arguments=(value)
22
20
  @arguments = value.to_a.map do |attributes|
23
21
  MethodArgument.new(attributes)
@@ -11,14 +11,12 @@ module Lutaml
11
11
  include HasName
12
12
  include HasType
13
13
 
14
- attr_reader :from
14
+ attr_reader :from, :to
15
15
 
16
16
  def from=(value)
17
17
  @from = value.to_s
18
18
  end
19
19
 
20
- attr_reader :to
21
-
22
20
  def to=(value)
23
21
  @to = value.to_s
24
22
  end
@@ -19,12 +19,12 @@ module Lutaml
19
19
 
20
20
  def definition=(value)
21
21
  @definition = value
22
- .to_s
23
- .gsub(/\\}/, '}')
24
- .gsub(/\\{/, '{')
25
- .split("\n")
26
- .map(&:strip)
27
- .join("\n")
22
+ .to_s
23
+ .gsub(/\\}/, "}")
24
+ .gsub(/\\{/, "{")
25
+ .split("\n")
26
+ .map(&:strip)
27
+ .join("\n")
28
28
  end
29
29
  end
30
30
  end
@@ -10,7 +10,9 @@ module Lutaml
10
10
 
11
11
  def initialize(attributes)
12
12
  update_attributes(attributes)
13
- @children_packages ||= packages.map { |pkg| [pkg, pkg.packages, pkg.packages.map(&:children_packages)] }.flatten.uniq
13
+ @children_packages ||= packages.map do |pkg|
14
+ [pkg, pkg.packages, pkg.packages.map(&:children_packages)]
15
+ end.flatten.uniq
14
16
  end
15
17
 
16
18
  def classes=(value)
@@ -18,11 +18,9 @@ module Lutaml
18
18
 
19
19
  def parse(io, options = {})
20
20
  tree = Transform.new.apply(super)
21
- tree = tree[:assignments].each_with_object({}) do |assignment, memo|
21
+ tree[:assignments].each_with_object({}) do |assignment, memo|
22
22
  memo[assignment[:name].to_s] = assignment[:value]
23
23
  end
24
-
25
- tree
26
24
  end
27
25
 
28
26
  rule(:spaces) { match("\s").repeat(1) }
@@ -10,6 +10,7 @@ module Lutaml
10
10
  module Uml
11
11
  module Parsers
12
12
  class ParsingError < StandardError; end
13
+
13
14
  # Class for parsing LutaML dsl into Lutaml::Uml::Document
14
15
  class Dsl < Parslet::Parser
15
16
  # @param [String] io - LutaML string representation
@@ -92,9 +93,9 @@ module Lutaml
92
93
  str(")")).maybe
93
94
  end
94
95
  rule(:cardinality_body_definition) do
95
- match['0-9\*'].as('min') >>
96
+ match['0-9\*'].as("min") >>
96
97
  str("..").maybe >>
97
- match['0-9\*'].as('max').maybe
98
+ match['0-9\*'].as("max").maybe
98
99
  end
99
100
  rule(:cardinality) do
100
101
  str("[") >>
@@ -210,11 +211,11 @@ module Lutaml
210
211
  spaces? >>
211
212
  str("[") >>
212
213
  cardinality_body_definition
213
- .as("#{association_end_type}_end_cardinality") >>
214
+ .as("#{association_end_type}_end_cardinality") >>
214
215
  str("]")
215
216
  end
216
217
  rule("#{association_end_type}_cardinality?") do
217
- send("#{association_end_type}_cardinality").maybe
218
+ send(:"#{association_end_type}_cardinality").maybe
218
219
  end
219
220
  rule("#{association_end_type}_attribute_name") do
220
221
  str("#") >>
@@ -222,17 +223,17 @@ module Lutaml
222
223
  name.as("#{association_end_type}_end_attribute_name")
223
224
  end
224
225
  rule("#{association_end_type}_attribute_name?") do
225
- send("#{association_end_type}_attribute_name").maybe
226
+ send(:"#{association_end_type}_attribute_name").maybe
226
227
  end
227
228
  rule("#{association_end_type}_definition") do
228
- send("kw_#{association_end_type}") >>
229
+ send(:"kw_#{association_end_type}") >>
229
230
  spaces >>
230
231
  name.as("#{association_end_type}_end") >>
231
- send("#{association_end_type}_attribute_name?") >>
232
- send("#{association_end_type}_cardinality?")
232
+ send(:"#{association_end_type}_attribute_name?") >>
233
+ send(:"#{association_end_type}_cardinality?")
233
234
  end
234
235
  rule("#{association_end_type}_type") do
235
- send("kw_#{association_end_type}_type") >>
236
+ send(:"kw_#{association_end_type}_type") >>
236
237
  spaces >>
237
238
  name.as("#{association_end_type}_end_type")
238
239
  end
@@ -303,7 +304,7 @@ module Lutaml
303
304
  whitespace? >>
304
305
  str("{") >>
305
306
  ((str("\\") >> any) | (str("}").absent? >> any)).repeat.maybe.as(:definition) >>
306
- str('}')
307
+ str("}")
307
308
  end
308
309
 
309
310
  # -- Enum
@@ -43,12 +43,13 @@ module Lutaml
43
43
  return line if include_path_match.nil? || line =~ /^\s\*\*/
44
44
 
45
45
  path_to_file = include_path_match[1].strip
46
- path_to_file = if path_to_file.match?(/^\//)
47
- path_to_file
48
- else
49
- File.join(include_root, path_to_file)
50
- end
51
- File.read(path_to_file).split("\n").map { |line| process_comment_line(line) }
46
+ unless path_to_file.match?(/^\//)
47
+ path_to_file = File.join(include_root,
48
+ path_to_file)
49
+ end
50
+ File.read(path_to_file).split("\n").map do |line|
51
+ process_comment_line(line)
52
+ end
52
53
  rescue Errno::ENOENT
53
54
  puts("No such file or directory @ rb_sysopen - #{path_to_file}, \
54
55
  include file paths need to be supplied relative to the main document")
@@ -33,8 +33,8 @@ module Lutaml
33
33
  yaml_content["imports"].map do |(klass_name, _)|
34
34
  klass_attrs = YAML.safe_load(
35
35
  File.read(
36
- File.join(models_path, "#{klass_name}.yml")
37
- )
36
+ File.join(models_path, "#{klass_name}.yml"),
37
+ ),
38
38
  )
39
39
  klass_attrs["name"] = klass_name if klass_attrs["name"].nil?
40
40
  Lutaml::Uml::Serializers::Class.new(klass_attrs)
@@ -18,7 +18,7 @@ module Lutaml
18
18
  end)
19
19
  property :associations,
20
20
  from: :relations,
21
- coerce: Array[::Lutaml::Uml::Serializers::Association]
21
+ coerce: [::Lutaml::Uml::Serializers::Association]
22
22
  property :name
23
23
  # property :type, from: :modelType
24
24
  # property :relations,
@@ -33,10 +33,10 @@ module Lutaml
33
33
  next_namespace = namespace
34
34
 
35
35
  while !next_namespace.nil?
36
- the_name = if !next_namespace.name.nil?
37
- next_namespace.name + "::" + the_name
36
+ the_name = if next_namespace.name.nil?
37
+ "::#{the_name}"
38
38
  else
39
- "::" + the_name
39
+ "#{next_namespace.name}::#{the_name}"
40
40
  end
41
41
  next_namespace = next_namespace.namespace
42
42
  end
@@ -46,12 +46,12 @@ module Lutaml
46
46
 
47
47
  def definition=(value)
48
48
  @definition = value
49
- .to_s
50
- .gsub(/\\}/, '}')
51
- .gsub(/\\{/, '{')
52
- .split("\n")
53
- .map(&:strip)
54
- .join("\n")
49
+ .to_s
50
+ .gsub(/\\}/, "}")
51
+ .gsub(/\\{/, "{")
52
+ .split("\n")
53
+ .map(&:strip)
54
+ .join("\n")
55
55
  end
56
56
  end
57
57
  end
@@ -27,12 +27,12 @@ module Lutaml
27
27
 
28
28
  def definition=(value)
29
29
  @definition = value
30
- .to_s
31
- .gsub(/\\}/, '}')
32
- .gsub(/\\{/, '{')
33
- .split("\n")
34
- .map(&:strip)
35
- .join("\n")
30
+ .to_s
31
+ .gsub(/\\}/, "}")
32
+ .gsub(/\\{/, "{")
33
+ .split("\n")
34
+ .map(&:strip)
35
+ .join("\n")
36
36
  end
37
37
  end
38
38
  end
@@ -19,12 +19,12 @@ module Lutaml
19
19
 
20
20
  def definition=(value)
21
21
  @definition = value
22
- .to_s
23
- .gsub(/\\}/, '}')
24
- .gsub(/\\{/, '{')
25
- .split("\n")
26
- .map(&:strip)
27
- .join("\n")
22
+ .to_s
23
+ .gsub(/\\}/, "}")
24
+ .gsub(/\\{/, "{")
25
+ .split("\n")
26
+ .map(&:strip)
27
+ .join("\n")
28
28
  end
29
29
  end
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.9.28".freeze
2
+ VERSION = "0.9.29".freeze
3
3
  end
@@ -3,44 +3,64 @@
3
3
  module Lutaml
4
4
  module XMI
5
5
  class AssociationDrop < Liquid::Drop
6
- def initialize(model) # rubocop:disable Lint/MissingSuper
7
- @model = model
6
+ include Parsers::XMIBase
7
+
8
+ def initialize( # rubocop:disable Lint/MissingSuper,Metrics/ParameterLists
9
+ xmi_id:,
10
+ member_end:,
11
+ member_end_type:,
12
+ member_end_cardinality:,
13
+ member_end_attribute_name:,
14
+ member_end_xmi_id:,
15
+ owner_end:,
16
+ owner_end_xmi_id:,
17
+ definition:
18
+ )
19
+ @xmi_id = xmi_id
20
+ @member_end = member_end
21
+ @member_end_type = member_end_type
22
+ @member_end_cardinality = member_end_cardinality
23
+ @member_end_attribute_name = member_end_attribute_name
24
+ @member_end_xmi_id = member_end_xmi_id
25
+ @owner_end = owner_end
26
+ @owner_end_xmi_id = owner_end_xmi_id
27
+ @definition = definition
8
28
  end
9
29
 
10
30
  def xmi_id
11
- @model[:xmi_id]
31
+ @xmi_id
12
32
  end
13
33
 
14
34
  def member_end
15
- @model[:member_end]
35
+ @member_end
16
36
  end
17
37
 
18
38
  def member_end_type
19
- @model[:member_end_type]
39
+ @member_end_type
20
40
  end
21
41
 
22
42
  def member_end_cardinality
23
- ::Lutaml::XMI::CardinalityDrop.new(@model[:member_end_cardinality])
43
+ ::Lutaml::XMI::CardinalityDrop.new(@member_end_cardinality)
24
44
  end
25
45
 
26
46
  def member_end_attribute_name
27
- @model[:member_end_attribute_name]
47
+ @member_end_attribute_name
28
48
  end
29
49
 
30
50
  def member_end_xmi_id
31
- @model[:member_end_xmi_id]
51
+ @member_end_xmi_id
32
52
  end
33
53
 
34
54
  def owner_end
35
- @model[:owner_end]
55
+ @owner_end
36
56
  end
37
57
 
38
58
  def owner_end_xmi_id
39
- @model[:owner_end_xmi_id]
59
+ @owner_end_xmi_id
40
60
  end
41
61
 
42
62
  def definition
43
- @model[:definition]
63
+ @definition
44
64
  end
45
65
  end
46
66
  end
@@ -3,44 +3,62 @@
3
3
  module Lutaml
4
4
  module XMI
5
5
  class AttributeDrop < Liquid::Drop
6
- def initialize(model) # rubocop:disable Lint/MissingSuper
6
+ include Parsers::XMIBase
7
+
8
+ def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper
7
9
  @model = model
10
+ @options = options
11
+ @xmi_root_model = options[:xmi_root_model]
12
+ @xmi_cache = options[:xmi_cache]
13
+
14
+ uml_type = @model.uml_type
15
+ @uml_type_idref = uml_type.idref if uml_type
8
16
  end
9
17
 
10
18
  def id
11
- @model[:id]
19
+ @model.id
12
20
  end
13
21
 
14
22
  def name
15
- @model[:name]
23
+ @model.name
16
24
  end
17
25
 
18
26
  def type
19
- @model[:type]
27
+ lookup_entity_name(@uml_type_idref) || @uml_type_idref
20
28
  end
21
29
 
22
30
  def xmi_id
23
- @model[:xmi_id]
31
+ @uml_type_idref
24
32
  end
25
33
 
26
- def is_derived
27
- @model[:is_derived]
34
+ def is_derived # rubocop:disable Naming/PredicateName
35
+ @model.is_derived
28
36
  end
29
37
 
30
38
  def cardinality
31
- ::Lutaml::XMI::CardinalityDrop.new(@model[:cardinality])
39
+ ::Lutaml::XMI::CardinalityDrop.new(@model)
32
40
  end
33
41
 
34
42
  def definition
35
- @model[:definition]
43
+ definition = lookup_attribute_documentation(@model.id)
44
+
45
+ if @options[:with_assoc] && @model.association
46
+ definition = loopup_assoc_def(@model.association)
47
+ end
48
+
49
+ definition
36
50
  end
37
51
 
38
52
  def association
39
- @model[:association]
53
+ if @options[:with_assoc] && @model.association
54
+ @model.association
55
+ end
40
56
  end
41
57
 
42
58
  def type_ns
43
- @model[:type_ns]
59
+ if @options[:with_assoc] && @model.association
60
+ get_ns_by_xmi_id(xmi_id)
61
+ end
44
62
  end
45
63
  end
46
64
  end
@@ -3,16 +3,22 @@
3
3
  module Lutaml
4
4
  module XMI
5
5
  class CardinalityDrop < Liquid::Drop
6
+ include Parsers::XMIBase
7
+
6
8
  def initialize(model) # rubocop:disable Lint/MissingSuper
7
9
  @model = model
8
10
  end
9
11
 
10
12
  def min
11
- @model[:min]
13
+ return @model[:min] if @model.is_a?(Hash)
14
+
15
+ @model.lower_value&.value
12
16
  end
13
17
 
14
18
  def max
15
- @model[:max]
19
+ return @model[:max] if @model.is_a?(Hash)
20
+
21
+ @model.upper_value&.value
16
22
  end
17
23
  end
18
24
  end