unitsml 0.6.1 → 0.6.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc95997f58b3e086c0ef26a0a030d5f7158aac7f2456cf879d33078c40b2dcaf
4
- data.tar.gz: 9a687fa649e8f8ebcf0f42ed0cd29440f69ad64d1799ded6f4267ec2e36c9c96
3
+ metadata.gz: c09381e8f89d514ecb84572e770736fb4f60615e2ab1766dcdb7bb3e6c15d8c7
4
+ data.tar.gz: 1a1ac51b9aafbdd3eb377c437385d07886f965d0907df62bd46ba79f75565a06
5
5
  SHA512:
6
- metadata.gz: 10c82e86eef30472bda3d6e956f00627b523aada12f8dcd58499d7422c0c00e0a36b8c0a047f7093f47a294131425d3fb29699dbe25c345a7ea5f660deb0fb8d
7
- data.tar.gz: 29e5414746513fa0c13e459f4bf72c97b8e4e3246191f6650646443f1a10477929b9733d80d976ff866e58afe40033e4c1087254ba43a0b4a41ae55042bb63fc
6
+ metadata.gz: 53b0e6e3141fdb2a236678a6833f335906ce566c0e9c3652ef4f13959b524090f20f03a17085bc45180a8fcb3e66c09c4fc065d83b8501ec136c2c849d57f0f0
7
+ data.tar.gz: 155deca466acc973546f4b42fe9a7adff098e15b307fea577f136b6274dfd23d291e2f3ba162d50612a9e0b50b5cfc4070a342ff597b6ccb0e98790e99b7cab5
data/.rubocop_todo.yml CHANGED
@@ -1,201 +1,58 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-04-03 23:07:18 UTC using RuboCop version 1.86.0.
3
+ # on 2026-04-15 09:29:09 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: 6
10
- # This cop supports safe autocorrection (--autocorrect).
11
- # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
12
- Bundler/OrderedGems:
13
- Exclude:
14
- - 'Gemfile'
15
-
16
- # Offense count: 1
17
- # This cop supports safe autocorrection (--autocorrect).
18
- Gemspec/RequireMFA:
19
- Exclude:
20
- - 'unitsml.gemspec'
21
-
22
9
  # Offense count: 1
23
10
  Gemspec/RequiredRubyVersion:
24
11
  Exclude:
25
12
  - 'unitsml.gemspec'
26
13
 
27
- # Offense count: 23
14
+ # Offense count: 1
28
15
  # This cop supports safe autocorrection (--autocorrect).
29
16
  # Configuration parameters: EnforcedStyle, IndentationWidth.
30
17
  # SupportedStyles: with_first_argument, with_fixed_indentation
31
18
  Layout/ArgumentAlignment:
32
- Exclude:
33
- - 'lib/unitsml/formula.rb'
34
- - 'lib/unitsml/model/dimension_quantities.rb'
35
- - 'lib/unitsml/model/units/symbol.rb'
36
- - 'lib/unitsml/parse.rb'
37
- - 'lib/unitsml/unit.rb'
38
- - 'lib/unitsml/utility.rb'
39
- - 'spec/unitsml/conv/mathml_spec.rb'
40
- - 'spec/unitsml/conv/plurimath_spec.rb'
41
-
42
- # Offense count: 1
43
- # This cop supports safe autocorrection (--autocorrect).
44
- # Configuration parameters: EnforcedStyle, IndentationWidth.
45
- # SupportedStyles: with_first_element, with_fixed_indentation
46
- Layout/ArrayAlignment:
47
19
  Exclude:
48
20
  - 'lib/unitsml/unit.rb'
49
21
 
50
- # Offense count: 49
51
- # This cop supports safe autocorrection (--autocorrect).
52
- # Configuration parameters: EnforcedStyleAlignWith.
53
- # SupportedStylesAlignWith: either, start_of_block, start_of_line
54
- Layout/BlockAlignment:
55
- Exclude:
56
- - 'lib/unitsml/formula.rb'
57
- - 'lib/unitsml/intermediate_exp_rules.rb'
58
- - 'lib/unitsml/parse.rb'
59
- - 'lib/unitsml/prefix.rb'
60
- - 'lib/unitsml/unitsdb/dimension.rb'
61
- - 'lib/unitsml/utility.rb'
62
- - 'spec/unitsml/conv/html_spec.rb'
63
- - 'spec/unitsml/conv/latex_spec.rb'
64
- - 'spec/unitsml/conv/unicode_spec.rb'
65
- - 'spec/unitsml/parse_spec.rb'
66
- - 'unitsml.gemspec'
67
-
68
- # Offense count: 48
22
+ # Offense count: 76
69
23
  # This cop supports safe autocorrection (--autocorrect).
70
- Layout/BlockEndNewline:
24
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
25
+ # URISchemes: http, https
26
+ Layout/LineLength:
71
27
  Exclude:
28
+ - 'lib/unitsml/fenced.rb'
72
29
  - 'lib/unitsml/formula.rb'
73
30
  - 'lib/unitsml/intermediate_exp_rules.rb'
74
31
  - 'lib/unitsml/parse.rb'
75
- - 'lib/unitsml/prefix.rb'
76
- - 'lib/unitsml/unitsdb/dimension.rb'
32
+ - 'lib/unitsml/parser.rb'
33
+ - 'lib/unitsml/unit.rb'
34
+ - 'lib/unitsml/unitsdb/dimensions.rb'
77
35
  - 'lib/unitsml/utility.rb'
78
36
  - 'spec/unitsml/conv/html_spec.rb'
79
37
  - 'spec/unitsml/conv/latex_spec.rb'
80
- - 'spec/unitsml/conv/unicode_spec.rb'
81
- - 'spec/unitsml/parse_spec.rb'
82
- - 'unitsml.gemspec'
83
-
84
- # Offense count: 2
85
- # This cop supports safe autocorrection (--autocorrect).
86
- Layout/ClosingParenthesisIndentation:
87
- Exclude:
88
- - 'lib/unitsml/parse.rb'
89
- - 'lib/unitsml/utility.rb'
90
-
91
- # Offense count: 2
92
- # This cop supports safe autocorrection (--autocorrect).
93
- # Configuration parameters: AllowForAlignment.
94
- Layout/CommentIndentation:
95
- Exclude:
96
- - 'spec/unitsml/conv/html_spec.rb'
97
-
98
- # Offense count: 2
99
- # This cop supports safe autocorrection (--autocorrect).
100
- Layout/EmptyLines:
101
- Exclude:
102
- - 'spec/unitsml/conv/mathml_spec.rb'
103
- - 'spec/unitsml/conv/xml_spec.rb'
104
-
105
- # Offense count: 2
106
- # This cop supports safe autocorrection (--autocorrect).
107
- # Configuration parameters: EnforcedStyle, IndentationWidth.
108
- # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
109
- Layout/FirstArgumentIndentation:
110
- Exclude:
111
- - 'lib/unitsml/parse.rb'
112
- - 'lib/unitsml/utility.rb'
113
-
114
- # Offense count: 11
115
- # This cop supports safe autocorrection (--autocorrect).
116
- # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
117
- # SupportedHashRocketStyles: key, separator, table
118
- # SupportedColonStyles: key, separator, table
119
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
120
- Layout/HashAlignment:
121
- Exclude:
122
- - 'lib/unitsml/formula.rb'
123
- - 'lib/unitsml/model/units/symbol.rb'
124
- - 'lib/unitsml/utility.rb'
125
38
  - 'spec/unitsml/conv/mathml_spec.rb'
126
-
127
- # Offense count: 7
128
- # This cop supports safe autocorrection (--autocorrect).
129
- # Configuration parameters: EnforcedStyle.
130
- # SupportedStyles: normal, indented_internal_methods
131
- Layout/IndentationConsistency:
132
- Exclude:
133
- - 'spec/unitsml/conv/html_spec.rb'
134
- - 'unitsml.gemspec'
135
-
136
- # Offense count: 97
137
- # This cop supports safe autocorrection (--autocorrect).
138
- # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
139
- # SupportedStylesAlignWith: start_of_line, relative_to_receiver
140
- Layout/IndentationWidth:
141
- Exclude:
142
- - 'lib/unitsml/formula.rb'
143
- - 'lib/unitsml/intermediate_exp_rules.rb'
144
- - 'lib/unitsml/parse.rb'
145
- - 'lib/unitsml/prefix.rb'
146
- - 'lib/unitsml/unitsdb/dimension.rb'
147
- - 'lib/unitsml/utility.rb'
148
- - 'spec/unitsml/conv/html_spec.rb'
149
- - 'spec/unitsml/conv/latex_spec.rb'
39
+ - 'spec/unitsml/conv/plurimath_spec.rb'
150
40
  - 'spec/unitsml/conv/unicode_spec.rb'
151
- - 'spec/unitsml/parse_spec.rb'
41
+ - 'spec/unitsml/conv/xml_spec.rb'
152
42
  - 'unitsml.gemspec'
153
43
 
154
- # Offense count: 148
155
- # This cop supports safe autocorrection (--autocorrect).
156
- # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
157
- # URISchemes: http, https
158
- Layout/LineLength:
159
- Enabled: false
160
-
161
- # Offense count: 2
162
- # This cop supports safe autocorrection (--autocorrect).
163
- # Configuration parameters: EnforcedStyle.
164
- # SupportedStyles: symmetrical, new_line, same_line
165
- Layout/MultilineMethodCallBraceLayout:
166
- Exclude:
167
- - 'lib/unitsml/parse.rb'
168
- - 'lib/unitsml/utility.rb'
169
-
170
- # Offense count: 6
171
- # This cop supports safe autocorrection (--autocorrect).
172
- # Configuration parameters: EnforcedStyle, IndentationWidth.
173
- # SupportedStyles: aligned, indented, indented_relative_to_receiver
174
- Layout/MultilineMethodCallIndentation:
175
- Exclude:
176
- - 'lib/unitsml/utility.rb'
177
-
178
- # Offense count: 23
44
+ # Offense count: 1
179
45
  # This cop supports safe autocorrection (--autocorrect).
180
46
  # Configuration parameters: AllowInHeredoc.
181
47
  Layout/TrailingWhitespace:
182
48
  Exclude:
183
- - 'lib/unitsml/formula.rb'
184
- - 'lib/unitsml/model/dimension_quantities.rb'
185
- - 'lib/unitsml/model/units/symbol.rb'
186
- - 'lib/unitsml/parse.rb'
187
49
  - 'lib/unitsml/unit.rb'
188
- - 'lib/unitsml/utility.rb'
189
- - 'spec/unitsml/conv/mathml_spec.rb'
190
- - 'spec/unitsml/conv/plurimath_spec.rb'
191
50
 
192
- # Offense count: 21
193
- # This cop supports safe autocorrection (--autocorrect).
194
- Lint/AmbiguousOperatorPrecedence:
51
+ # Offense count: 3
52
+ Lint/ReturnInVoidContext:
195
53
  Exclude:
196
- - 'lib/unitsml/intermediate_exp_rules.rb'
197
- - 'lib/unitsml/parse.rb'
198
- - 'lib/unitsml/utility.rb'
54
+ - 'lib/unitsml/unitsdb/si_derived_base.rb'
55
+ - 'lib/unitsml/unitsdb/unit.rb'
199
56
 
200
57
  # Offense count: 19
201
58
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
@@ -249,37 +106,11 @@ Performance/CollectionLiteralInLoop:
249
106
  Exclude:
250
107
  - 'lib/unitsml/parser.rb'
251
108
 
252
- # Offense count: 1
253
- # This cop supports unsafe autocorrection (--autocorrect-all).
254
- Performance/MapCompact:
255
- Exclude:
256
- - 'lib/unitsml/utility.rb'
257
-
258
- # Offense count: 1
259
- # This cop supports safe autocorrection (--autocorrect).
260
- Performance/RedundantMatch:
261
- Exclude:
262
- - 'lib/unitsml/formula.rb'
263
-
264
- # Offense count: 2
265
- # This cop supports safe autocorrection (--autocorrect).
266
- Performance/RegexpMatch:
267
- Exclude:
268
- - 'lib/unitsml/formula.rb'
269
-
270
109
  # Offense count: 1
271
110
  RSpec/AnyInstance:
272
111
  Exclude:
273
112
  - 'spec/unitsml/conv/plurimath_spec.rb'
274
113
 
275
- # Offense count: 1
276
- # This cop supports safe autocorrection (--autocorrect).
277
- # Configuration parameters: EnforcedStyle.
278
- # SupportedStyles: be, be_nil
279
- RSpec/BeNil:
280
- Exclude:
281
- - 'spec/unitsml_spec.rb'
282
-
283
114
  # Offense count: 2
284
115
  RSpec/BeforeAfterAll:
285
116
  Exclude:
@@ -301,41 +132,15 @@ RSpec/ContextWording:
301
132
  - 'spec/unitsml/parse_spec.rb'
302
133
  - 'spec/unitsml/parser_spec.rb'
303
134
 
304
- # Offense count: 26
305
- # This cop supports safe autocorrection (--autocorrect).
306
- RSpec/EmptyLineAfterFinalLet:
307
- Exclude:
308
- - 'spec/unitsml/conv/mathml_spec.rb'
309
-
310
- # Offense count: 3
311
- # This cop supports safe autocorrection (--autocorrect).
312
- RSpec/EmptyLineAfterSubject:
313
- Exclude:
314
- - 'spec/unitsml/conv/mathml_spec.rb'
315
- - 'spec/unitsml/conv/xml_spec.rb'
316
-
317
135
  # Offense count: 5
318
136
  # Configuration parameters: CountAsOne.
319
137
  RSpec/ExampleLength:
320
138
  Max: 7
321
139
 
322
- # Offense count: 4
323
- # This cop supports safe autocorrection (--autocorrect).
324
- RSpec/LeadingSubject:
325
- Exclude:
326
- - 'spec/unitsml/conv/mathml_spec.rb'
327
- - 'spec/unitsml/conv/xml_spec.rb'
328
-
329
140
  # Offense count: 15
330
141
  RSpec/MultipleExpectations:
331
142
  Max: 6
332
143
 
333
- # Offense count: 1
334
- # This cop supports safe autocorrection (--autocorrect).
335
- RSpec/MultipleSubjects:
336
- Exclude:
337
- - 'spec/unitsml/conv/mathml_spec.rb'
338
-
339
144
  # Offense count: 12
340
145
  RSpec/RepeatedExampleGroupBody:
341
146
  Exclude:
@@ -363,38 +168,11 @@ RSpec/SpecFilePathFormat:
363
168
  - 'spec/unitsml/conv/unicode_spec.rb'
364
169
  - 'spec/unitsml/conv/xml_spec.rb'
365
170
 
366
- # Offense count: 83
367
- # This cop supports safe autocorrection (--autocorrect).
368
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
369
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
370
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
371
- # FunctionalMethods: let, let!, subject, watch
372
- # AllowedMethods: lambda, proc, it
373
- Style/BlockDelimiters:
374
- Exclude:
375
- - 'lib/unitsml/formula.rb'
376
- - 'lib/unitsml/intermediate_exp_rules.rb'
377
- - 'lib/unitsml/parse.rb'
378
- - 'lib/unitsml/prefix.rb'
379
- - 'lib/unitsml/unitsdb/dimension.rb'
380
- - 'lib/unitsml/utility.rb'
381
- - 'spec/unitsml/conv/html_spec.rb'
382
- - 'spec/unitsml/conv/latex_spec.rb'
383
- - 'spec/unitsml/conv/unicode_spec.rb'
384
- - 'spec/unitsml/parse_spec.rb'
385
- - 'unitsml.gemspec'
386
-
387
- # Offense count: 2
171
+ # Offense count: 1
388
172
  # This cop supports safe autocorrection (--autocorrect).
389
173
  Style/MultilineIfModifier:
390
174
  Exclude:
391
- - 'lib/unitsml/formula.rb'
392
-
393
- # Offense count: 3
394
- # This cop supports safe autocorrection (--autocorrect).
395
- Style/NegatedIfElseCondition:
396
- Exclude:
397
- - 'lib/unitsml/utility.rb'
175
+ - 'lib/unitsml/unit.rb'
398
176
 
399
177
  # Offense count: 2
400
178
  # Configuration parameters: AllowedMethods.
@@ -404,31 +182,6 @@ Style/OptionalBooleanParameter:
404
182
  - 'lib/unitsml/parser.rb'
405
183
  - 'lib/unitsml/prefix.rb'
406
184
 
407
- # Offense count: 1
408
- # This cop supports unsafe autocorrection (--autocorrect-all).
409
- Style/ReduceToHash:
410
- Exclude:
411
- - 'lib/unitsml/utility.rb'
412
-
413
- # Offense count: 1
414
- # This cop supports unsafe autocorrection (--autocorrect-all).
415
- # Configuration parameters: Methods.
416
- Style/RedundantArgument:
417
- Exclude:
418
- - 'lib/unitsml/utility.rb'
419
-
420
- # Offense count: 6
421
- # This cop supports safe autocorrection (--autocorrect).
422
- Style/RedundantConstantBase:
423
- Exclude:
424
- - 'lib/unitsml.rb'
425
-
426
- # Offense count: 3
427
- # This cop supports safe autocorrection (--autocorrect).
428
- Style/RedundantRegexpArgument:
429
- Exclude:
430
- - 'lib/unitsml/utility.rb'
431
-
432
185
  # Offense count: 2
433
186
  # Configuration parameters: Max.
434
187
  Style/SafeNavigationChainLength:
@@ -442,54 +195,3 @@ Style/SafeNavigationChainLength:
442
195
  Style/StringConcatenation:
443
196
  Exclude:
444
197
  - 'lib/unitsml/utility.rb'
445
-
446
- # Offense count: 2141
447
- # This cop supports safe autocorrection (--autocorrect).
448
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
449
- # SupportedStyles: single_quotes, double_quotes
450
- Style/StringLiterals:
451
- Enabled: false
452
-
453
- # Offense count: 258
454
- # This cop supports safe autocorrection (--autocorrect).
455
- # Configuration parameters: EnforcedStyleForMultiline.
456
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
457
- Style/TrailingCommaInArguments:
458
- Exclude:
459
- - 'lib/unitsml.rb'
460
- - 'lib/unitsml/dimension.rb'
461
- - 'lib/unitsml/number.rb'
462
- - 'lib/unitsml/parser.rb'
463
- - 'lib/unitsml/prefix.rb'
464
- - 'lib/unitsml/transform.rb'
465
- - 'lib/unitsml/unit.rb'
466
- - 'lib/unitsml/utility.rb'
467
- - 'spec/unitsml/conv/asciimath_spec.rb'
468
- - 'spec/unitsml/conv/html_spec.rb'
469
- - 'spec/unitsml/conv/latex_spec.rb'
470
- - 'spec/unitsml/conv/plurimath_spec.rb'
471
- - 'spec/unitsml/parser_spec.rb'
472
-
473
- # Offense count: 154
474
- # This cop supports safe autocorrection (--autocorrect).
475
- # Configuration parameters: EnforcedStyleForMultiline.
476
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
477
- Style/TrailingCommaInArrayLiteral:
478
- Exclude:
479
- - 'lib/unitsml.rb'
480
- - 'lib/unitsml/formula.rb'
481
- - 'lib/unitsml/transform.rb'
482
- - 'spec/unitsml/conv/plurimath_spec.rb'
483
- - 'spec/unitsml/parser_spec.rb'
484
-
485
- # Offense count: 11
486
- # This cop supports safe autocorrection (--autocorrect).
487
- # Configuration parameters: EnforcedStyleForMultiline.
488
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
489
- Style/TrailingCommaInHashLiteral:
490
- Exclude:
491
- - 'lib/unitsml.rb'
492
- - 'lib/unitsml/dimension.rb'
493
- - 'lib/unitsml/extender.rb'
494
- - 'lib/unitsml/number.rb'
495
- - 'lib/unitsml/utility.rb'
data/Gemfile CHANGED
@@ -5,10 +5,8 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in unitsml.gemspec
6
6
  gemspec
7
7
 
8
- gem "lutaml-model", "~> 0.8.0", github: "lutaml/lutaml-model", branch: "main"
9
-
10
8
  gem "canon"
11
- gem "mml", github: "plurimath/mml", branch: "main"
9
+ gem "lutaml-model", "~> 0.8.0", github: "lutaml/lutaml-model", branch: "main"
12
10
  gem "oga"
13
11
  gem "ox"
14
12
  gem "plurimath", github: "plurimath/plurimath", branch: "rt-lutaml-080"
@@ -16,5 +14,7 @@ gem "pry"
16
14
  gem "rake"
17
15
  gem "rspec"
18
16
  gem "rubocop"
17
+ gem "rubocop-performance"
18
+ gem "rubocop-rake"
19
+ gem "rubocop-rspec"
19
20
  gem "simplecov"
20
- gem "unitsdb", github: "unitsml/unitsdb-ruby", branch: "rt-lutaml-080-compat"
@@ -196,10 +196,14 @@ module Unitsml
196
196
  end
197
197
 
198
198
  def nullify_mml_models
199
+ return unless defined?(Plurimath::Mathml::Parser::CONFIGURATION)
200
+
199
201
  Plurimath::Mathml::Parser::CONFIGURATION.each_key { |klass| klass.model(klass) }
200
202
  end
201
203
 
202
204
  def reset_mml_models
205
+ return unless defined?(Plurimath::Mathml::Parser::CONFIGURATION)
206
+
203
207
  ::Mml::V4::Configuration.custom_models = Plurimath::Mathml::Parser::CONFIGURATION
204
208
  end
205
209
 
data/lib/unitsml/unit.rb CHANGED
@@ -35,10 +35,14 @@ module Unitsml
35
35
  end
36
36
 
37
37
  def to_mathml(options)
38
- value = unit_symbols&.mathml
39
- tag_name = value.match(/^<(?<tag>\w+)/)[:tag]
40
- value = ::Mml::V4.const_get(tag_name.capitalize).from_xml(value)
41
- value.value = "#{prefix.to_mathml(options)}#{value.value}" if prefix
38
+ raw_mathml = unit_symbols&.mathml
39
+ tag_name = raw_mathml.match(/^<(?<tag>\w+)/)[:tag]
40
+ klass = ::Mml::V4.const_get(tag_name.capitalize)
41
+ value = klass.from_xml(raw_mathml)
42
+ if prefix
43
+ value = with_updated_value(value,
44
+ "#{prefix.to_mathml(options)}#{value.value}")
45
+ end
42
46
  if power_numerator
43
47
  value = msup_tag(
44
48
  { method_name: tag_name, value: value },
@@ -126,6 +130,15 @@ module Unitsml
126
130
  unit_instance.unit_system_reference
127
131
  end
128
132
 
133
+ def with_updated_value(element, new_value)
134
+ attrs = element.class.attributes.each_with_object({}) do |(name, _), h|
135
+ val = element.public_send(name)
136
+ h[name] = val unless val.nil?
137
+ end
138
+ attrs[:value] = new_value
139
+ element.class.new(**attrs)
140
+ end
141
+
129
142
  def msup_tag(value, options)
130
143
  msup = ::Mml::V4::Msup.new
131
144
  msup.ordered = true
@@ -16,35 +16,37 @@ module Unitsml
16
16
  end
17
17
 
18
18
  def length=(value)
19
- quantities_common_code(:length, value)
19
+ quantities_common_code(:length, wrap_dimension_value(value))
20
20
  end
21
21
 
22
22
  def mass=(value)
23
- quantities_common_code(:mass, value)
23
+ quantities_common_code(:mass, wrap_dimension_value(value))
24
24
  end
25
25
 
26
26
  def time=(value)
27
- quantities_common_code(:time, value)
27
+ quantities_common_code(:time, wrap_dimension_value(value))
28
28
  end
29
29
 
30
30
  def thermodynamic_temperature=(value)
31
- quantities_common_code(:thermodynamic_temperature, value)
31
+ quantities_common_code(:thermodynamic_temperature,
32
+ wrap_dimension_value(value))
32
33
  end
33
34
 
34
35
  def amount_of_substance=(value)
35
- quantities_common_code(:amount_of_substance, value)
36
+ quantities_common_code(:amount_of_substance,
37
+ wrap_dimension_value(value))
36
38
  end
37
39
 
38
40
  def luminous_intensity=(value)
39
- quantities_common_code(:luminous_intensity, value)
41
+ quantities_common_code(:luminous_intensity, wrap_dimension_value(value))
40
42
  end
41
43
 
42
44
  def plane_angle=(value)
43
- quantities_common_code(:plane_angle, value)
45
+ quantities_common_code(:plane_angle, wrap_dimension_value(value))
44
46
  end
45
47
 
46
48
  def electric_current=(value)
47
- quantities_common_code(:electric_current, value)
49
+ quantities_common_code(:electric_current, wrap_dimension_value(value))
48
50
  end
49
51
 
50
52
  def dim_symbols
@@ -79,6 +81,14 @@ module Unitsml
79
81
  @parsable = true
80
82
  value.dim_symbols_ids(@parsables, id)
81
83
  end
84
+
85
+ def wrap_dimension_value(value)
86
+ return value if value.is_a?(DimensionQuantity)
87
+ return DimensionQuantity.new(value.to_hash) if value.is_a?(::Unitsdb::DimensionDetails)
88
+ return DimensionQuantity.new(value) if value.is_a?(Hash)
89
+
90
+ value
91
+ end
82
92
  end
83
93
  end
84
94
  end
@@ -16,7 +16,9 @@ module Unitsml
16
16
  end
17
17
 
18
18
  def prefix
19
- @prefix ||= Unitsdb.prefixes.find_by_id(id)
19
+ @prefix ||= ::Unitsdb.database.prefixes.find do |p|
20
+ p.identifiers.any? { |i| i.id == id }
21
+ end
20
22
  end
21
23
  end
22
24
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsml
4
+ module Unitsdb
5
+ class SiDerivedBase < ::Unitsdb::SiDerivedBase
6
+ def prefix_reference=(value)
7
+ return super if value.nil?
8
+ return super if value.is_a?(PrefixReference)
9
+
10
+ super(PrefixReference.new(value.to_hash))
11
+ end
12
+ end
13
+ end
14
+ end
@@ -3,9 +3,17 @@
3
3
  module Unitsml
4
4
  module Unitsdb
5
5
  class Unit < ::Unitsdb::Unit
6
+ def si_derived_bases=(value)
7
+ return super if value.nil?
8
+
9
+ super(value.map do |s|
10
+ SiDerivedBase.new(s.to_hash)
11
+ end)
12
+ end
13
+
6
14
  def dimension_url
7
15
  quantity_id = quantity_references[0].id
8
- quantity = Unitsdb.quantities.find_by_id(quantity_id)
16
+ quantity = Unitsml::Unitsdb.quantities.find_by_id(quantity_id)
9
17
  quantity.dimension_reference.id
10
18
  end
11
19
 
@@ -10,6 +10,7 @@ module Unitsml
10
10
  autoload :Quantities, "#{__dir__}/unitsdb/quantities"
11
11
  autoload :PrefixReference, "#{__dir__}/unitsdb/prefix_reference"
12
12
  autoload :DimensionQuantity, "#{__dir__}/unitsdb/dimension_quantity"
13
+ autoload :SiDerivedBase, "#{__dir__}/unitsdb/si_derived_base"
13
14
 
14
15
  class << self
15
16
  def units
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Unitsml
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.3"
5
5
  end
data/unitsml.gemspec CHANGED
@@ -30,11 +30,11 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.bindir = "exe"
32
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
- spec.require_paths = ["lib", "unitsdb/**/*.yaml"]
33
+ spec.require_paths = ["lib"]
34
34
 
35
35
  spec.add_dependency "htmlentities"
36
36
  spec.add_dependency "lutaml-model", "~> 0.8.0"
37
- spec.add_dependency "mml"
37
+ spec.add_dependency "mml", "~> 2.3.2"
38
38
  spec.add_dependency "parslet"
39
39
  spec.add_dependency "unitsdb", "~> 2.2.1"
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unitsml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-04 00:00:00.000000000 Z
11
+ date: 2026-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: mml
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.3.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.3.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: parslet
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +155,7 @@ files:
155
155
  - lib/unitsml/unitsdb/prefix_reference.rb
156
156
  - lib/unitsml/unitsdb/prefixes.rb
157
157
  - lib/unitsml/unitsdb/quantities.rb
158
+ - lib/unitsml/unitsdb/si_derived_base.rb
158
159
  - lib/unitsml/unitsdb/unit.rb
159
160
  - lib/unitsml/unitsdb/units.rb
160
161
  - lib/unitsml/utility.rb
@@ -170,7 +171,6 @@ post_install_message:
170
171
  rdoc_options: []
171
172
  require_paths:
172
173
  - lib
173
- - unitsdb/**/*.yaml
174
174
  required_ruby_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - ">="