lutaml 0.10.9 → 0.10.10

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +42 -8
  3. data/lib/lutaml/cli/interactive_shell/command_base.rb +2 -2
  4. data/lib/lutaml/cli/interactive_shell/query_commands.rb +1 -1
  5. data/lib/lutaml/cli/interactive_shell.rb +21 -18
  6. data/lib/lutaml/cli/resource_registry.rb +1 -1
  7. data/lib/lutaml/cli/uml/inspect_command.rb +1 -1
  8. data/lib/lutaml/converter/dsl_to_uml.rb +8 -8
  9. data/lib/lutaml/converter/xmi_to_uml.rb +2 -2
  10. data/lib/lutaml/ea/diagram/style_parser.rb +15 -15
  11. data/lib/lutaml/ea/diagram/style_resolver.rb +4 -3
  12. data/lib/lutaml/formatter/graphviz.rb +1 -1
  13. data/lib/lutaml/model_transformations/parsers/qea_parser.rb +2 -4
  14. data/lib/lutaml/model_transformations/parsers/xmi_parser.rb +1 -6
  15. data/lib/lutaml/qea/factory/document_builder.rb +3 -3
  16. data/lib/lutaml/qea/lookup_indexes.rb +2 -2
  17. data/lib/lutaml/qea/models/base_model.rb +1 -1
  18. data/lib/lutaml/qea/repositories/base_repository.rb +7 -7
  19. data/lib/lutaml/qea/validation/base_validator.rb +5 -3
  20. data/lib/lutaml/qea/verification/element_comparator.rb +18 -47
  21. data/lib/lutaml/uml/association_generalization.rb +1 -0
  22. data/lib/lutaml/uml/class.rb +0 -1
  23. data/lib/lutaml/uml/classifier.rb +3 -0
  24. data/lib/lutaml/uml/data_type.rb +0 -1
  25. data/lib/lutaml/uml/has_attributes.rb +1 -1
  26. data/lib/lutaml/uml/has_members.rb +1 -1
  27. data/lib/lutaml/uml/inheritance_walker.rb +4 -4
  28. data/lib/lutaml/uml/model_helpers.rb +5 -62
  29. data/lib/lutaml/uml/operation.rb +6 -0
  30. data/lib/lutaml/uml/operation_parameter.rb +17 -0
  31. data/lib/lutaml/uml/qualified_name.rb +4 -5
  32. data/lib/lutaml/uml/top_element_attribute.rb +4 -0
  33. data/lib/lutaml/uml/validation/document_structure_validator.rb +4 -4
  34. data/lib/lutaml/uml_repository/class_lookup_index.rb +1 -1
  35. data/lib/lutaml/uml_repository/exporters/json_exporter.rb +1 -1
  36. data/lib/lutaml/uml_repository/exporters/markdown/class_page_builder.rb +2 -2
  37. data/lib/lutaml/uml_repository/index_builder.rb +15 -15
  38. data/lib/lutaml/uml_repository/package_exporter.rb +3 -5
  39. data/lib/lutaml/uml_repository/package_loader.rb +3 -3
  40. data/lib/lutaml/uml_repository/queries/association_query.rb +2 -2
  41. data/lib/lutaml/uml_repository/queries/inheritance_query.rb +9 -13
  42. data/lib/lutaml/uml_repository/queries/search_query.rb +7 -7
  43. data/lib/lutaml/uml_repository/query_dsl/conditions/hash_condition.rb +2 -2
  44. data/lib/lutaml/uml_repository/query_dsl/order.rb +2 -2
  45. data/lib/lutaml/uml_repository/query_dsl/query_builder.rb +2 -2
  46. data/lib/lutaml/uml_repository/repository.rb +2 -2
  47. data/lib/lutaml/uml_repository/repository_enhanced.rb +1 -1
  48. data/lib/lutaml/uml_repository/static_site/association_serialization.rb +38 -86
  49. data/lib/lutaml/uml_repository/static_site/data_transformer.rb +13 -39
  50. data/lib/lutaml/uml_repository/static_site/models/spa_association.rb +32 -0
  51. data/lib/lutaml/uml_repository/static_site/models/spa_association_end.rb +28 -0
  52. data/lib/lutaml/uml_repository/static_site/models/spa_attribute.rb +42 -0
  53. data/lib/lutaml/uml_repository/static_site/models/spa_base.rb +12 -0
  54. data/lib/lutaml/uml_repository/static_site/models/spa_cardinality.rb +21 -0
  55. data/lib/lutaml/uml_repository/static_site/models/spa_class.rb +64 -0
  56. data/lib/lutaml/uml_repository/static_site/models/spa_diagram.rb +33 -0
  57. data/lib/lutaml/uml_repository/static_site/models/spa_document.rb +42 -0
  58. data/lib/lutaml/uml_repository/static_site/models/spa_inherited_association.rb +27 -0
  59. data/lib/lutaml/uml_repository/static_site/models/spa_inherited_attribute.rb +28 -0
  60. data/lib/lutaml/uml_repository/static_site/models/spa_literal.rb +21 -0
  61. data/lib/lutaml/uml_repository/static_site/models/spa_metadata.rb +26 -0
  62. data/lib/lutaml/uml_repository/static_site/models/spa_operation.rb +37 -0
  63. data/lib/lutaml/uml_repository/static_site/models/spa_package.rb +37 -0
  64. data/lib/lutaml/uml_repository/static_site/models/spa_package_tree_node.rb +35 -0
  65. data/lib/lutaml/uml_repository/static_site/models/spa_parameter.rb +23 -0
  66. data/lib/lutaml/uml_repository/static_site/models/spa_search_entry.rb +37 -0
  67. data/lib/lutaml/uml_repository/static_site/models/spa_statistics.rb +27 -0
  68. data/lib/lutaml/uml_repository/static_site/models/spa_tree_class_ref.rb +23 -0
  69. data/lib/lutaml/uml_repository/static_site/search_index_builder.rb +46 -131
  70. data/lib/lutaml/uml_repository/static_site/serializers/attribute_serializer.rb +11 -11
  71. data/lib/lutaml/uml_repository/static_site/serializers/class_serializer.rb +17 -16
  72. data/lib/lutaml/uml_repository/static_site/serializers/diagram_serializer.rb +8 -12
  73. data/lib/lutaml/uml_repository/static_site/serializers/inheritance_resolver.rb +44 -51
  74. data/lib/lutaml/uml_repository/static_site/serializers/metadata_builder.rb +8 -5
  75. data/lib/lutaml/uml_repository/static_site/serializers/operation_serializer.rb +14 -11
  76. data/lib/lutaml/uml_repository/static_site/serializers/package_serializer.rb +15 -17
  77. data/lib/lutaml/uml_repository/static_site/serializers/package_tree_builder.rb +19 -31
  78. data/lib/lutaml/uml_repository/statistics_calculator.rb +2 -4
  79. data/lib/lutaml/version.rb +1 -1
  80. data/lib/lutaml/xmi/parsers/xmi_base.rb +4 -4
  81. data/lib/lutaml/xmi/parsers/xmi_connector.rb +7 -7
  82. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c86294799b84e5b722bd271cba3e8f8bb47b5ca2b25a8e8a1fdfac763cc7ac42
4
- data.tar.gz: c32950a48ea9681d0091b16f5df20e99c64c107703677467709a28353630cc92
3
+ metadata.gz: f6bf7ec9ab56a8d2d17b70b191ee22dda71459f5c0e00f6066aa499a26427cde
4
+ data.tar.gz: a5b2f9ed9ac2f89b8bb76b65e0b648e41c42fd20fd94e422cc8a90403683c430
5
5
  SHA512:
6
- metadata.gz: 46ac28ea247ea946d5fa18d93824698d7b10756abb75b28992e148d22ea0e9c97e00a48b54eaa6929b1240a7732cca7edc60914edb243cbccb311de589611422
7
- data.tar.gz: 83e71c5fd9dd4237743ca89894edbc6ecbad02d67d47f115d24e20f085531322b6e94cdcbede356665c35c2e6fec4ae81facafc1de689fa934ad1f1db06685eb
6
+ metadata.gz: 112cf5de38571225fd17e354dc1c4bd2debd878841f2681423c7e616176e6bd93a8935f7d504c5be181b9f4d3a6ad5220e3ff102def9753796c821e899576e65
7
+ data.tar.gz: e7afc11d364ebfc3be4f651bb2fd389da30256504877209ee76154483be9b0525ca6a2dbd4fe2242a61d56447818030e304c31da02fdbd2b0851a7ff13d4d788
data/.rubocop_todo.yml CHANGED
@@ -1,18 +1,45 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-05-08 06:29:20 UTC using RuboCop version 1.86.1.
3
+ # on 2026-05-11 04:25:12 UTC using RuboCop version 1.86.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 172
9
+ # Offense count: 1
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: IndentationWidth.
12
+ Layout/AssignmentIndentation:
13
+ Exclude:
14
+ - 'lib/lutaml/ea/diagram/style_resolver.rb'
15
+
16
+ # Offense count: 1
17
+ # This cop supports safe autocorrection (--autocorrect).
18
+ # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
19
+ Layout/EmptyLineBetweenDefs:
20
+ Exclude:
21
+ - 'lib/lutaml/ea/diagram/style_parser.rb'
22
+
23
+ # Offense count: 1
24
+ # This cop supports safe autocorrection (--autocorrect).
25
+ Layout/EmptyLines:
26
+ Exclude:
27
+ - 'lib/lutaml/ea/diagram/style_parser.rb'
28
+
29
+ # Offense count: 159
10
30
  # This cop supports safe autocorrection (--autocorrect).
11
31
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
12
32
  # URISchemes: http, https
13
33
  Layout/LineLength:
14
34
  Enabled: false
15
35
 
36
+ # Offense count: 1
37
+ # This cop supports safe autocorrection (--autocorrect).
38
+ # Configuration parameters: AllowInHeredoc.
39
+ Layout/TrailingWhitespace:
40
+ Exclude:
41
+ - 'lib/lutaml/ea/diagram/style_resolver.rb'
42
+
16
43
  # Offense count: 1
17
44
  Lint/BinaryOperatorWithIdenticalOperands:
18
45
  Exclude:
@@ -88,17 +115,17 @@ Metrics/AbcSize:
88
115
  Metrics/BlockLength:
89
116
  Max: 53
90
117
 
91
- # Offense count: 37
118
+ # Offense count: 33
92
119
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
93
120
  Metrics/CyclomaticComplexity:
94
121
  Enabled: false
95
122
 
96
- # Offense count: 68
123
+ # Offense count: 74
97
124
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
98
125
  Metrics/MethodLength:
99
126
  Max: 62
100
127
 
101
- # Offense count: 29
128
+ # Offense count: 25
102
129
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
103
130
  Metrics/PerceivedComplexity:
104
131
  Enabled: false
@@ -168,7 +195,7 @@ RSpec/ContextWording:
168
195
  RSpec/DescribeClass:
169
196
  Enabled: false
170
197
 
171
- # Offense count: 654
198
+ # Offense count: 652
172
199
  # Configuration parameters: CountAsOne.
173
200
  RSpec/ExampleLength:
174
201
  Max: 30
@@ -222,9 +249,9 @@ RSpec/MessageSpies:
222
249
  - 'spec/lutaml/uml_repository/presenters/diagram_presenter_spec.rb'
223
250
  - 'spec/lutaml/uml_repository/repository_spec.rb'
224
251
 
225
- # Offense count: 38
252
+ # Offense count: 39
226
253
  RSpec/MultipleExpectations:
227
- Max: 6
254
+ Max: 7
228
255
 
229
256
  # Offense count: 151
230
257
  # Configuration parameters: AllowSubject.
@@ -307,3 +334,10 @@ Style/SafeNavigationChainLength:
307
334
  Exclude:
308
335
  - 'lib/lutaml/qea/validation/attribute_validator.rb'
309
336
  - 'lib/lutaml/qea/validation/operation_validator.rb'
337
+
338
+ # Offense count: 3
339
+ # This cop supports unsafe autocorrection (--autocorrect-all).
340
+ # Configuration parameters: AllowSend.
341
+ Style/SendWithLiteralMethodName:
342
+ Exclude:
343
+ - 'lib/lutaml/ea/diagram/style_resolver.rb'
@@ -14,7 +14,7 @@ module Lutaml
14
14
  def current_path = shell.current_path
15
15
 
16
16
  def current_path=(path)
17
- shell.instance_variable_set(:@current_path, path)
17
+ shell.current_path = path
18
18
  end
19
19
 
20
20
  def config = shell.config
@@ -22,7 +22,7 @@ module Lutaml
22
22
  def last_results = shell.last_results
23
23
 
24
24
  def last_results=(results)
25
- shell.instance_variable_set(:@last_results, results)
25
+ shell.last_results = results
26
26
  end
27
27
 
28
28
  def path_history = shell.path_history
@@ -110,7 +110,7 @@ module Lutaml
110
110
  end
111
111
 
112
112
  def show_package(path)
113
- nav = shell.instance_variable_get(:@navigation)
113
+ nav = shell.navigation
114
114
  path = nav.resolve_path(path)
115
115
  pkg = repository.find_package(path)
116
116
 
@@ -17,8 +17,11 @@ module Lutaml
17
17
  HISTORY_FILE = File.expand_path("~/.lutaml-xmi-history")
18
18
  MAX_HISTORY = 1000
19
19
 
20
- attr_reader :repository, :current_path, :config, :bookmarks,
21
- :last_results, :path_history
20
+ attr_reader :repository, :config, :bookmarks,
21
+ :path_history,
22
+ :navigation, :query, :bookmarks_cmd, :export, :help
23
+
24
+ attr_accessor :current_path, :last_results
22
25
 
23
26
  def initialize(lur_path_or_repo, config: nil)
24
27
  @config = {
@@ -83,25 +86,25 @@ module Lutaml
83
86
 
84
87
  COMMAND_DISPATCH = {
85
88
  # Navigation
86
- "cd" => :@navigation, "pwd" => :@navigation,
87
- "ls" => :@navigation, "list" => :@navigation,
88
- "tree" => :@navigation, "up" => :@navigation,
89
- "root" => :@navigation, "back" => :@navigation,
89
+ "cd" => :navigation, "pwd" => :navigation,
90
+ "ls" => :navigation, "list" => :navigation,
91
+ "tree" => :navigation, "up" => :navigation,
92
+ "root" => :navigation, "back" => :navigation,
90
93
  # Query
91
- "find" => :@query, "f" => :@query,
92
- "show" => :@query, "s" => :@query,
93
- "search" => :@query, "?" => :@query,
94
- "results" => :@query,
94
+ "find" => :query, "f" => :query,
95
+ "show" => :query, "s" => :query,
96
+ "search" => :query, "?" => :query,
97
+ "results" => :query,
95
98
  # Bookmarks
96
- "bookmark" => :@bookmarks_cmd, "bm" => :@bookmarks_cmd,
99
+ "bookmark" => :bookmarks_cmd, "bm" => :bookmarks_cmd,
97
100
  # Export
98
- "export" => :@export,
101
+ "export" => :export,
99
102
  # Utilities
100
- "help" => :@help, "h" => :@help,
101
- "history" => :@help,
102
- "clear" => :@help, "cls" => :@help,
103
- "config" => :@help,
104
- "stats" => :@help
103
+ "help" => :help, "h" => :help,
104
+ "history" => :help,
105
+ "clear" => :help, "cls" => :help,
106
+ "config" => :help,
107
+ "stats" => :help
105
108
  }.freeze
106
109
 
107
110
  METHOD_MAP = {
@@ -136,7 +139,7 @@ module Lutaml
136
139
  method_name = METHOD_MAP[command]
137
140
 
138
141
  if handler_var && method_name
139
- instance_variable_get(handler_var).send(method_name, args)
142
+ public_send(handler_var).public_send(method_name, args)
140
143
  else
141
144
  puts OutputFormatter.warning("Unknown command: #{command}")
142
145
  puts "Type 'help' for available commands"
@@ -10,7 +10,7 @@ module Lutaml
10
10
  #
11
11
  # @example Get configuration for a type
12
12
  # config = ResourceRegistry.config_for(:class)
13
- # classes = repository.send(config[:list_method])
13
+ # classes = repository.public_send(config[:list_method])
14
14
  #
15
15
  # @example List all available types
16
16
  # ResourceRegistry.types # => [:package, :class, :diagram, ...]
@@ -66,7 +66,7 @@ module Lutaml
66
66
  config = ResourceRegistry.config_for(identifier.type)
67
67
  return nil unless config
68
68
 
69
- repo.send(config[:find_method], identifier.path)
69
+ repo.public_send(config[:find_method], identifier.path)
70
70
  end
71
71
 
72
72
  def display_element_details(element, identifier, repo)
@@ -101,14 +101,14 @@ module Lutaml
101
101
  .split("\n").map(&:strip).join("\n")
102
102
  end
103
103
 
104
- if model.respond_to?("#{key}=")
105
- if model.class.attributes[key.to_sym].options[:collection]
106
- values = model.send(key.to_sym).to_a
107
- values << value
108
- model.send("#{key}=", values)
109
- else
110
- model.send("#{key}=", value)
111
- end
104
+ next unless model.class.attributes.key?(key.to_sym)
105
+
106
+ if model.class.attributes[key.to_sym].options[:collection]
107
+ values = model.public_send(key.to_sym).to_a
108
+ values << value
109
+ model.public_send("#{key}=", values)
110
+ else
111
+ model.public_send("#{key}=", value)
112
112
  end
113
113
  end
114
114
  end
@@ -271,7 +271,7 @@ module Lutaml
271
271
  uml_type = operation.uml_type.first
272
272
  uml_type_idref = uml_type.idref if uml_type
273
273
 
274
- if !operation.respond_to?(:association) || operation.association.nil?
274
+ if !operation.class.attributes.key?(:association) || operation.association.nil?
275
275
  ::Lutaml::Uml::Operation.new.tap do |op|
276
276
  op.id = operation.id
277
277
  op.xmi_id = uml_type_idref
@@ -289,7 +289,7 @@ module Lutaml
289
289
  # In ea-xmi-2.5.1, constraints are moved to source/target under
290
290
  # connectors
291
291
  constraints = %i[source target].map do |st|
292
- connector_node.send(st).constraints.constraint
292
+ connector_node.public_send(st).constraints.constraint
293
293
  end.flatten
294
294
 
295
295
  constraints.map do |constraint|
@@ -139,6 +139,21 @@ module Lutaml
139
139
  base_style
140
140
  end
141
141
 
142
+ # Convert EA color integer to hex color
143
+ # (EA stores colors as BGR integers)
144
+ # @param ea_color [Integer] EA color value
145
+ # @return [String] Hex color string
146
+ def color_from_ea_color(ea_color)
147
+ return EA_COLORS[:class_fill] if ea_color.zero?
148
+
149
+ # EA colors are stored as BGR, convert to RGB
150
+ b = (ea_color & 0xFF0000) >> 16
151
+ g = (ea_color & 0x00FF00) >> 8
152
+ r = ea_color & 0x0000FF
153
+
154
+ format("#%02x%02x%02x", r, g, b).upcase # rubocop:disable Style/FormatStringToken
155
+ end
156
+
142
157
  private
143
158
 
144
159
  def get_base_element_style(element_type) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
@@ -277,21 +292,6 @@ module Lutaml
277
292
  style
278
293
  end
279
294
 
280
- # Convert EA color integer to hex color
281
- # (EA stores colors as BGR integers)
282
- # @param ea_color [Integer] EA color value
283
- # @return [String] Hex color string
284
- def color_from_ea_color(ea_color)
285
- return EA_COLORS[:class_fill] if ea_color.zero?
286
-
287
- # EA colors are stored as BGR, convert to RGB
288
- b = (ea_color & 0xFF0000) >> 16
289
- g = (ea_color & 0x00FF00) >> 8
290
- r = ea_color & 0x0000FF
291
-
292
- format("#%02x%02x%02x", r, g, b).upcase # rubocop:disable Style/FormatStringToken
293
- end
294
-
295
295
  # Get stereotype-specific styling
296
296
  # (EA has specific colors for stereotypes)
297
297
  # @param stereotype [String] Stereotype name
@@ -182,11 +182,12 @@ module Lutaml
182
182
  case key.strip
183
183
  when "BCol"
184
184
  # Background color (BGR integer)
185
- style[:fill] = style_parser.send(:color_from_ea_color, value.to_i)
185
+ style[:fill] =
186
+ style_parser.color_from_ea_color(value.to_i)
186
187
  when "LCol"
187
188
  # Line color (BGR integer)
188
189
  style[:stroke] =
189
- style_parser.send(:color_from_ea_color, value.to_i)
190
+ style_parser.color_from_ea_color(value.to_i)
190
191
  when "BFol"
191
192
  # Bold font (0 or 1)
192
193
  style[:font_weight] = value == "1" ? 700 : 400
@@ -220,7 +221,7 @@ module Lutaml
220
221
  when "LCol"
221
222
  # Line color
222
223
  style[:stroke] =
223
- style_parser.send(:color_from_ea_color, value.to_i)
224
+ style_parser.color_from_ea_color(value.to_i)
224
225
  when "LWth"
225
226
  # Line width
226
227
  style[:stroke_width] = value.to_i
@@ -237,7 +237,7 @@ module Lutaml
237
237
  HEREDOC
238
238
 
239
239
  field_table = format_member_rows(node.attributes, hide_members)
240
- method_table = if node.respond_to?(:operations)
240
+ method_table = if node.operations&.any?
241
241
  format_member_rows(node.operations, hide_members)
242
242
  end
243
243
  table_body = [name_html, field_table, method_table].map do |type|
@@ -301,12 +301,10 @@ module Lutaml
301
301
  }
302
302
 
303
303
  # Store metadata using various approaches
304
- if document.respond_to?(:parsing_metadata=)
304
+ if document.class.method_defined?(:parsing_metadata=)
305
305
  document.parsing_metadata = metadata
306
- elsif document.respond_to?(:metadata=)
306
+ elsif document.class.method_defined?(:metadata=)
307
307
  document.metadata = metadata
308
- else
309
- document.instance_variable_set(:@qea_metadata, metadata)
310
308
  end
311
309
  end
312
310
 
@@ -165,13 +165,8 @@ module Lutaml
165
165
  options: @options,
166
166
  }
167
167
 
168
- # Store metadata if document supports it
169
- if document.respond_to?(:parsing_metadata=)
168
+ if document.class.method_defined?(:parsing_metadata=)
170
169
  document.parsing_metadata = metadata
171
- elsif document.respond_to?(:instance_variable_set)
172
- # Store in custom attribute if available
173
- document.instance_variable_set(:@parsing_metadata,
174
- metadata)
175
170
  end
176
171
  end
177
172
 
@@ -238,7 +238,7 @@ module Lutaml
238
238
  # @param valid_ids [Set<String>] Set of valid xmi_ids
239
239
  # @return [Boolean] True if valid or nil
240
240
  def check_association_end_valid?(assoc, attr, valid_ids)
241
- value = assoc.send(attr)
241
+ value = assoc.public_send(attr)
242
242
  return true if value.nil?
243
243
 
244
244
  valid_ids.include?(value)
@@ -250,14 +250,14 @@ module Lutaml
250
250
  # @param valid_ids [Set<String>] Set of valid xmi_ids
251
251
  # @param warnings [Array<String>] Warning accumulator
252
252
  def add_invalid_end_warning(assoc, attr, valid_ids, warnings) # rubocop:disable Metrics/MethodLength
253
- value = assoc.send(attr)
253
+ value = assoc.public_send(attr)
254
254
  return if value.nil?
255
255
 
256
256
  unless valid_ids.include?(value)
257
257
  # Get the corresponding name attribute for better error messages
258
258
  name_attr = attr.to_s.gsub("_xmi_id", "").to_sym
259
259
  name_value = begin
260
- assoc.send(name_attr)
260
+ assoc.public_send(name_attr)
261
261
  rescue StandardError
262
262
  nil
263
263
  end
@@ -17,12 +17,12 @@ module Lutaml
17
17
  def build_group_index(collection, method, single: false)
18
18
  if single
19
19
  collection.each_with_object({}) do |item, hash|
20
- key = item.send(method)
20
+ key = item.public_send(method)
21
21
  hash[key] = item if key
22
22
  end
23
23
  else
24
24
  collection.each_with_object({}) do |item, hash|
25
- key = item.send(method)
25
+ key = item.public_send(method)
26
26
  (hash[key] ||= []) << item if key
27
27
  end
28
28
  end
@@ -25,7 +25,7 @@ module Lutaml
25
25
  # Returns the primary key value for this instance
26
26
  # @return [Object] the primary key value
27
27
  def primary_key
28
- send(self.class.primary_key_column)
28
+ public_send(self.class.primary_key_column)
29
29
  end
30
30
 
31
31
  # Create instance from database row hash
@@ -57,7 +57,7 @@ module Lutaml
57
57
  # @param id [Object] key value
58
58
  # @return [Object, nil] The record or nil if not found
59
59
  def find_by_key(key, id)
60
- @records.find { |record| record.send(key) == id }
60
+ @records.find { |record| record.public_send(key) == id }
61
61
  end
62
62
 
63
63
  # Filter records by conditions
@@ -79,7 +79,7 @@ module Lutaml
79
79
  elsif conditions.is_a?(Hash)
80
80
  @records.select do |record|
81
81
  conditions.all? do |attr, value|
82
- record.respond_to?(attr) && record.send(attr) == value
82
+ record.public_send(attr) == value
83
83
  end
84
84
  end
85
85
  else
@@ -150,8 +150,8 @@ module Lutaml
150
150
  # # => [{id: 1, name: "Test"}, {id: 2, name: "Other"}]
151
151
  def pluck(*attributes)
152
152
  @records.map do |record|
153
- attributes.each_with_object({}) do |attr, hash|
154
- hash[attr] = record.send(attr) if record.respond_to?(attr)
153
+ attributes.to_h do |attr|
154
+ [attr, record.public_send(attr)]
155
155
  end
156
156
  end
157
157
  end
@@ -165,7 +165,7 @@ module Lutaml
165
165
  # repository.group_by(:type)
166
166
  # # => {"Class" => [obj1, obj2], "Interface" => [obj3]}
167
167
  def group_by(attribute)
168
- @records.group_by { |record| record.send(attribute) }
168
+ @records.group_by { |record| record.public_send(attribute) }
169
169
  end
170
170
 
171
171
  # Sort records by an attribute
@@ -178,7 +178,7 @@ module Lutaml
178
178
  # repository.order_by(:name)
179
179
  # repository.order_by(:created_at, :desc)
180
180
  def order_by(attribute, order = :asc)
181
- sorted = @records.sort_by { |record| record.send(attribute) }
181
+ sorted = @records.sort_by { |record| record.public_send(attribute) }
182
182
  order == :desc ? sorted.reverse : sorted
183
183
  end
184
184
 
@@ -191,7 +191,7 @@ module Lutaml
191
191
  # repository.distinct(:type)
192
192
  # # => ["Class", "Interface", "Component"]
193
193
  def distinct(attribute)
194
- @records.map { |record| record.send(attribute) }.uniq
194
+ @records.map { |record| record.public_send(attribute) }.uniq
195
195
  end
196
196
 
197
197
  # Check if repository is empty
@@ -122,7 +122,9 @@ module Lutaml
122
122
  collection = get_collection_for_table(table)
123
123
  return false unless collection
124
124
 
125
- collection.any? { |record| record.send(id_column) == reference_id }
125
+ collection.any? do |record|
126
+ record.public_send(id_column) == reference_id
127
+ end
126
128
  end
127
129
 
128
130
  # Maps table names to their corresponding collections in Database
@@ -223,8 +225,8 @@ module Lutaml
223
225
  collection = get_collection_for_table(table)
224
226
  return nil unless collection
225
227
 
226
- record = collection.find { |r| r.send(id_column) == id }
227
- record&.send(name_column)
228
+ record = collection.find { |r| r.public_send(id_column) == id }
229
+ record&.public_send(name_column)
228
230
  end
229
231
 
230
232
  # Validates a collection of entities
@@ -52,25 +52,19 @@ module Lutaml
52
52
  end
53
53
 
54
54
  # Compare is_abstract
55
- if xmi_class.respond_to?(:is_abstract) &&
56
- qea_class.respond_to?(:is_abstract) &&
57
- xmi_class.is_abstract != qea_class.is_abstract
55
+ if xmi_class.is_abstract != qea_class.is_abstract
58
56
  differences << "is_abstract: #{xmi_class.is_abstract} " \
59
57
  "vs #{qea_class.is_abstract}"
60
58
  end
61
59
 
62
60
  # Compare type
63
- if xmi_class.respond_to?(:type) &&
64
- qea_class.respond_to?(:type) &&
65
- normalize_value(xmi_class.type) != normalize_value(qea_class.type)
61
+ if normalize_value(xmi_class.type) != normalize_value(qea_class.type)
66
62
  differences << "type: '#{xmi_class.type}' vs '#{qea_class.type}'"
67
63
  end
68
64
 
69
65
  # Compare modifier
70
- if xmi_class.respond_to?(:modifier) &&
71
- qea_class.respond_to?(:modifier) &&
72
- normalize_value(xmi_class.modifier) !=
73
- normalize_value(qea_class.modifier)
66
+ if normalize_value(xmi_class.modifier) !=
67
+ normalize_value(qea_class.modifier)
74
68
  differences << "modifier: '#{xmi_class.modifier}' " \
75
69
  "vs '#{qea_class.modifier}'"
76
70
  end
@@ -105,27 +99,22 @@ module Lutaml
105
99
  end
106
100
 
107
101
  # Compare type
108
- if xmi_attr.respond_to?(:type) &&
109
- qea_attr.respond_to?(:type) &&
110
- normalize_value(xmi_attr.type) !=
111
- normalize_value(qea_attr.type)
102
+ if normalize_value(xmi_attr.type) !=
103
+ normalize_value(qea_attr.type)
112
104
  differences << "type: '#{xmi_attr.type}' vs '#{qea_attr.type}'"
113
105
  end
114
106
 
115
107
  # Compare visibility
116
- if xmi_attr.respond_to?(:visibility) &&
117
- qea_attr.respond_to?(:visibility) &&
118
- normalize_value(xmi_attr.visibility) !=
119
- normalize_value(qea_attr.visibility)
108
+ if normalize_value(xmi_attr.visibility) !=
109
+ normalize_value(qea_attr.visibility)
120
110
  differences << "visibility: '#{xmi_attr.visibility}' " \
121
111
  "vs '#{qea_attr.visibility}'"
122
112
  end
123
113
 
124
114
  # Compare cardinality if present
125
- if xmi_attr.respond_to?(:cardinality) &&
126
- qea_attr.respond_to?(:cardinality)
127
- xmi_card = xmi_attr.cardinality
128
- qea_card = qea_attr.cardinality
115
+ xmi_card = xmi_attr.cardinality
116
+ qea_card = qea_attr.cardinality
117
+ if xmi_card || qea_card
129
118
  if xmi_card && qea_card
130
119
  unless cardinalities_equal?(xmi_card, qea_card)
131
120
  differences << "cardinality: #{format_cardinality(xmi_card)} " \
@@ -157,19 +146,15 @@ module Lutaml
157
146
  end
158
147
 
159
148
  # Compare return type
160
- if xmi_op.respond_to?(:return_type) &&
161
- qea_op.respond_to?(:return_type) &&
162
- normalize_value(xmi_op.return_type) !=
163
- normalize_value(qea_op.return_type)
149
+ if normalize_value(xmi_op.return_type) !=
150
+ normalize_value(qea_op.return_type)
164
151
  differences << "return_type: '#{xmi_op.return_type}' " \
165
152
  "vs '#{qea_op.return_type}'"
166
153
  end
167
154
 
168
155
  # Compare visibility
169
- if xmi_op.respond_to?(:visibility) &&
170
- qea_op.respond_to?(:visibility) &&
171
- normalize_value(xmi_op.visibility) !=
172
- normalize_value(qea_op.visibility)
156
+ if normalize_value(xmi_op.visibility) !=
157
+ normalize_value(qea_op.visibility)
173
158
  differences << "visibility: '#{xmi_op.visibility}' " \
174
159
  "vs '#{qea_op.visibility}'"
175
160
  end
@@ -273,32 +258,18 @@ module Lutaml
273
258
  end
274
259
 
275
260
  # Check if cardinalities are equal
276
- def cardinalities_equal?(card1, card2) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
261
+ def cardinalities_equal?(card1, card2)
277
262
  return true if card1.nil? && card2.nil?
278
263
  return false if card1.nil? || card2.nil?
279
264
 
280
- min_equal = (
281
- card1.min || (card1.respond_to?(:min_value) && card1.min_value)
282
- ) == (
283
- card2.min || (card2.respond_to?(:min_value) && card2.min_value)
284
- )
285
- max_equal = (
286
- card1.max || (card1.respond_to?(:max_value) && card1.max_value)
287
- ) == (
288
- card2.max || (card2.respond_to?(:max_value) && card2.max_value)
289
- )
290
-
291
- min_equal && max_equal
265
+ card1.min == card2.min && card1.max == card2.max
292
266
  end
293
267
 
294
268
  # Format cardinality for display
295
269
  def format_cardinality(card)
296
270
  return "nil" if card.nil?
297
271
 
298
- min = card.min || (card.respond_to?(:min_value) && card.min_value)
299
- max = card.max || (card.respond_to?(:max_value) && card.max_value)
300
-
301
- "#{min}..#{max}"
272
+ "\#{card.min}..\#{card.max}"
302
273
  end
303
274
  end
304
275
  end
@@ -6,6 +6,7 @@ module Lutaml
6
6
  attribute :id, :string
7
7
  attribute :type, :string
8
8
  attribute :general, :string
9
+ attribute :parent_object_id, :string
9
10
 
10
11
  yaml do
11
12
  map "id", to: :id
@@ -13,7 +13,6 @@ module Lutaml
13
13
  class Class < Classifier
14
14
  attribute :nested_classifier, :string, collection: true,
15
15
  default: -> { [] }
16
- attribute :is_abstract, :boolean, default: false
17
16
  attribute :stereotype, :string, collection: true, default: -> { [] }
18
17
  attribute :type, :string
19
18
  attribute :attributes, TopElementAttribute, collection: true