unitsml 0.6.2 → 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: 519edb3bcbb3adee7983969d11be6a300340d782e8e305dae7622633b86e7677
4
- data.tar.gz: 68becf0180daf138fc4f38048f052debef3d82433f4806d0f631c0c14e6ea852
3
+ metadata.gz: c09381e8f89d514ecb84572e770736fb4f60615e2ab1766dcdb7bb3e6c15d8c7
4
+ data.tar.gz: 1a1ac51b9aafbdd3eb377c437385d07886f965d0907df62bd46ba79f75565a06
5
5
  SHA512:
6
- metadata.gz: b6cb0077f5037893a02e69e6ff6c4b8a7c75ae3e67615897a4ccee3966349121bdaa1d8a8b244c42b6e9ba59898c6b2243a4c911239a54fd7f254a360208154a
7
- data.tar.gz: 3fa4b5a9542487d7e502a18a22eca293664dc44b556cd9acca4e1bf589f6cd4d88daa9448b2ac18f37a678de4d63646e8f558ac128192d188a46efc56d5d27c6
6
+ metadata.gz: 53b0e6e3141fdb2a236678a6833f335906ce566c0e9c3652ef4f13959b524090f20f03a17085bc45180a8fcb3e66c09c4fc065d83b8501ec136c2c849d57f0f0
7
+ data.tar.gz: 155deca466acc973546f4b42fe9a7adff098e15b307fea577f136b6274dfd23d291e2f3ba162d50612a9e0b50b5cfc4070a342ff597b6ccb0e98790e99b7cab5
data/.rubocop_todo.yml CHANGED
@@ -1,24 +1,25 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-04-04 03:19:03 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: 2
10
- # This cop supports safe autocorrection (--autocorrect).
11
- # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
12
- Bundler/OrderedGems:
13
- Exclude:
14
- - 'Gemfile'
15
-
16
9
  # Offense count: 1
17
10
  Gemspec/RequiredRubyVersion:
18
11
  Exclude:
19
12
  - 'unitsml.gemspec'
20
13
 
21
- # Offense count: 75
14
+ # Offense count: 1
15
+ # This cop supports safe autocorrection (--autocorrect).
16
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
17
+ # SupportedStyles: with_first_argument, with_fixed_indentation
18
+ Layout/ArgumentAlignment:
19
+ Exclude:
20
+ - 'lib/unitsml/unit.rb'
21
+
22
+ # Offense count: 76
22
23
  # This cop supports safe autocorrection (--autocorrect).
23
24
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
24
25
  # URISchemes: http, https
@@ -40,6 +41,13 @@ Layout/LineLength:
40
41
  - 'spec/unitsml/conv/xml_spec.rb'
41
42
  - 'unitsml.gemspec'
42
43
 
44
+ # Offense count: 1
45
+ # This cop supports safe autocorrection (--autocorrect).
46
+ # Configuration parameters: AllowInHeredoc.
47
+ Layout/TrailingWhitespace:
48
+ Exclude:
49
+ - 'lib/unitsml/unit.rb'
50
+
43
51
  # Offense count: 3
44
52
  Lint/ReturnInVoidContext:
45
53
  Exclude:
@@ -160,6 +168,12 @@ RSpec/SpecFilePathFormat:
160
168
  - 'spec/unitsml/conv/unicode_spec.rb'
161
169
  - 'spec/unitsml/conv/xml_spec.rb'
162
170
 
171
+ # Offense count: 1
172
+ # This cop supports safe autocorrection (--autocorrect).
173
+ Style/MultilineIfModifier:
174
+ Exclude:
175
+ - 'lib/unitsml/unit.rb'
176
+
163
177
  # Offense count: 2
164
178
  # Configuration parameters: AllowedMethods.
165
179
  # AllowedMethods: respond_to_missing?
data/Gemfile CHANGED
@@ -7,7 +7,6 @@ gemspec
7
7
 
8
8
  gem "canon"
9
9
  gem "lutaml-model", "~> 0.8.0", github: "lutaml/lutaml-model", branch: "main"
10
- gem "mml"
11
10
  gem "oga"
12
11
  gem "ox"
13
12
  gem "plurimath", github: "plurimath/plurimath", branch: "rt-lutaml-080"
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Unitsml
4
- VERSION = "0.6.2"
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.2
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
@@ -171,7 +171,6 @@ post_install_message:
171
171
  rdoc_options: []
172
172
  require_paths:
173
173
  - lib
174
- - unitsdb/**/*.yaml
175
174
  required_ruby_version: !ruby/object:Gem::Requirement
176
175
  requirements:
177
176
  - - ">="