unitsml 0.6.0 → 0.6.2

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/.rubocop_todo.yml +97 -412
  4. data/Gemfile +15 -14
  5. data/Rakefile +2 -2
  6. data/bin/console +3 -3
  7. data/lib/unitsml/dimension.rb +3 -3
  8. data/lib/unitsml/errors.rb +2 -2
  9. data/lib/unitsml/extender.rb +9 -9
  10. data/lib/unitsml/fenced.rb +3 -3
  11. data/lib/unitsml/formula.rb +29 -20
  12. data/lib/unitsml/intermediate_exp_rules.rb +30 -20
  13. data/lib/unitsml/model/dimension.rb +1 -1
  14. data/lib/unitsml/model/dimension_quantities.rb +8 -4
  15. data/lib/unitsml/model/prefix.rb +1 -1
  16. data/lib/unitsml/model/prefixes/name.rb +2 -2
  17. data/lib/unitsml/model/prefixes/symbol.rb +1 -1
  18. data/lib/unitsml/model/quantities/name.rb +2 -2
  19. data/lib/unitsml/model/quantity.rb +2 -2
  20. data/lib/unitsml/model/unit.rb +1 -1
  21. data/lib/unitsml/model/units/name.rb +2 -2
  22. data/lib/unitsml/model/units/root_units.rb +1 -1
  23. data/lib/unitsml/model/units/symbol.rb +4 -2
  24. data/lib/unitsml/model/units/system.rb +2 -2
  25. data/lib/unitsml/model/units.rb +5 -5
  26. data/lib/unitsml/namespace.rb +2 -2
  27. data/lib/unitsml/number.rb +11 -11
  28. data/lib/unitsml/parse.rb +30 -19
  29. data/lib/unitsml/parser.rb +11 -11
  30. data/lib/unitsml/prefix.rb +6 -4
  31. data/lib/unitsml/transform.rb +26 -26
  32. data/lib/unitsml/unit.rb +8 -6
  33. data/lib/unitsml/unitsdb/dimension.rb +24 -12
  34. data/lib/unitsml/unitsdb/dimensions.rb +4 -0
  35. data/lib/unitsml/unitsdb/prefix_reference.rb +3 -1
  36. data/lib/unitsml/unitsdb/si_derived_base.rb +14 -0
  37. data/lib/unitsml/unitsdb/unit.rb +11 -3
  38. data/lib/unitsml/unitsdb/units.rb +4 -0
  39. data/lib/unitsml/unitsdb.rb +9 -19
  40. data/lib/unitsml/utility.rb +81 -70
  41. data/lib/unitsml/version.rb +1 -1
  42. data/lib/unitsml.rb +31 -31
  43. data/unitsml.gemspec +22 -19
  44. metadata +6 -23
  45. data/unitsdb/Gemfile +0 -6
  46. data/unitsdb/LICENSE.md +0 -53
  47. data/unitsdb/README.adoc +0 -1253
  48. data/unitsdb/RELEASE-NOTES.adoc +0 -269
  49. data/unitsdb/dimensions.yaml +0 -1864
  50. data/unitsdb/prefixes.yaml +0 -874
  51. data/unitsdb/quantities.yaml +0 -3715
  52. data/unitsdb/scales.yaml +0 -97
  53. data/unitsdb/schemas/README.md +0 -159
  54. data/unitsdb/schemas/dimensions-schema.yaml +0 -153
  55. data/unitsdb/schemas/prefixes-schema.yaml +0 -155
  56. data/unitsdb/schemas/quantities-schema.yaml +0 -117
  57. data/unitsdb/schemas/scales-schema.yaml +0 -106
  58. data/unitsdb/schemas/unit_systems-schema.yaml +0 -116
  59. data/unitsdb/schemas/units-schema.yaml +0 -215
  60. data/unitsdb/spec/units_spec.rb +0 -22
  61. data/unitsdb/unit_systems.yaml +0 -78
  62. data/unitsdb/units.yaml +0 -14052
  63. data/unitsdb/validate_schemas.rb +0 -203
@@ -1,106 +0,0 @@
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/scales-schema.yaml"
5
- title: "Scales Database Schema"
6
- description: "Schema for scales.yaml - defines measurement scales with their mathematical properties"
7
-
8
- type: object
9
- required: ["schema_version", "scales"]
10
- properties:
11
- schema_version:
12
- type: string
13
- pattern: "^\\d+\\.\\d+\\.\\d+$"
14
- description: "Semantic version of the schema"
15
- scales:
16
- type: array
17
- description: "Array of scale definitions"
18
- items:
19
- $ref: "#/definitions/Scale"
20
-
21
- definitions:
22
- Scale:
23
- type: object
24
- required: ["identifiers", "names", "properties"]
25
- properties:
26
- identifiers:
27
- type: array
28
- description: "External identifiers for this scale"
29
- items:
30
- $ref: "#/definitions/Identifier"
31
- names:
32
- type: array
33
- description: "Multilingual names for this scale"
34
- items:
35
- $ref: "#/definitions/Name"
36
- properties:
37
- $ref: "#/definitions/ScaleProperties"
38
- description: "Mathematical properties of the scale"
39
- references:
40
- type: array
41
- description: "External references and citations"
42
- items:
43
- $ref: "#/definitions/Reference"
44
-
45
- Identifier:
46
- type: object
47
- required: ["type", "id"]
48
- properties:
49
- type:
50
- type: string
51
- description: "Type of identifier system"
52
- id:
53
- type: string
54
- description: "Identifier value within the system"
55
-
56
- Name:
57
- type: object
58
- required: ["value", "lang"]
59
- properties:
60
- value:
61
- type: string
62
- description: "Name in the specified language"
63
- lang:
64
- type: string
65
- pattern: "^[a-z]{2}(-[A-Z]{2})?$"
66
- description: "Language code (ISO 639-1, optionally with ISO 3166-1 country)"
67
-
68
- ScaleProperties:
69
- type: object
70
- required: ["continuous", "ordered", "logarithmic", "interval", "ratio"]
71
- properties:
72
- continuous:
73
- type: boolean
74
- description: "Whether the scale is continuous"
75
- ordered:
76
- type: boolean
77
- description: "Whether the scale has an ordering"
78
- logarithmic:
79
- type: boolean
80
- description: "Whether the scale is logarithmic"
81
- interval:
82
- type: boolean
83
- description: "Whether the scale has meaningful intervals"
84
- ratio:
85
- type: boolean
86
- description: "Whether the scale has a meaningful zero point"
87
-
88
- Reference:
89
- type: object
90
- required: ["type"]
91
- properties:
92
- type:
93
- type: string
94
- enum: ["informative", "normative"]
95
- description: "Type of reference"
96
- authority:
97
- type: string
98
- description: "Authoritative body or organization"
99
- enum: ["si-digital-framework", "qudt", "ucum", "nist"]
100
- uri:
101
- type: string
102
- format: "uri"
103
- description: "URI to the reference"
104
- title:
105
- type: string
106
- description: "Title of the reference"
@@ -1,116 +0,0 @@
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"
@@ -1,215 +0,0 @@
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"
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "yaml"
4
- require "rspec"
5
- require "plurimath/math"
6
-
7
- describe "Validate MathML in UnitsDB" do
8
- unitsdb = YAML.load_file(File.join(__dir__, "../units.yaml"))
9
-
10
- unitsdb.each do |unit, unit_data|
11
- context "when parsing MathML for #{unit}" do
12
- it "parses successfully" do
13
- symbols = unit_data["symbols"].flatten.compact
14
- symbols.each do |symbols_hash|
15
- expect do
16
- Plurimath::Math.parse(symbols_hash["mathml"], :mathml)
17
- end.not_to raise_error
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,78 +0,0 @@
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