unitsdb 2.1.0 → 2.2.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.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +8 -1
- data/.gitignore +2 -0
- data/.gitmodules +4 -3
- data/.rubocop.yml +13 -8
- data/.rubocop_todo.yml +247 -53
- data/CLAUDE.md +55 -0
- data/Gemfile +5 -1
- data/README.adoc +385 -12
- data/data/dimensions.yaml +1864 -0
- data/data/prefixes.yaml +874 -0
- data/data/quantities.yaml +3715 -0
- data/data/scales.yaml +97 -0
- data/data/schemas/dimensions-schema.yaml +153 -0
- data/data/schemas/prefixes-schema.yaml +155 -0
- data/data/schemas/quantities-schema.yaml +117 -0
- data/data/schemas/scales-schema.yaml +106 -0
- data/data/schemas/unit_systems-schema.yaml +116 -0
- data/data/schemas/units-schema.yaml +215 -0
- data/data/unit_systems.yaml +78 -0
- data/data/units.yaml +14052 -0
- data/exe/unitsdb +7 -1
- data/lib/unitsdb/cli.rb +47 -13
- data/lib/unitsdb/commands/_modify.rb +41 -5
- data/lib/unitsdb/commands/base.rb +10 -32
- data/lib/unitsdb/commands/check_si/si_formatter.rb +488 -0
- data/lib/unitsdb/commands/check_si/si_matcher.rb +487 -0
- data/lib/unitsdb/commands/check_si/si_ttl_parser.rb +103 -0
- data/lib/unitsdb/commands/check_si/si_updater.rb +254 -0
- data/lib/unitsdb/commands/check_si.rb +54 -35
- data/lib/unitsdb/commands/get.rb +11 -10
- data/lib/unitsdb/commands/normalize.rb +21 -7
- data/lib/unitsdb/commands/qudt/check.rb +150 -0
- data/lib/unitsdb/commands/qudt/formatter.rb +194 -0
- data/lib/unitsdb/commands/qudt/matcher.rb +746 -0
- data/lib/unitsdb/commands/qudt/ttl_parser.rb +403 -0
- data/lib/unitsdb/commands/qudt/update.rb +126 -0
- data/lib/unitsdb/commands/qudt/updater.rb +189 -0
- data/lib/unitsdb/commands/qudt.rb +82 -0
- data/lib/unitsdb/commands/release.rb +50 -86
- data/lib/unitsdb/commands/search.rb +12 -11
- data/lib/unitsdb/commands/ucum/check.rb +139 -0
- data/lib/unitsdb/commands/ucum/formatter.rb +142 -0
- data/lib/unitsdb/commands/ucum/matcher.rb +315 -0
- data/lib/unitsdb/commands/ucum/update.rb +85 -0
- data/lib/unitsdb/commands/ucum/updater.rb +132 -0
- data/lib/unitsdb/commands/ucum/xml_parser.rb +32 -0
- data/lib/unitsdb/commands/ucum.rb +83 -0
- data/lib/unitsdb/commands/validate/identifiers.rb +3 -3
- data/lib/unitsdb/commands/validate/qudt_references.rb +111 -0
- data/lib/unitsdb/commands/validate/references.rb +37 -18
- data/lib/unitsdb/commands/validate/si_references.rb +3 -11
- data/lib/unitsdb/commands/validate/ucum_references.rb +105 -0
- data/lib/unitsdb/commands/validate.rb +67 -11
- data/lib/unitsdb/commands.rb +20 -0
- data/lib/unitsdb/database.rb +91 -52
- data/lib/unitsdb/dimension.rb +1 -4
- data/lib/unitsdb/dimension_details.rb +0 -1
- data/lib/unitsdb/dimensions.rb +1 -2
- data/lib/unitsdb/errors.rb +7 -0
- data/lib/unitsdb/prefix.rb +0 -4
- data/lib/unitsdb/prefix_reference.rb +0 -2
- data/lib/unitsdb/prefixes.rb +1 -1
- data/lib/unitsdb/quantities.rb +1 -2
- data/lib/unitsdb/quantity.rb +0 -6
- data/lib/unitsdb/qudt.rb +100 -0
- data/lib/unitsdb/root_unit_reference.rb +0 -3
- data/lib/unitsdb/scale.rb +0 -4
- data/lib/unitsdb/scale_reference.rb +0 -2
- data/lib/unitsdb/scales.rb +1 -2
- data/lib/unitsdb/si_derived_base.rb +0 -2
- data/lib/unitsdb/ucum.rb +202 -0
- data/lib/unitsdb/unit.rb +0 -10
- data/lib/unitsdb/unit_reference.rb +0 -2
- data/lib/unitsdb/unit_system.rb +1 -3
- data/lib/unitsdb/unit_system_reference.rb +0 -2
- data/lib/unitsdb/unit_systems.rb +1 -2
- data/lib/unitsdb/units.rb +1 -2
- data/lib/unitsdb/utils.rb +32 -21
- data/lib/unitsdb/version.rb +5 -1
- data/lib/unitsdb.rb +62 -14
- data/unitsdb.gemspec +6 -5
- metadata +60 -13
- data/lib/unitsdb/commands/si_formatter.rb +0 -485
- data/lib/unitsdb/commands/si_matcher.rb +0 -470
- data/lib/unitsdb/commands/si_ttl_parser.rb +0 -100
- data/lib/unitsdb/commands/si_updater.rb +0 -212
data/lib/unitsdb/ucum.rb
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unitsdb
|
|
4
|
+
# <base-unit Code="s" CODE="S" dim="T">
|
|
5
|
+
# <name>second</name>
|
|
6
|
+
# <printSymbol>s</printSymbol>
|
|
7
|
+
# <property>time</property>
|
|
8
|
+
# </base-unit>
|
|
9
|
+
class UcumBaseUnit < Lutaml::Model::Serializable
|
|
10
|
+
attribute :code_sensitive, :string
|
|
11
|
+
attribute :code, :string
|
|
12
|
+
attribute :dimension, :string
|
|
13
|
+
attribute :name, :string
|
|
14
|
+
attribute :print_symbol, :string, raw: true
|
|
15
|
+
attribute :property, :string
|
|
16
|
+
|
|
17
|
+
xml do
|
|
18
|
+
element "base-unit"
|
|
19
|
+
map_attribute "Code", to: :code_sensitive
|
|
20
|
+
map_attribute "CODE", to: :code
|
|
21
|
+
map_attribute "dim", to: :dimension
|
|
22
|
+
map_element "name", to: :name
|
|
23
|
+
map_element "printSymbol", to: :print_symbol
|
|
24
|
+
map_element "property", to: :property
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def identifier
|
|
28
|
+
"ucum:base-unit:code:#{code_sensitive}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# <prefix Code="Y" CODE="YA">
|
|
33
|
+
# <name>yotta</name>
|
|
34
|
+
# <printSymbol>Y</printSymbol>
|
|
35
|
+
# <value value="1e24">1 × 10<sup>24</sup>
|
|
36
|
+
# </value>
|
|
37
|
+
# </prefix>
|
|
38
|
+
|
|
39
|
+
class UcumPrefixValue < Lutaml::Model::Serializable
|
|
40
|
+
attribute :value, :string
|
|
41
|
+
attribute :content, :string
|
|
42
|
+
|
|
43
|
+
xml do
|
|
44
|
+
element "value"
|
|
45
|
+
map_attribute "value", to: :value
|
|
46
|
+
map_content to: :content
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class UcumPrefix < Lutaml::Model::Serializable
|
|
51
|
+
attribute :code_sensitive, :string
|
|
52
|
+
attribute :code, :string
|
|
53
|
+
attribute :name, :string
|
|
54
|
+
attribute :print_symbol, :string, raw: true
|
|
55
|
+
attribute :value, UcumPrefixValue
|
|
56
|
+
|
|
57
|
+
xml do
|
|
58
|
+
element "prefix"
|
|
59
|
+
map_attribute "Code", to: :code_sensitive
|
|
60
|
+
map_attribute "CODE", to: :code
|
|
61
|
+
map_element "name", to: :name
|
|
62
|
+
map_element "printSymbol", to: :print_symbol
|
|
63
|
+
map_element "value", to: :value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def identifier
|
|
67
|
+
"ucum:prefix:code:#{code_sensitive}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# <unit Code="10*" CODE="10*" isMetric="no" class="dimless">
|
|
72
|
+
# <name>the number ten for arbitrary powers</name>
|
|
73
|
+
# <printSymbol>10</printSymbol>
|
|
74
|
+
# <property>number</property>
|
|
75
|
+
# <value Unit="1" UNIT="1" value="10">10</value>
|
|
76
|
+
# </unit>
|
|
77
|
+
|
|
78
|
+
# <unit Code="gon" CODE="GON" isMetric="no" class="iso1000">
|
|
79
|
+
# <name>gon</name>
|
|
80
|
+
# <name>grade</name>
|
|
81
|
+
# <printSymbol>
|
|
82
|
+
# <sup>g</sup>
|
|
83
|
+
# </printSymbol>
|
|
84
|
+
# <property>plane angle</property>
|
|
85
|
+
# <value Unit="deg" UNIT="DEG" value="0.9">0.9</value>
|
|
86
|
+
# </unit>
|
|
87
|
+
|
|
88
|
+
# <unit Code="[D'ag'U]" CODE="[D'AG'U]" isMetric="no" isArbitrary="yes"
|
|
89
|
+
# class="chemical">
|
|
90
|
+
# <name>D-antigen unit</name>
|
|
91
|
+
# <printSymbol/>
|
|
92
|
+
# <property>procedure defined amount of a poliomyelitis d-antigen substance</property>
|
|
93
|
+
# <value Unit="1" UNIT="1" value="1">1</value>
|
|
94
|
+
# </unit>
|
|
95
|
+
|
|
96
|
+
# <unit Code="Cel" CODE="CEL" isMetric="yes" isSpecial="yes" class="si">
|
|
97
|
+
# <name>degree Celsius</name>
|
|
98
|
+
# <printSymbol>°C</printSymbol>
|
|
99
|
+
# <property>temperature</property>
|
|
100
|
+
# <value Unit="cel(1 K)" UNIT="CEL(1 K)">
|
|
101
|
+
# <function name="Cel" value="1" Unit="K"/>
|
|
102
|
+
# </value>
|
|
103
|
+
# </unit>
|
|
104
|
+
|
|
105
|
+
class UcumUnitValueFunction < Lutaml::Model::Serializable
|
|
106
|
+
attribute :name, :string
|
|
107
|
+
attribute :value, :string
|
|
108
|
+
attribute :unit_sensitive, :string
|
|
109
|
+
|
|
110
|
+
xml do
|
|
111
|
+
element "function"
|
|
112
|
+
map_attribute "name", to: :name
|
|
113
|
+
map_attribute "value", to: :value
|
|
114
|
+
map_attribute "Unit", to: :unit_sensitive
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
class UcumUnitValue < Lutaml::Model::Serializable
|
|
119
|
+
attribute :unit_sensitive, :string
|
|
120
|
+
attribute :unit, :string
|
|
121
|
+
attribute :value, :string
|
|
122
|
+
attribute :function, UcumUnitValueFunction
|
|
123
|
+
attribute :content, :string
|
|
124
|
+
|
|
125
|
+
xml do
|
|
126
|
+
element "value"
|
|
127
|
+
map_attribute "Unit", to: :unit_sensitive
|
|
128
|
+
map_attribute "UNIT", to: :unit
|
|
129
|
+
map_attribute "value", to: :value
|
|
130
|
+
map_element "function", to: :function
|
|
131
|
+
map_content to: :content
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
class UcumUnit < Lutaml::Model::Serializable
|
|
136
|
+
attribute :code_sensitive, :string
|
|
137
|
+
attribute :code, :string
|
|
138
|
+
attribute :is_metric, :string
|
|
139
|
+
attribute :is_arbitrary, :string
|
|
140
|
+
attribute :is_special, :string
|
|
141
|
+
attribute :klass, :string
|
|
142
|
+
attribute :name, :string, collection: true
|
|
143
|
+
attribute :print_symbol, :string, raw: true
|
|
144
|
+
attribute :property, :string
|
|
145
|
+
attribute :value, UcumUnitValue
|
|
146
|
+
|
|
147
|
+
xml do
|
|
148
|
+
element "unit"
|
|
149
|
+
map_attribute "Code", to: :code_sensitive
|
|
150
|
+
map_attribute "CODE", to: :code
|
|
151
|
+
map_attribute "isMetric", to: :is_metric
|
|
152
|
+
map_attribute "isArbitrary", to: :is_arbitrary
|
|
153
|
+
map_attribute "isSpecial", to: :is_special
|
|
154
|
+
map_attribute "class", to: :klass
|
|
155
|
+
|
|
156
|
+
map_element "name", to: :name
|
|
157
|
+
map_element "printSymbol", to: :print_symbol
|
|
158
|
+
map_element "property", to: :property
|
|
159
|
+
map_element "value", to: :value
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def identifier
|
|
163
|
+
# Use empty string if klass is not present
|
|
164
|
+
k = klass || ""
|
|
165
|
+
"ucum:unit:#{k}:code:#{code_sensitive}"
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
class UcumNamespace < Lutaml::Xml::Namespace
|
|
170
|
+
uri "http://unitsofmeasure.org/ucum-essence"
|
|
171
|
+
prefix_default "ucum"
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# This is the root element of the UCUM XML "ucum-essence.xml" file.
|
|
175
|
+
#
|
|
176
|
+
# <root xmlns="http://unitsofmeasure.org/ucum-essence" version="2.2" revision="N/A"
|
|
177
|
+
# revision-date="2024-06-17">
|
|
178
|
+
|
|
179
|
+
class UcumFile < Lutaml::Model::Serializable
|
|
180
|
+
attribute :revision, :string
|
|
181
|
+
attribute :version, :string
|
|
182
|
+
attribute :revision_date, :date
|
|
183
|
+
attribute :prefixes, UcumPrefix, collection: true
|
|
184
|
+
attribute :base_units, UcumBaseUnit, collection: true
|
|
185
|
+
attribute :units, UcumUnit, collection: true
|
|
186
|
+
|
|
187
|
+
xml do
|
|
188
|
+
element "root"
|
|
189
|
+
namespace UcumNamespace
|
|
190
|
+
|
|
191
|
+
map_attribute "version", to: :version
|
|
192
|
+
map_attribute "revision", to: :revision
|
|
193
|
+
map_attribute "revision-date", to: :revision_date
|
|
194
|
+
|
|
195
|
+
map_element "prefix", to: :prefixes
|
|
196
|
+
map_element "base-unit", to: :base_units
|
|
197
|
+
map_element "unit", to: :units
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# No adapter registration needed
|
|
201
|
+
end
|
|
202
|
+
end
|
data/lib/unitsdb/unit.rb
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "symbol_presentations"
|
|
4
|
-
require_relative "unit_system_reference"
|
|
5
|
-
require_relative "root_unit_reference"
|
|
6
|
-
require_relative "si_derived_base"
|
|
7
|
-
require_relative "quantity_reference"
|
|
8
|
-
require_relative "dimension_reference"
|
|
9
|
-
require_relative "external_reference"
|
|
10
|
-
require_relative "localized_string"
|
|
11
|
-
require_relative "scale_reference"
|
|
12
|
-
|
|
13
3
|
# "NISTu10":
|
|
14
4
|
# dimension_url: "#NISTd9"
|
|
15
5
|
# short: steradian
|
data/lib/unitsdb/unit_system.rb
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "identifier"
|
|
4
|
-
require_relative "localized_string"
|
|
5
|
-
|
|
6
3
|
module Unitsdb
|
|
7
4
|
class UnitSystem < Lutaml::Model::Serializable
|
|
8
5
|
# model Config.model_for(:unit_system)
|
|
@@ -11,5 +8,6 @@ module Unitsdb
|
|
|
11
8
|
attribute :names, LocalizedString, collection: true
|
|
12
9
|
attribute :short, :string
|
|
13
10
|
attribute :acceptable, :boolean
|
|
11
|
+
attribute :references, ExternalReference, collection: true
|
|
14
12
|
end
|
|
15
13
|
end
|
data/lib/unitsdb/unit_systems.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "unit_system"
|
|
4
|
-
|
|
5
3
|
module Unitsdb
|
|
6
4
|
class UnitSystems < Lutaml::Model::Serializable
|
|
7
5
|
# model Config.model_for(:unit_systems)
|
|
8
6
|
|
|
9
7
|
attribute :schema_version, :string
|
|
8
|
+
attribute :version, :string
|
|
10
9
|
attribute :unit_systems, UnitSystem, collection: true
|
|
11
10
|
end
|
|
12
11
|
end
|
data/lib/unitsdb/units.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "unit"
|
|
4
|
-
|
|
5
3
|
module Unitsdb
|
|
6
4
|
class Units < Lutaml::Model::Serializable
|
|
7
5
|
# model Config.model_for(:units)
|
|
8
6
|
|
|
9
7
|
attribute :schema_version, :string
|
|
8
|
+
attribute :version, :string
|
|
10
9
|
attribute :units, Unit, collection: true
|
|
11
10
|
end
|
|
12
11
|
end
|
data/lib/unitsdb/utils.rb
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Unitsdb
|
|
4
4
|
module Utils
|
|
5
|
-
DEFAULT_YAML_FILES = %w[dimensions prefixes quantities unit_systems
|
|
5
|
+
DEFAULT_YAML_FILES = %w[dimensions prefixes quantities unit_systems
|
|
6
|
+
units].map do |f|
|
|
7
|
+
"#{f}.yaml"
|
|
8
|
+
end
|
|
6
9
|
|
|
7
10
|
def self.levenshtein_distance(s, t)
|
|
8
11
|
m = s.length
|
|
@@ -32,7 +35,10 @@ module Unitsdb
|
|
|
32
35
|
def self.find_similar_ids(id, valid_ids, max_results = 5)
|
|
33
36
|
# Simple similarity measure based on Levenshtein distance
|
|
34
37
|
valid_ids
|
|
35
|
-
.map
|
|
38
|
+
.map do |valid_id|
|
|
39
|
+
[valid_id,
|
|
40
|
+
levenshtein_distance(id.to_s, valid_id.to_s)]
|
|
41
|
+
end
|
|
36
42
|
.sort_by { |_, distance| distance }
|
|
37
43
|
.take(max_results)
|
|
38
44
|
.select { |_, distance| distance < [id.to_s.length, 10].min }
|
|
@@ -44,32 +50,37 @@ module Unitsdb
|
|
|
44
50
|
when Hash
|
|
45
51
|
# Transform values first, then sort keys
|
|
46
52
|
obj.transform_values { |v| sort_yaml_keys(v) }
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
.sort_by do |key, _|
|
|
54
|
+
key_str = key.to_s
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
# Handle NIST IDs with proper category-based sorting
|
|
57
|
+
case key_str
|
|
58
|
+
when /\ANIST([a-z])(\d+)_(-?\d+)\Z/ # Prefixes with power (NISTp2_10)
|
|
59
|
+
[0, ::Regexp.last_match(1), ::Regexp.last_match(2).to_i,
|
|
60
|
+
::Regexp.last_match(3).to_i]
|
|
61
|
+
when /\ANIST([a-z])(\d+)\Z/ # Prefixes without power
|
|
62
|
+
[0, ::Regexp.last_match(1), ::Regexp.last_match(2).to_i, 0]
|
|
63
|
+
when %r{[/e]} # Composite IDs with '/' or 'e' to the end
|
|
64
|
+
[2, key_str]
|
|
65
|
+
when /\ANISTu(\d+)\.(.+)\Z/ # Simple unit IDs (NISTu10.1)
|
|
66
|
+
[1, "u", ::Regexp.last_match(1).to_i, ::Regexp.last_match(2)]
|
|
67
|
+
else
|
|
68
|
+
[3, key_str] # Everything else
|
|
69
|
+
end
|
|
70
|
+
end.to_h
|
|
64
71
|
when Array
|
|
65
72
|
# For arrays in the new structure, sort them if they're arrays of hashes with 'id' or 'short' keys
|
|
66
|
-
if !obj.empty? && obj.all?
|
|
73
|
+
if !obj.empty? && obj.all?(Hash)
|
|
67
74
|
# Sort by 'id' within identifiers array
|
|
68
75
|
if obj.first.key?("id") && obj.first.key?("type")
|
|
69
|
-
obj.sort_by
|
|
76
|
+
obj.sort_by do |item|
|
|
77
|
+
item["id"].to_s
|
|
78
|
+
end.map { |item| sort_yaml_keys(item) }
|
|
70
79
|
# Sort by 'short' for other arrays (like main unit arrays)
|
|
71
80
|
elsif obj.first.key?("short")
|
|
72
|
-
obj.sort_by
|
|
81
|
+
obj.sort_by do |item|
|
|
82
|
+
item["short"].to_s
|
|
83
|
+
end.map { |item| sort_yaml_keys(item) }
|
|
73
84
|
else
|
|
74
85
|
obj.map { |item| sort_yaml_keys(item) }
|
|
75
86
|
end
|
data/lib/unitsdb/version.rb
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Unitsdb
|
|
4
|
-
VERSION = "2.1
|
|
4
|
+
VERSION = "2.2.1"
|
|
5
|
+
|
|
6
|
+
# The version of the bundled UnitsDB data (from the data/ submodule).
|
|
7
|
+
# This version corresponds to a tag/commit in https://github.com/unitsml/unitsdb.
|
|
8
|
+
UNITS_DATA_VERSION = "2.0.0"
|
|
5
9
|
end
|
data/lib/unitsdb.rb
CHANGED
|
@@ -2,20 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
require "lutaml/model"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
module Unitsdb
|
|
6
|
+
autoload :Cli, "unitsdb/cli"
|
|
7
|
+
autoload :Config, "unitsdb/config"
|
|
8
|
+
autoload :Commands, "unitsdb/commands"
|
|
9
|
+
autoload :Database, "unitsdb/database"
|
|
10
|
+
autoload :Dimension, "unitsdb/dimension"
|
|
11
|
+
autoload :DimensionDetails, "unitsdb/dimension_details"
|
|
12
|
+
autoload :DimensionReference, "unitsdb/dimension_reference"
|
|
13
|
+
autoload :Dimensions, "unitsdb/dimensions"
|
|
14
|
+
autoload :Errors, "unitsdb/errors"
|
|
15
|
+
autoload :ExternalReference, "unitsdb/external_reference"
|
|
16
|
+
autoload :Identifier, "unitsdb/identifier"
|
|
17
|
+
autoload :LocalizedString, "unitsdb/localized_string"
|
|
18
|
+
autoload :Prefix, "unitsdb/prefix"
|
|
19
|
+
autoload :PrefixReference, "unitsdb/prefix_reference"
|
|
20
|
+
autoload :Prefixes, "unitsdb/prefixes"
|
|
21
|
+
autoload :Quantities, "unitsdb/quantities"
|
|
22
|
+
autoload :Quantity, "unitsdb/quantity"
|
|
23
|
+
autoload :QuantityReference, "unitsdb/quantity_reference"
|
|
24
|
+
autoload :QudtUnit, "unitsdb/qudt"
|
|
25
|
+
autoload :QudtQuantityKind, "unitsdb/qudt"
|
|
26
|
+
autoload :QudtDimensionVector, "unitsdb/qudt"
|
|
27
|
+
autoload :QudtSystemOfUnits, "unitsdb/qudt"
|
|
28
|
+
autoload :QudtPrefix, "unitsdb/qudt"
|
|
29
|
+
autoload :QudtVocabularies, "unitsdb/qudt"
|
|
30
|
+
autoload :RootUnitReference, "unitsdb/root_unit_reference"
|
|
31
|
+
autoload :Scale, "unitsdb/scale"
|
|
32
|
+
autoload :ScaleProperties, "unitsdb/scale_properties"
|
|
33
|
+
autoload :ScaleReference, "unitsdb/scale_reference"
|
|
34
|
+
autoload :Scales, "unitsdb/scales"
|
|
35
|
+
autoload :SiDerivedBase, "unitsdb/si_derived_base"
|
|
36
|
+
autoload :SymbolPresentations, "unitsdb/symbol_presentations"
|
|
37
|
+
autoload :UcumBaseUnit, "unitsdb/ucum"
|
|
38
|
+
autoload :UcumPrefixValue, "unitsdb/ucum"
|
|
39
|
+
autoload :UcumPrefix, "unitsdb/ucum"
|
|
40
|
+
autoload :UcumUnitValueFunction, "unitsdb/ucum"
|
|
41
|
+
autoload :UcumUnitValue, "unitsdb/ucum"
|
|
42
|
+
autoload :UcumUnit, "unitsdb/ucum"
|
|
43
|
+
autoload :UcumFile, "unitsdb/ucum"
|
|
44
|
+
autoload :Unit, "unitsdb/unit"
|
|
45
|
+
autoload :UnitReference, "unitsdb/unit_reference"
|
|
46
|
+
autoload :UnitSystem, "unitsdb/unit_system"
|
|
47
|
+
autoload :UnitSystemReference, "unitsdb/unit_system_reference"
|
|
48
|
+
autoload :UnitSystems, "unitsdb/unit_systems"
|
|
49
|
+
autoload :Units, "unitsdb/units"
|
|
50
|
+
autoload :Utils, "unitsdb/utils"
|
|
16
51
|
|
|
17
|
-
|
|
18
|
-
|
|
52
|
+
class << self
|
|
53
|
+
# Returns the path to the bundled data directory containing YAML files
|
|
54
|
+
def data_dir
|
|
55
|
+
@data_dir ||= File.join(gem_dir, "data")
|
|
56
|
+
end
|
|
19
57
|
|
|
20
|
-
|
|
58
|
+
# Returns a pre-loaded Database instance from the bundled data
|
|
59
|
+
def database
|
|
60
|
+
@database ||= Database.from_db(data_dir)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def gem_dir
|
|
66
|
+
@gem_dir ||= File.dirname(__dir__)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
21
69
|
end
|
data/unitsdb.gemspec
CHANGED
|
@@ -18,8 +18,7 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
19
19
|
spec.metadata["source_code_uri"] = spec.homepage
|
|
20
20
|
spec.metadata["changelog_uri"] = "https://github.com/unitsml/unitsdb-ruby/releases"
|
|
21
|
-
|
|
22
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
|
21
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
23
22
|
|
|
24
23
|
# Specify which files should be added to the gem when it is released.
|
|
25
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
@@ -28,15 +27,17 @@ Gem::Specification.new do |spec|
|
|
|
28
27
|
f.match(%r{^(test|spec|features)/})
|
|
29
28
|
end
|
|
30
29
|
end
|
|
30
|
+
# Include YAML data files in the gem
|
|
31
|
+
spec.files += Dir.glob("data/**/*.yaml")
|
|
31
32
|
spec.bindir = "exe"
|
|
32
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
33
|
-
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
|
34
34
|
spec.require_paths = ["lib"]
|
|
35
35
|
|
|
36
|
-
spec.add_dependency "
|
|
36
|
+
spec.add_dependency "fuzzy_match"
|
|
37
|
+
spec.add_dependency "lutaml-model", "~> 0.8.0"
|
|
37
38
|
spec.add_dependency "rdf", "~> 3.1"
|
|
38
39
|
spec.add_dependency "rdf-turtle", "~> 3.1"
|
|
39
40
|
spec.add_dependency "rubyzip", "~> 2.3"
|
|
40
|
-
spec.add_dependency "
|
|
41
|
+
spec.add_dependency "table_tennis", "~> 0.0.7"
|
|
41
42
|
spec.add_dependency "thor", "~> 1.0"
|
|
42
43
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unitsdb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1
|
|
4
|
+
version: 2.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: fuzzy_match
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: lutaml-model
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
16
30
|
requirements:
|
|
17
31
|
- - "~>"
|
|
18
32
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
33
|
+
version: 0.8.0
|
|
20
34
|
type: :runtime
|
|
21
35
|
prerelease: false
|
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
37
|
requirements:
|
|
24
38
|
- - "~>"
|
|
25
39
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
40
|
+
version: 0.8.0
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: rdf
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,19 +81,19 @@ dependencies:
|
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
82
|
version: '2.3'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
84
|
+
name: table_tennis
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
73
|
-
- - "
|
|
87
|
+
- - "~>"
|
|
74
88
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
89
|
+
version: 0.0.7
|
|
76
90
|
type: :runtime
|
|
77
91
|
prerelease: false
|
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
93
|
requirements:
|
|
80
|
-
- - "
|
|
94
|
+
- - "~>"
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
96
|
+
version: 0.0.7
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: thor
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,6 +125,7 @@ files:
|
|
|
111
125
|
- ".rspec"
|
|
112
126
|
- ".rubocop.yml"
|
|
113
127
|
- ".rubocop_todo.yml"
|
|
128
|
+
- CLAUDE.md
|
|
114
129
|
- CODE_OF_CONDUCT.md
|
|
115
130
|
- Gemfile
|
|
116
131
|
- LICENSE.txt
|
|
@@ -118,24 +133,53 @@ files:
|
|
|
118
133
|
- Rakefile
|
|
119
134
|
- bin/console
|
|
120
135
|
- bin/setup
|
|
136
|
+
- data/dimensions.yaml
|
|
137
|
+
- data/prefixes.yaml
|
|
138
|
+
- data/quantities.yaml
|
|
139
|
+
- data/scales.yaml
|
|
140
|
+
- data/schemas/dimensions-schema.yaml
|
|
141
|
+
- data/schemas/prefixes-schema.yaml
|
|
142
|
+
- data/schemas/quantities-schema.yaml
|
|
143
|
+
- data/schemas/scales-schema.yaml
|
|
144
|
+
- data/schemas/unit_systems-schema.yaml
|
|
145
|
+
- data/schemas/units-schema.yaml
|
|
146
|
+
- data/unit_systems.yaml
|
|
147
|
+
- data/units.yaml
|
|
121
148
|
- exe/unitsdb
|
|
122
149
|
- lib/unitsdb.rb
|
|
123
150
|
- lib/unitsdb/cli.rb
|
|
151
|
+
- lib/unitsdb/commands.rb
|
|
124
152
|
- lib/unitsdb/commands/_modify.rb
|
|
125
153
|
- lib/unitsdb/commands/base.rb
|
|
126
154
|
- lib/unitsdb/commands/check_si.rb
|
|
155
|
+
- lib/unitsdb/commands/check_si/si_formatter.rb
|
|
156
|
+
- lib/unitsdb/commands/check_si/si_matcher.rb
|
|
157
|
+
- lib/unitsdb/commands/check_si/si_ttl_parser.rb
|
|
158
|
+
- lib/unitsdb/commands/check_si/si_updater.rb
|
|
127
159
|
- lib/unitsdb/commands/get.rb
|
|
128
160
|
- lib/unitsdb/commands/normalize.rb
|
|
161
|
+
- lib/unitsdb/commands/qudt.rb
|
|
162
|
+
- lib/unitsdb/commands/qudt/check.rb
|
|
163
|
+
- lib/unitsdb/commands/qudt/formatter.rb
|
|
164
|
+
- lib/unitsdb/commands/qudt/matcher.rb
|
|
165
|
+
- lib/unitsdb/commands/qudt/ttl_parser.rb
|
|
166
|
+
- lib/unitsdb/commands/qudt/update.rb
|
|
167
|
+
- lib/unitsdb/commands/qudt/updater.rb
|
|
129
168
|
- lib/unitsdb/commands/release.rb
|
|
130
169
|
- lib/unitsdb/commands/search.rb
|
|
131
|
-
- lib/unitsdb/commands/
|
|
132
|
-
- lib/unitsdb/commands/
|
|
133
|
-
- lib/unitsdb/commands/
|
|
134
|
-
- lib/unitsdb/commands/
|
|
170
|
+
- lib/unitsdb/commands/ucum.rb
|
|
171
|
+
- lib/unitsdb/commands/ucum/check.rb
|
|
172
|
+
- lib/unitsdb/commands/ucum/formatter.rb
|
|
173
|
+
- lib/unitsdb/commands/ucum/matcher.rb
|
|
174
|
+
- lib/unitsdb/commands/ucum/update.rb
|
|
175
|
+
- lib/unitsdb/commands/ucum/updater.rb
|
|
176
|
+
- lib/unitsdb/commands/ucum/xml_parser.rb
|
|
135
177
|
- lib/unitsdb/commands/validate.rb
|
|
136
178
|
- lib/unitsdb/commands/validate/identifiers.rb
|
|
179
|
+
- lib/unitsdb/commands/validate/qudt_references.rb
|
|
137
180
|
- lib/unitsdb/commands/validate/references.rb
|
|
138
181
|
- lib/unitsdb/commands/validate/si_references.rb
|
|
182
|
+
- lib/unitsdb/commands/validate/ucum_references.rb
|
|
139
183
|
- lib/unitsdb/config.rb
|
|
140
184
|
- lib/unitsdb/database.rb
|
|
141
185
|
- lib/unitsdb/dimension.rb
|
|
@@ -152,6 +196,7 @@ files:
|
|
|
152
196
|
- lib/unitsdb/quantities.rb
|
|
153
197
|
- lib/unitsdb/quantity.rb
|
|
154
198
|
- lib/unitsdb/quantity_reference.rb
|
|
199
|
+
- lib/unitsdb/qudt.rb
|
|
155
200
|
- lib/unitsdb/root_unit_reference.rb
|
|
156
201
|
- lib/unitsdb/scale.rb
|
|
157
202
|
- lib/unitsdb/scale_properties.rb
|
|
@@ -159,6 +204,7 @@ files:
|
|
|
159
204
|
- lib/unitsdb/scales.rb
|
|
160
205
|
- lib/unitsdb/si_derived_base.rb
|
|
161
206
|
- lib/unitsdb/symbol_presentations.rb
|
|
207
|
+
- lib/unitsdb/ucum.rb
|
|
162
208
|
- lib/unitsdb/unit.rb
|
|
163
209
|
- lib/unitsdb/unit_reference.rb
|
|
164
210
|
- lib/unitsdb/unit_system.rb
|
|
@@ -176,6 +222,7 @@ metadata:
|
|
|
176
222
|
homepage_uri: https://github.com/unitsml/unitsdb-ruby
|
|
177
223
|
source_code_uri: https://github.com/unitsml/unitsdb-ruby
|
|
178
224
|
changelog_uri: https://github.com/unitsml/unitsdb-ruby/releases
|
|
225
|
+
rubygems_mfa_required: 'true'
|
|
179
226
|
post_install_message:
|
|
180
227
|
rdoc_options: []
|
|
181
228
|
require_paths:
|