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 +4 -4
- data/.rubocop_todo.yml +23 -9
- data/Gemfile +0 -1
- data/lib/unitsml/formula.rb +4 -0
- data/lib/unitsml/unit.rb +17 -4
- data/lib/unitsml/version.rb +1 -1
- data/unitsml.gemspec +2 -2
- metadata +6 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c09381e8f89d514ecb84572e770736fb4f60615e2ab1766dcdb7bb3e6c15d8c7
|
|
4
|
+
data.tar.gz: 1a1ac51b9aafbdd3eb377c437385d07886f965d0907df62bd46ba79f75565a06
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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-
|
|
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:
|
|
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
data/lib/unitsml/formula.rb
CHANGED
|
@@ -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
|
-
|
|
39
|
-
tag_name =
|
|
40
|
-
|
|
41
|
-
value
|
|
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
|
data/lib/unitsml/version.rb
CHANGED
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"
|
|
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.
|
|
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-
|
|
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:
|
|
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:
|
|
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
|
- - ">="
|