unitsdb 2.1.1 → 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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +8 -1
  3. data/.gitignore +2 -0
  4. data/.gitmodules +4 -3
  5. data/.rubocop.yml +13 -8
  6. data/.rubocop_todo.yml +217 -100
  7. data/CLAUDE.md +55 -0
  8. data/Gemfile +4 -1
  9. data/README.adoc +283 -16
  10. data/data/dimensions.yaml +1864 -0
  11. data/data/prefixes.yaml +874 -0
  12. data/data/quantities.yaml +3715 -0
  13. data/data/scales.yaml +97 -0
  14. data/data/schemas/dimensions-schema.yaml +153 -0
  15. data/data/schemas/prefixes-schema.yaml +155 -0
  16. data/data/schemas/quantities-schema.yaml +117 -0
  17. data/data/schemas/scales-schema.yaml +106 -0
  18. data/data/schemas/unit_systems-schema.yaml +116 -0
  19. data/data/schemas/units-schema.yaml +215 -0
  20. data/data/unit_systems.yaml +78 -0
  21. data/data/units.yaml +14052 -0
  22. data/exe/unitsdb +7 -1
  23. data/lib/unitsdb/cli.rb +42 -15
  24. data/lib/unitsdb/commands/_modify.rb +40 -4
  25. data/lib/unitsdb/commands/base.rb +6 -2
  26. data/lib/unitsdb/commands/check_si/si_formatter.rb +488 -0
  27. data/lib/unitsdb/commands/check_si/si_matcher.rb +487 -0
  28. data/lib/unitsdb/commands/check_si/si_ttl_parser.rb +103 -0
  29. data/lib/unitsdb/commands/check_si/si_updater.rb +254 -0
  30. data/lib/unitsdb/commands/check_si.rb +54 -35
  31. data/lib/unitsdb/commands/get.rb +11 -10
  32. data/lib/unitsdb/commands/normalize.rb +21 -7
  33. data/lib/unitsdb/commands/qudt/check.rb +150 -0
  34. data/lib/unitsdb/commands/qudt/formatter.rb +194 -0
  35. data/lib/unitsdb/commands/qudt/matcher.rb +746 -0
  36. data/lib/unitsdb/commands/qudt/ttl_parser.rb +403 -0
  37. data/lib/unitsdb/commands/qudt/update.rb +126 -0
  38. data/lib/unitsdb/commands/qudt/updater.rb +189 -0
  39. data/lib/unitsdb/commands/qudt.rb +82 -0
  40. data/lib/unitsdb/commands/release.rb +12 -9
  41. data/lib/unitsdb/commands/search.rb +12 -11
  42. data/lib/unitsdb/commands/ucum/check.rb +42 -29
  43. data/lib/unitsdb/commands/ucum/formatter.rb +2 -1
  44. data/lib/unitsdb/commands/ucum/matcher.rb +23 -9
  45. data/lib/unitsdb/commands/ucum/update.rb +14 -13
  46. data/lib/unitsdb/commands/ucum/updater.rb +40 -6
  47. data/lib/unitsdb/commands/ucum/xml_parser.rb +0 -2
  48. data/lib/unitsdb/commands/ucum.rb +44 -4
  49. data/lib/unitsdb/commands/validate/identifiers.rb +2 -4
  50. data/lib/unitsdb/commands/validate/qudt_references.rb +111 -0
  51. data/lib/unitsdb/commands/validate/references.rb +36 -19
  52. data/lib/unitsdb/commands/validate/si_references.rb +3 -5
  53. data/lib/unitsdb/commands/validate/ucum_references.rb +105 -0
  54. data/lib/unitsdb/commands/validate.rb +67 -11
  55. data/lib/unitsdb/commands.rb +20 -0
  56. data/lib/unitsdb/database.rb +90 -52
  57. data/lib/unitsdb/dimension.rb +1 -4
  58. data/lib/unitsdb/dimension_details.rb +0 -1
  59. data/lib/unitsdb/dimensions.rb +0 -2
  60. data/lib/unitsdb/errors.rb +7 -0
  61. data/lib/unitsdb/prefix.rb +0 -4
  62. data/lib/unitsdb/prefix_reference.rb +0 -2
  63. data/lib/unitsdb/prefixes.rb +0 -1
  64. data/lib/unitsdb/quantities.rb +0 -2
  65. data/lib/unitsdb/quantity.rb +0 -6
  66. data/lib/unitsdb/qudt.rb +100 -0
  67. data/lib/unitsdb/root_unit_reference.rb +0 -3
  68. data/lib/unitsdb/scale.rb +0 -4
  69. data/lib/unitsdb/scale_reference.rb +0 -2
  70. data/lib/unitsdb/scales.rb +0 -2
  71. data/lib/unitsdb/si_derived_base.rb +0 -2
  72. data/lib/unitsdb/ucum.rb +14 -10
  73. data/lib/unitsdb/unit.rb +0 -10
  74. data/lib/unitsdb/unit_reference.rb +0 -2
  75. data/lib/unitsdb/unit_system.rb +1 -3
  76. data/lib/unitsdb/unit_system_reference.rb +0 -2
  77. data/lib/unitsdb/unit_systems.rb +0 -2
  78. data/lib/unitsdb/units.rb +0 -2
  79. data/lib/unitsdb/utils.rb +32 -21
  80. data/lib/unitsdb/version.rb +5 -1
  81. data/lib/unitsdb.rb +62 -14
  82. data/unitsdb.gemspec +6 -3
  83. metadata +52 -13
  84. data/lib/unitsdb/commands/si_formatter.rb +0 -485
  85. data/lib/unitsdb/commands/si_matcher.rb +0 -470
  86. data/lib/unitsdb/commands/si_ttl_parser.rb +0 -100
  87. data/lib/unitsdb/commands/si_updater.rb +0 -212
@@ -0,0 +1,116 @@
1
+ # yaml-language-server: $schema=http://json-schema.org/draft-06/schema
2
+ ---
3
+ $schema: "http://json-schema.org/draft-06/schema#"
4
+ $id: "https://unitsml.org/schemas/unit_systems-schema.yaml"
5
+ title: "Unit Systems Database Schema"
6
+ description: "Schema for unit_systems.yaml - defines systems of measurement units"
7
+
8
+ type: object
9
+ required: ["schema_version", "unit_systems"]
10
+ properties:
11
+ schema_version:
12
+ type: string
13
+ pattern: "^\\d+\\.\\d+\\.\\d+$"
14
+ description: "Semantic version of the schema"
15
+ unit_systems:
16
+ type: array
17
+ description: "Array of unit system definitions"
18
+ items:
19
+ $ref: "#/definitions/UnitSystem"
20
+
21
+ definitions:
22
+ UnitSystem:
23
+ type: object
24
+ required: ["identifiers", "names"]
25
+ properties:
26
+ identifiers:
27
+ type: array
28
+ description: "External identifiers for this unit system"
29
+ items:
30
+ $ref: "#/definitions/Identifier"
31
+ names:
32
+ type: array
33
+ description: "Multilingual names for this unit system"
34
+ items:
35
+ $ref: "#/definitions/Name"
36
+ base_units:
37
+ type: array
38
+ description: "Base units that define this system"
39
+ items:
40
+ $ref: "#/definitions/BaseUnitReference"
41
+ references:
42
+ type: array
43
+ description: "External references and citations"
44
+ items:
45
+ $ref: "#/definitions/Reference"
46
+
47
+ Identifier:
48
+ type: object
49
+ required: ["type", "id"]
50
+ properties:
51
+ type:
52
+ type: string
53
+ enum: ["nist", "unitsml", "si-digital-framework"]
54
+ description: "Type of identifier system"
55
+ id:
56
+ type: string
57
+ description: "Identifier value within the system"
58
+
59
+ Name:
60
+ type: object
61
+ required: ["value", "lang"]
62
+ properties:
63
+ value:
64
+ type: string
65
+ description: "Name in the specified language"
66
+ lang:
67
+ type: string
68
+ pattern: "^[a-z]{2}(-[A-Z]{2})?$"
69
+ description: "Language code (ISO 639-1, optionally with ISO 3166-1 country)"
70
+
71
+ BaseUnitReference:
72
+ type: object
73
+ required: ["type", "id", "quantity_reference"]
74
+ properties:
75
+ type:
76
+ type: string
77
+ const: "unit"
78
+ description: "Reference type indicator"
79
+ id:
80
+ type: string
81
+ description: "Unit identifier"
82
+ quantity_reference:
83
+ $ref: "#/definitions/QuantityReference"
84
+ description: "Physical quantity this base unit measures"
85
+
86
+ QuantityReference:
87
+ type: object
88
+ required: ["type", "id"]
89
+ properties:
90
+ type:
91
+ type: string
92
+ const: "quantity"
93
+ description: "Reference type indicator"
94
+ id:
95
+ type: string
96
+ description: "Quantity identifier"
97
+
98
+ Reference:
99
+ type: object
100
+ required: ["type"]
101
+ properties:
102
+ type:
103
+ type: string
104
+ enum: ["informative", "normative"]
105
+ description: "Type of reference"
106
+ authority:
107
+ type: string
108
+ description: "Authoritative body or organization"
109
+ enum: ["si-digital-framework", "qudt", "ucum", "nist"]
110
+ uri:
111
+ type: string
112
+ format: "uri"
113
+ description: "URI to the reference"
114
+ title:
115
+ type: string
116
+ description: "Title of the reference"
@@ -0,0 +1,215 @@
1
+ # yaml-language-server: $schema=http://json-schema.org/draft-06/schema
2
+ ---
3
+ $schema: "http://json-schema.org/draft-06/schema#"
4
+ $id: "https://unitsml.org/schemas/units-schema.yaml"
5
+ title: "Units Database Schema"
6
+ description: "Schema for units.yaml - defines measurement units with their properties, symbols, and relationships"
7
+
8
+ type: object
9
+ required: ["schema_version", "units"]
10
+ properties:
11
+ schema_version:
12
+ type: string
13
+ pattern: "^\\d+\\.\\d+\\.\\d+$"
14
+ description: "Semantic version of the schema"
15
+ units:
16
+ type: array
17
+ description: "Array of unit definitions"
18
+ items:
19
+ $ref: "#/definitions/Unit"
20
+
21
+ definitions:
22
+ Unit:
23
+ type: object
24
+ required: ["identifiers", "names", "scale_reference", "unit_system_reference", "root", "short", "symbols"]
25
+ properties:
26
+ identifiers:
27
+ type: array
28
+ description: "External identifiers for this unit"
29
+ items:
30
+ $ref: "#/definitions/Identifier"
31
+ names:
32
+ type: array
33
+ description: "Multilingual names for this unit"
34
+ items:
35
+ $ref: "#/definitions/Name"
36
+ scale_reference:
37
+ $ref: "#/definitions/ScaleReference"
38
+ description: "Reference to the measurement scale"
39
+ unit_system_reference:
40
+ type: array
41
+ description: "Reference to the unit system"
42
+ items:
43
+ $ref: "#/definitions/UnitSystemReference"
44
+ minimum: 1
45
+ root:
46
+ type: boolean
47
+ description: "Whether this unit is a root unit in its system"
48
+ root_units:
49
+ type: array
50
+ description: "Root units that compose this unit"
51
+ items:
52
+ $ref: "#/definitions/RootUnit"
53
+ short:
54
+ type: string
55
+ description: "Short description or definition"
56
+ symbols:
57
+ type: array
58
+ description: "Mathematical and textual representations"
59
+ items:
60
+ $ref: "#/definitions/Symbol"
61
+ quantity_reference:
62
+ $ref: "#/definitions/QuantityReference"
63
+ description: "Reference to the physical quantity (optional)"
64
+ references:
65
+ type: array
66
+ description: "External references and citations"
67
+ items:
68
+ $ref: "#/definitions/Reference"
69
+
70
+ Identifier:
71
+ type: object
72
+ required: ["type", "id"]
73
+ properties:
74
+ type:
75
+ type: string
76
+ enum: ["nist", "unitsml", "ucum", "si-digital-framework"]
77
+ description: "Type of identifier system"
78
+ id:
79
+ type: string
80
+ description: "Identifier value within the system"
81
+
82
+ Name:
83
+ type: object
84
+ required: ["value", "lang"]
85
+ properties:
86
+ value:
87
+ type: string
88
+ description: "Name in the specified language"
89
+ lang:
90
+ type: string
91
+ pattern: "^[a-z]{2}(-[A-Z]{2})?$"
92
+ description: "Language code (ISO 639-1, optionally with ISO 3166-1 country)"
93
+
94
+ ScaleReference:
95
+ type: object
96
+ required: ["type", "id"]
97
+ properties:
98
+ type:
99
+ type: string
100
+ description: "Reference type indicator"
101
+ enum: ["unitsml"]
102
+ id:
103
+ type: string
104
+ description: "Scale identifier"
105
+
106
+ UnitSystemReference:
107
+ type: object
108
+ required: ["type", "id"]
109
+ properties:
110
+ type:
111
+ type: string
112
+ description: "Reference type indicator"
113
+ enum: ["unitsml", "ucum", "nist"]
114
+ id:
115
+ type: string
116
+ description: "Unit system identifier"
117
+
118
+ QuantityReference:
119
+ type: object
120
+ required: ["type", "id"]
121
+ properties:
122
+ type:
123
+ type: string
124
+ description: "Reference type indicator"
125
+ enum: ["unitsml", "ucum", "nist"]
126
+ id:
127
+ type: string
128
+ description: "Quantity identifier"
129
+
130
+ RootUnit:
131
+ type: object
132
+ required: ["power", "unit_reference"]
133
+ properties:
134
+ power:
135
+ type: integer
136
+ description: "Exponent for this unit in the composition"
137
+ unit_reference:
138
+ $ref: "#/definitions/UnitReference"
139
+ description: "Reference to the base unit"
140
+
141
+ UnitReference:
142
+ type: object
143
+ required: ["type", "id"]
144
+ properties:
145
+ type:
146
+ type: string
147
+ description: "Reference type indicator"
148
+ id:
149
+ type: string
150
+ description: "Unit identifier"
151
+ prefix_reference:
152
+ $ref: "#/definitions/PrefixReference"
153
+ description: "Optional prefix applied to the unit"
154
+
155
+ PrefixReference:
156
+ type: object
157
+ required: ["type", "id"]
158
+ properties:
159
+ type:
160
+ type: string
161
+ description: "Reference type indicator"
162
+ id:
163
+ type: string
164
+ description: "Prefix identifier"
165
+
166
+ # - latex: "\\ensuremath{\\mathrm{m}}"
167
+ # unicode: m
168
+ # ascii: m
169
+ # html: m
170
+ # id: m
171
+ # mathml: "<mi mathvariant='normal'>m</mi>"
172
+
173
+ Symbol:
174
+ type: object
175
+ required: ["latex", "unicode", "ascii", "html", "id", "mathml"]
176
+ description: "Mathematical and textual representations of the unit"
177
+ properties:
178
+ latex:
179
+ type: string
180
+ description: "LaTeX representation"
181
+ unicode:
182
+ type: string
183
+ description: "Unicode representation"
184
+ ascii:
185
+ type: string
186
+ description: "ASCII representation"
187
+ html:
188
+ type: string
189
+ description: "HTML representation"
190
+ id:
191
+ type: string
192
+ description: "Symbol identifier"
193
+ mathml:
194
+ type: string
195
+ description: "MathML representation"
196
+
197
+ Reference:
198
+ type: object
199
+ required: ["type"]
200
+ properties:
201
+ type:
202
+ type: string
203
+ enum: ["informative", "normative"]
204
+ description: "Type of reference"
205
+ authority:
206
+ type: string
207
+ description: "Authoritative body or organization"
208
+ enum: ["si-digital-framework", "qudt", "ucum", "nist"]
209
+ uri:
210
+ type: string
211
+ format: "uri"
212
+ description: "URI to the reference"
213
+ title:
214
+ type: string
215
+ description: "Title of the reference"
@@ -0,0 +1,78 @@
1
+ # yaml-language-server: $schema=schemas/unit_systems-schema.yaml
2
+ ---
3
+ schema_version: 2.0.0
4
+ unit_systems:
5
+ - acceptable: true
6
+ identifiers:
7
+ - type: nist
8
+ id: SI_base
9
+ - type: unitsml
10
+ id: us:si-base
11
+ names:
12
+ - value: SI base units
13
+ lang: en
14
+ references:
15
+ - type: informative
16
+ authority: qudt
17
+ uri: http://qudt.org/vocab/sou/SI
18
+ short: si-base
19
+ - acceptable: true
20
+ identifiers:
21
+ - type: nist
22
+ id: SI_compatible
23
+ - type: unitsml
24
+ id: us:si-compatible
25
+ names:
26
+ - value: Units compatible with SI
27
+ lang: en
28
+ short: si-compatible
29
+ - acceptable: true
30
+ identifiers:
31
+ - type: nist
32
+ id: SI_derived_non-special
33
+ - type: unitsml
34
+ id: us:si-derived-nonspecial
35
+ names:
36
+ - value: SI-derived units non-special
37
+ lang: en
38
+ short: si-derived-nonspecial
39
+ - acceptable: true
40
+ identifiers:
41
+ - type: nist
42
+ id: SI_derived_special
43
+ - type: unitsml
44
+ id: us:si-derived-special
45
+ names:
46
+ - value: SI-derived units special
47
+ lang: en
48
+ short: si-derived-special
49
+ - acceptable: true
50
+ identifiers:
51
+ - type: nist
52
+ id: non-SI_acceptable
53
+ - type: unitsml
54
+ id: us:nonsi-acceptable
55
+ names:
56
+ - value: non-SI but acceptable
57
+ lang: en
58
+ short: nonsi-acceptable
59
+ - acceptable: true
60
+ identifiers:
61
+ - type: nist
62
+ id: non-SI_nist_acceptable
63
+ - type: unitsml
64
+ id: us:nonsi-nist-acceptable
65
+ names:
66
+ - value: non-SI but acceptable by NIST SP 811
67
+ lang: en
68
+ short: nonsi-nist-acceptable
69
+ - acceptable: false
70
+ identifiers:
71
+ - type: nist
72
+ id: non-SI_not_acceptable
73
+ - type: unitsml
74
+ id: us:nonsi-unacceptable
75
+ names:
76
+ - value: non-SI and not acceptable
77
+ lang: en
78
+ short: nonsi-unacceptable