xmi 0.3.21 → 0.5.1

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +13 -6
  3. data/.gitignore +2 -1
  4. data/.rubocop.yml +12 -13
  5. data/.rubocop_todo.yml +265 -12
  6. data/CHANGELOG.md +55 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +12 -0
  9. data/README.adoc +319 -6
  10. data/Rakefile +2 -0
  11. data/docs/migration.md +141 -0
  12. data/docs/versioning.md +255 -0
  13. data/lib/tasks/benchmark_runner.rb +274 -0
  14. data/lib/tasks/performance.rake +46 -0
  15. data/lib/tasks/performance_comparator.rb +88 -0
  16. data/lib/tasks/performance_helpers.rb +238 -0
  17. data/lib/xmi/add.rb +14 -38
  18. data/lib/xmi/{the_custom_profile.rb → custom_profile.rb} +25 -25
  19. data/lib/xmi/delete.rb +14 -38
  20. data/lib/xmi/difference.rb +14 -38
  21. data/lib/xmi/documentation.rb +16 -101
  22. data/lib/xmi/ea_root.rb +114 -33
  23. data/lib/xmi/extension.rb +6 -6
  24. data/lib/xmi/namespace/dynamic.rb +28 -0
  25. data/lib/xmi/namespace/omg.rb +81 -0
  26. data/lib/xmi/namespace/sparx.rb +39 -0
  27. data/lib/xmi/namespace.rb +9 -0
  28. data/lib/xmi/namespace_detector.rb +138 -0
  29. data/lib/xmi/namespace_registry.rb +119 -0
  30. data/lib/xmi/parsing.rb +116 -0
  31. data/lib/xmi/replace.rb +14 -38
  32. data/lib/xmi/root.rb +49 -213
  33. data/lib/xmi/sparx/connector.rb +241 -0
  34. data/lib/xmi/sparx/custom_profile.rb +19 -0
  35. data/lib/xmi/sparx/diagram.rb +97 -0
  36. data/lib/xmi/sparx/ea_stub.rb +20 -0
  37. data/lib/xmi/{extensions/eauml.rb → sparx/ea_uml.rb} +3 -2
  38. data/lib/xmi/sparx/element.rb +453 -0
  39. data/lib/xmi/sparx/extension.rb +43 -0
  40. data/lib/xmi/{extensions → sparx}/gml.rb +9 -3
  41. data/lib/xmi/sparx/mappings/base_mapping.rb +182 -0
  42. data/lib/xmi/sparx/mappings.rb +10 -0
  43. data/lib/xmi/sparx/primitive_type.rb +18 -0
  44. data/lib/xmi/sparx/root.rb +60 -0
  45. data/lib/xmi/sparx/sys_ph_s.rb +18 -0
  46. data/lib/xmi/sparx.rb +17 -1376
  47. data/lib/xmi/type.rb +37 -0
  48. data/lib/xmi/uml.rb +191 -469
  49. data/lib/xmi/v20110701.rb +81 -0
  50. data/lib/xmi/v20131001.rb +68 -0
  51. data/lib/xmi/v20161101.rb +61 -0
  52. data/lib/xmi/version.rb +1 -1
  53. data/lib/xmi/version_registry.rb +167 -0
  54. data/lib/xmi/versioned.rb +145 -0
  55. data/lib/xmi.rb +83 -11
  56. data/xmi.gemspec +3 -9
  57. metadata +40 -77
@@ -0,0 +1,238 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "open3"
5
+ require "tmpdir"
6
+ require "fileutils"
7
+
8
+ module PerformanceHelpers
9
+ # ANSI color codes for terminal output
10
+ CLEAR = "\e[0m"
11
+ BOLD = "\e[1m"
12
+ DIM = "\e[2m"
13
+ CYAN = "\e[36m"
14
+ GREEN = "\e[32m"
15
+ YELLOW = "\e[33m"
16
+ RED = "\e[31m"
17
+ GRAY = "\e[90m"
18
+ MAGENTA = "\e[35m"
19
+
20
+ # Terminal formatting helpers
21
+ module Term
22
+ extend self
23
+
24
+ HL = "─"
25
+ VL = "│"
26
+ TL = "┌"
27
+ TR = "┐"
28
+ BL = "└"
29
+ BR = "┘"
30
+
31
+ def header(title, color: PerformanceHelpers::CYAN)
32
+ width = 78
33
+ line = HL * width
34
+ puts
35
+ puts "#{color}#{TL}#{line}#{TR}#{CLEAR}"
36
+ puts "#{color}#{VL}#{CLEAR} #{BOLD}#{color}#{title}#{CLEAR}#{' ' * (width - title.length - 4)}#{color}#{VL}#{CLEAR}"
37
+ puts "#{color}#{BL}#{line}#{BR}#{CLEAR}"
38
+ end
39
+
40
+ def sep(char: HL, width: 78)
41
+ puts "#{DIM}#{char * width}#{CLEAR}"
42
+ end
43
+ end
44
+
45
+ module Base
46
+ end
47
+
48
+ module Current
49
+ end
50
+
51
+ class << self
52
+ def load_into_namespace(module_obj, file_path)
53
+ content = File.read(file_path)
54
+ module_obj.module_eval(content, file_path)
55
+ end
56
+
57
+ def ruby_exec(cmd, env: {})
58
+ Open3.capture3(env, cmd)
59
+ end
60
+
61
+ def current_branch
62
+ stdout, = ruby_exec("git rev-parse --abbrev-ref HEAD")
63
+ stdout.strip
64
+ end
65
+
66
+ # Clone base branch into a temp dir and return its path
67
+ def clone_base_repo(base, performance_dir, script)
68
+ puts "#{DIM}Cloning base #{base}...#{CLEAR}"
69
+ safe_ref = base.gsub(/[^0-9A-Za-z._-]/, "-")
70
+ clone_dir = File.join(performance_dir, "base-#{safe_ref}")
71
+ FileUtils.rm_rf(clone_dir)
72
+
73
+ repo_url, = ruby_exec("git config --get remote.origin.url")
74
+ repo_url = repo_url.strip
75
+
76
+ stdout, stderr, status = ruby_exec("git clone --branch #{safe_ref} --single-branch #{repo_url} #{clone_dir}")
77
+ raise "git clone failed: #{stderr}\n#{stdout}" unless status.success?
78
+
79
+ Dir.chdir(clone_dir) do
80
+ stdout, stderr, status = ruby_exec("bundle install --quiet")
81
+ raise "bundle install failed: #{stderr}\n#{stdout}" unless status.success?
82
+
83
+ bench_copy_dir = File.join(clone_dir, "lib", "tasks")
84
+ FileUtils.mkdir_p(bench_copy_dir)
85
+ bench_copy = File.join(bench_copy_dir, "benchmark_runner.rb")
86
+ File.write(bench_copy, File.read(script))
87
+ load_into_namespace(Base, bench_copy)
88
+ end
89
+ end
90
+
91
+ def run_benchmarks(base_runner, current_runner, threshold, all_base,
92
+ all_current)
93
+ base_results = base_runner.run_benchmarks
94
+ curr_results = current_runner.run_benchmarks
95
+
96
+ all_base.merge!(base_results)
97
+ all_current.merge!(curr_results)
98
+
99
+ # Collect comparison results
100
+ comparison_rows = []
101
+
102
+ curr_results.each do |label, result|
103
+ base_result = base_results[label]
104
+ cmp = compare_metrics(label, result, base_result, threshold)
105
+ comparison_rows << cmp
106
+ end
107
+
108
+ print_comparison_table(comparison_rows, threshold)
109
+ end
110
+
111
+ def print_comparison_table(comparison_rows, threshold)
112
+ rows = comparison_rows.map do |cmp|
113
+ {
114
+ benchmark: cmp[:label],
115
+ base_ips: cmp[:base_ips]&.round(1),
116
+ curr_ips: cmp[:curr_ips]&.round(1),
117
+ change: cmp[:change] ? "#{(cmp[:change] * 100).round(1)}%" : "N/A",
118
+ status: if cmp[:base_ips].nil?
119
+ "NEW"
120
+ elsif cmp[:change] < -threshold
121
+ "REGRESSED"
122
+ else
123
+ "OK"
124
+ end,
125
+ }
126
+ end
127
+
128
+ return if rows.empty?
129
+
130
+ puts " #{'Benchmark'.ljust(40)} #{'Base IPS'.rjust(12)} #{'Curr IPS'.rjust(12)} #{'Change'.rjust(10)} #{'Status'.rjust(10)}"
131
+ puts " #{DIM}#{'─' * 86}#{CLEAR}"
132
+
133
+ rows.each do |row|
134
+ status_color = case row[:status]
135
+ when "REGRESSED" then RED
136
+ when "NEW" then YELLOW
137
+ else GREEN
138
+ end
139
+ row[:status] == "REGRESSED" ? RED : DIM
140
+
141
+ puts " #{row[:benchmark].ljust(40)} #{format('%-12.1f',
142
+ row[:base_ips] || 0)} #{format('%-12.1f',
143
+ row[:curr_ips] || 0)} #{format('%-10s', row[:change]).gsub('%',
144
+ '%%')} #{status_color}#{row[:status].rjust(10)}#{CLEAR}"
145
+ end
146
+
147
+ puts
148
+ end
149
+
150
+ def compare_metrics(label, curr, base, threshold)
151
+ unless base
152
+ return { label: label, base_ips: nil, curr_ips: nil, change: nil,
153
+ regressed: false }
154
+ end
155
+
156
+ base_ips = base.fetch(:lower)
157
+ curr_ips = curr.fetch(:upper)
158
+ change = (curr_ips - base_ips) / base_ips.to_f
159
+
160
+ {
161
+ label: label,
162
+ base_ips: base_ips,
163
+ curr_ips: curr_ips,
164
+ change: change,
165
+ regressed: change < -threshold,
166
+ }
167
+ end
168
+
169
+ def summary_report(current_results, base_results, base, run_time, threshold)
170
+ summary = {
171
+ run_time: run_time,
172
+ threshold: threshold,
173
+ branch: current_branch,
174
+ base: base,
175
+ regressions: [],
176
+ new_benchmarks: [],
177
+ }
178
+
179
+ current_results.each do |label, metrics|
180
+ base_result = base_results[label]
181
+ cmp = compare_metrics(label, metrics, base_result, threshold)
182
+
183
+ # Track new benchmarks that don't exist in base
184
+ if base_result.nil?
185
+ summary[:new_benchmarks] << label
186
+ next
187
+ end
188
+
189
+ next unless cmp[:regressed]
190
+
191
+ summary[:regressions] << {
192
+ label: label,
193
+ base_ips: cmp[:base_ips],
194
+ curr_ips: cmp[:curr_ips],
195
+ delta_fraction: cmp[:change],
196
+ }
197
+ end
198
+
199
+ log_regressions(summary[:regressions], threshold)
200
+ log_new_benchmarks(summary[:new_benchmarks])
201
+ summary
202
+ end
203
+
204
+ def log_new_benchmarks(new_benchmarks)
205
+ return if new_benchmarks.empty?
206
+
207
+ puts
208
+ puts "#{YELLOW}🆕 New benchmarks (not in base branch):#{CLEAR}"
209
+ new_benchmarks.each do |label|
210
+ puts " • #{label}"
211
+ end
212
+ end
213
+
214
+ def log_regressions(regressions, threshold)
215
+ return if regressions.empty?
216
+
217
+ puts
218
+ puts "#{RED}⚠️ Performance Regressions Detected#{CLEAR}"
219
+ puts "#{RED} (< -#{(threshold * 100).round(2)}% IPS)#{CLEAR}"
220
+ puts
221
+ regressions.each do |regression|
222
+ delta = regression[:delta_fraction]
223
+ base_ips = regression[:base_ips]
224
+ curr_ips = regression[:curr_ips]
225
+
226
+ delta_str = delta ? format("%+0.2f%%", delta * 100) : "N/A"
227
+ base_str = base_ips ? format("%.2f", base_ips) : "N/A"
228
+ curr_str = curr_ips ? format("%.2f", curr_ips) : "N/A"
229
+
230
+ puts " #{BOLD}#{regression[:label]}#{CLEAR}"
231
+ puts " #{GRAY}base: #{base_str} IPS#{CLEAR}"
232
+ puts " #{RED}curr: #{curr_str} IPS#{CLEAR}"
233
+ puts " #{RED}change: #{delta_str}#{CLEAR}"
234
+ puts
235
+ end
236
+ end
237
+ end
238
+ end
data/lib/xmi/add.rb CHANGED
@@ -5,12 +5,12 @@ require_relative "extension"
5
5
 
6
6
  module Xmi
7
7
  class Add < Lutaml::Model::Serializable
8
- attribute :id, :string
9
- attribute :label, :string
10
- attribute :uuid, :string
8
+ attribute :id, ::Xmi::Type::XmiId
9
+ attribute :label, ::Xmi::Type::XmiLabel
10
+ attribute :uuid, ::Xmi::Type::XmiUuid
11
11
  attribute :href, :string
12
- attribute :idref, :string
13
- attribute :type, :string
12
+ attribute :idref, ::Xmi::Type::XmiIdRef
13
+ attribute :type, ::Xmi::Type::XmiType
14
14
  attribute :target, :string
15
15
  attribute :container, :string
16
16
  attribute :position, :integer
@@ -18,46 +18,22 @@ module Xmi
18
18
  attribute :difference, Difference, collection: true
19
19
  attribute :extension, Extension, collection: true
20
20
 
21
- xml do # rubocop:disable Metrics/BlockLength
21
+ xml do
22
22
  root "Add"
23
- namespace "http://www.omg.org/spec/XMI/20131001", "xmlns"
23
+ namespace ::Xmi::Namespace::Omg::Xmi
24
24
 
25
- map_attribute "id", to: :id, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
26
- map_attribute "label", to: :label, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
27
- map_attribute "uuid", to: :uuid, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
25
+ map_attribute "id", to: :id
26
+ map_attribute "label", to: :label
27
+ map_attribute "uuid", to: :uuid
28
28
  map_attribute "href", to: :href
29
- map_attribute "idref", to: :idref, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
30
- map_attribute "type", to: :type, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
29
+ map_attribute "idref", to: :idref
30
+ map_attribute "type", to: :type
31
31
  map_attribute "target", to: :target
32
32
  map_attribute "container", to: :container
33
33
  map_attribute "position", to: :position
34
34
  map_attribute "addition", to: :addition
35
- map_element "difference", to: :difference, prefix: nil, namespace: nil,
36
- value_map: {
37
- from: {
38
- nil: :empty,
39
- empty: :empty,
40
- omitted: :empty
41
- },
42
- to: {
43
- nil: :empty,
44
- empty: :empty,
45
- omitted: :empty
46
- }
47
- }
48
- map_element "Extension", to: :extension,
49
- value_map: {
50
- from: {
51
- nil: :empty,
52
- empty: :empty,
53
- omitted: :empty
54
- },
55
- to: {
56
- nil: :empty,
57
- empty: :empty,
58
- omitted: :empty
59
- }
60
- }
35
+ map_element "difference", to: :difference, value_map: VALUE_MAP
36
+ map_element "Extension", to: :extension, value_map: VALUE_MAP
61
37
  end
62
38
  end
63
39
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xmi
4
- module TheCustomProfile
4
+ module CustomProfile
5
5
  class Bibliography < Lutaml::Model::Serializable
6
6
  attribute :base_class, :string
7
7
 
8
8
  xml do
9
- root "Bibliography"
10
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
9
+ element "Bibliography"
10
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
11
11
 
12
12
  map_attribute "base_Class", to: :base_class
13
13
  end
@@ -17,8 +17,8 @@ module Xmi
17
17
  attribute :base_class, :string
18
18
 
19
19
  xml do
20
- root "BasicDoc"
21
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
20
+ element "BasicDoc"
21
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
22
22
 
23
23
  map_attribute "base_Class", to: :base_class
24
24
  end
@@ -28,8 +28,8 @@ module Xmi
28
28
  attribute :base_enumeration, :string
29
29
 
30
30
  xml do
31
- root "enumeration"
32
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
31
+ element "enumeration"
32
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
33
33
 
34
34
  map_attribute "base_Enumeration", to: :base_enumeration
35
35
  end
@@ -39,8 +39,8 @@ module Xmi
39
39
  attribute :base_constraint, :string
40
40
 
41
41
  xml do
42
- root "OCL"
43
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
42
+ element "OCL"
43
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
44
44
 
45
45
  map_attribute "base_Constraint", to: :base_constraint
46
46
  end
@@ -50,8 +50,8 @@ module Xmi
50
50
  attribute :base_constraint, :string
51
51
 
52
52
  xml do
53
- root "invariant"
54
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
53
+ element "invariant"
54
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
55
55
 
56
56
  map_attribute "base_Constraint", to: :base_constraint
57
57
  end
@@ -62,8 +62,8 @@ module Xmi
62
62
  attribute :publication_date, :string
63
63
 
64
64
  xml do
65
- root "publicationDate"
66
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
65
+ element "publicationDate"
66
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
67
67
 
68
68
  map_attribute "base_Package", to: :base_package
69
69
  map_attribute "publicationDate", to: :publication_date
@@ -75,8 +75,8 @@ module Xmi
75
75
  attribute :edition, :string
76
76
 
77
77
  xml do
78
- root "edition"
79
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
78
+ element "edition"
79
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
80
80
 
81
81
  map_attribute "base_Package", to: :base_package
82
82
  map_attribute "edition", to: :edition
@@ -88,8 +88,8 @@ module Xmi
88
88
  attribute :number, :string
89
89
 
90
90
  xml do
91
- root "number"
92
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
91
+ element "number"
92
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
93
93
 
94
94
  map_attribute "base_Package", to: :base_package
95
95
  map_attribute "number", to: :number
@@ -101,8 +101,8 @@ module Xmi
101
101
  attribute :year_version, :string
102
102
 
103
103
  xml do
104
- root "yearVersion"
105
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
104
+ element "yearVersion"
105
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
106
106
 
107
107
  map_attribute "base_Package", to: :base_package
108
108
  map_attribute "yearVersion", to: :year_version
@@ -113,8 +113,8 @@ module Xmi
113
113
  attribute :base_package, :string
114
114
 
115
115
  xml do
116
- root "informative"
117
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
116
+ element "informative"
117
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
118
118
 
119
119
  map_attribute "base_Package", to: :base_package
120
120
  end
@@ -126,8 +126,8 @@ module Xmi
126
126
  attribute :persistence, :string
127
127
 
128
128
  xml do
129
- root "persistence"
130
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
129
+ element "persistence"
130
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
131
131
 
132
132
  map_attribute "base_Class", to: :base_class
133
133
  map_attribute "base_Enumeration", to: :base_enumeration
@@ -139,8 +139,8 @@ module Xmi
139
139
  attribute :base_class, :string
140
140
 
141
141
  xml do
142
- root "Abstract"
143
- namespace "http://www.sparxsystems.com/profiles/thecustomprofile/1.0", "thecustomprofile"
142
+ element "Abstract"
143
+ namespace ::Xmi::Namespace::Sparx::CustomProfile
144
144
 
145
145
  map_attribute "base_Class", to: :base_class
146
146
  end
data/lib/xmi/delete.rb CHANGED
@@ -5,55 +5,31 @@ require_relative "extension"
5
5
 
6
6
  module Xmi
7
7
  class Delete < Lutaml::Model::Serializable
8
- attribute :id, :string
9
- attribute :label, :string
10
- attribute :uuid, :string
8
+ attribute :id, ::Xmi::Type::XmiId
9
+ attribute :label, ::Xmi::Type::XmiLabel
10
+ attribute :uuid, ::Xmi::Type::XmiUuid
11
11
  attribute :href, :string
12
- attribute :idref, :string
13
- attribute :type, :string
12
+ attribute :idref, ::Xmi::Type::XmiIdRef
13
+ attribute :type, ::Xmi::Type::XmiType
14
14
  attribute :target, :string
15
15
  attribute :container, :string
16
16
  attribute :difference, Difference, collection: true
17
17
  attribute :extension, Extension, collection: true
18
18
 
19
- xml do # rubocop:disable Metrics/BlockLength
19
+ xml do
20
20
  root "Delete"
21
- namespace "http://www.omg.org/spec/XMI/20131001", "xmlns"
21
+ namespace ::Xmi::Namespace::Omg::Xmi
22
22
 
23
- map_attribute "id", to: :id, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
24
- map_attribute "label", to: :label, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
25
- map_attribute "uuid", to: :uuid, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
23
+ map_attribute "id", to: :id
24
+ map_attribute "label", to: :label
25
+ map_attribute "uuid", to: :uuid
26
26
  map_attribute "href", to: :href
27
- map_attribute "idref", to: :idref, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
28
- map_attribute "type", to: :type, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
27
+ map_attribute "idref", to: :idref
28
+ map_attribute "type", to: :type
29
29
  map_attribute "target", to: :target
30
30
  map_attribute "container", to: :container
31
- map_element "difference", to: :difference, prefix: nil, namespace: nil,
32
- value_map: {
33
- from: {
34
- nil: :empty,
35
- empty: :empty,
36
- omitted: :empty
37
- },
38
- to: {
39
- nil: :empty,
40
- empty: :empty,
41
- omitted: :empty
42
- }
43
- }
44
- map_element "Extension", to: :extension,
45
- value_map: {
46
- from: {
47
- nil: :empty,
48
- empty: :empty,
49
- omitted: :empty
50
- },
51
- to: {
52
- nil: :empty,
53
- empty: :empty,
54
- omitted: :empty
55
- }
56
- }
31
+ map_element "difference", to: :difference, value_map: VALUE_MAP
32
+ map_element "Extension", to: :extension, value_map: VALUE_MAP
57
33
  end
58
34
  end
59
35
  end
@@ -4,55 +4,31 @@ require_relative "extension"
4
4
 
5
5
  module Xmi
6
6
  class Difference < Lutaml::Model::Serializable
7
- attribute :id, :string
8
- attribute :label, :string
9
- attribute :uuid, :string
7
+ attribute :id, ::Xmi::Type::XmiId
8
+ attribute :label, ::Xmi::Type::XmiLabel
9
+ attribute :uuid, ::Xmi::Type::XmiUuid
10
10
  attribute :href, :string
11
- attribute :idref, :string
12
- attribute :type, :string
11
+ attribute :idref, ::Xmi::Type::XmiIdRef
12
+ attribute :type, ::Xmi::Type::XmiType
13
13
  attribute :target, :string
14
14
  attribute :container, :string
15
15
  attribute :difference, Difference, collection: true
16
16
  attribute :extension, Extension, collection: true
17
17
 
18
- xml do # rubocop:disable Metrics/BlockLength
18
+ xml do
19
19
  root "Difference"
20
- namespace "http://www.omg.org/spec/XMI/20131001", "xmlns"
20
+ namespace ::Xmi::Namespace::Omg::Xmi
21
21
 
22
- map_attribute "id", to: :id, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
23
- map_attribute "label", to: :label, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
24
- map_attribute "uuid", to: :uuid, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
22
+ map_attribute "id", to: :id
23
+ map_attribute "label", to: :label
24
+ map_attribute "uuid", to: :uuid
25
25
  map_attribute "href", to: :href
26
- map_attribute "idref", to: :idref, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
27
- map_attribute "type", to: :type, prefix: "xmlns", namespace: "http://www.omg.org/spec/XMI/20131001"
26
+ map_attribute "idref", to: :idref
27
+ map_attribute "type", to: :type
28
28
  map_attribute "target", to: :target
29
29
  map_attribute "container", to: :container
30
- map_element "difference", to: :difference, prefix: nil, namespace: nil,
31
- value_map: {
32
- from: {
33
- nil: :empty,
34
- empty: :empty,
35
- omitted: :empty
36
- },
37
- to: {
38
- nil: :empty,
39
- empty: :empty,
40
- omitted: :empty
41
- }
42
- }
43
- map_element "Extension", to: :extension,
44
- value_map: {
45
- from: {
46
- nil: :empty,
47
- empty: :empty,
48
- omitted: :empty
49
- },
50
- to: {
51
- nil: :empty,
52
- empty: :empty,
53
- omitted: :empty
54
- }
55
- }
30
+ map_element "difference", to: :difference, value_map: VALUE_MAP
31
+ map_element "Extension", to: :extension, value_map: VALUE_MAP
56
32
  end
57
33
  end
58
34
  end