unitsml 0.4.7 → 0.5.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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.adoc +104 -2
  3. data/lib/unitsml/dimension.rb +1 -1
  4. data/lib/unitsml/fenced.rb +77 -0
  5. data/lib/unitsml/formula.rb +21 -8
  6. data/lib/unitsml/intermediate_exp_rules.rb +35 -0
  7. data/lib/unitsml/parse.rb +16 -25
  8. data/lib/unitsml/parser.rb +19 -4
  9. data/lib/unitsml/prefix.rb +10 -10
  10. data/lib/unitsml/transform.rb +31 -0
  11. data/lib/unitsml/unit.rb +29 -7
  12. data/lib/unitsml/unitsdb/dimension.rb +12 -18
  13. data/lib/unitsml/unitsdb/dimension_quantity.rb +2 -6
  14. data/lib/unitsml/unitsdb/dimensions.rb +4 -8
  15. data/lib/unitsml/unitsdb/prefix_reference.rb +23 -0
  16. data/lib/unitsml/unitsdb/prefixes.rb +19 -5
  17. data/lib/unitsml/unitsdb/quantities.rb +6 -4
  18. data/lib/unitsml/unitsdb/unit.rb +21 -0
  19. data/lib/unitsml/unitsdb/units.rb +20 -17
  20. data/lib/unitsml/unitsdb.rb +8 -4
  21. data/lib/unitsml/utility.rb +36 -44
  22. data/lib/unitsml/version.rb +1 -1
  23. data/lib/unitsml.rb +34 -16
  24. data/unitsdb/LICENSE.md +53 -0
  25. data/unitsdb/README.adoc +1071 -0
  26. data/unitsdb/RELEASE-NOTES.adoc +269 -0
  27. data/unitsdb/dimensions.yaml +1255 -602
  28. data/unitsdb/prefixes.yaml +742 -301
  29. data/unitsdb/quantities.yaml +3104 -2458
  30. data/unitsdb/scales.yaml +97 -0
  31. data/unitsdb/schemas/README.md +159 -0
  32. data/unitsdb/schemas/dimensions-schema.yaml +157 -0
  33. data/unitsdb/schemas/prefixes-schema.yaml +159 -0
  34. data/unitsdb/schemas/quantities-schema.yaml +120 -0
  35. data/unitsdb/schemas/scales-schema.yaml +109 -0
  36. data/unitsdb/schemas/unit_systems-schema.yaml +120 -0
  37. data/unitsdb/schemas/units-schema.yaml +219 -0
  38. data/unitsdb/spec/units_spec.rb +11 -10
  39. data/unitsdb/unit_systems.yaml +73 -15
  40. data/unitsdb/units.yaml +12566 -9974
  41. data/unitsdb/validate_schemas.rb +208 -0
  42. data/unitsml.gemspec +2 -1
  43. metadata +34 -6
  44. data/unitsdb/docs/README.adoc +0 -12
  45. data/unitsdb/docs/navigation.adoc +0 -7
@@ -2,24 +2,14 @@
2
2
 
3
3
  module Unitsml
4
4
  module Unitsdb
5
- class Dimension
6
- attr_accessor :vector,
7
- :id,
8
- :dimensionless
9
-
10
- attr_reader :length,
11
- :mass,
12
- :time,
13
- :electric_current,
14
- :thermodynamic_temperature,
15
- :amount_of_substance,
16
- :luminous_intensity,
17
- :plane_angle,
18
- :parsables,
5
+ class Dimension < ::Unitsdb::Dimension
6
+ attr_reader :parsables,
19
7
  :parsable,
20
- :processed_keys
8
+ :processed_keys,
9
+ :vector
21
10
 
22
- def initialize
11
+ def initialize(attrs)
12
+ super
23
13
  @parsables = {}
24
14
  @processed_keys = []
25
15
  @parsable = false
@@ -67,10 +57,14 @@ module Unitsml
67
57
 
68
58
  def set_vector
69
59
  @vector ||= Utility::DIMS_VECTOR.map do |h|
70
- public_send(Utility.underscore(h))&.power_numerator
60
+ public_send(Utility.underscore(h))&.power
71
61
  end.join(":")
72
62
  end
73
63
 
64
+ def id
65
+ identifiers.find { |id| id.type == "nist" }&.id
66
+ end
67
+
74
68
  private
75
69
 
76
70
  def quantities_common_code(instance_var, value)
@@ -78,7 +72,7 @@ module Unitsml
78
72
 
79
73
  instance_variable_set(:"@#{instance_var}", value)
80
74
  @processed_keys << instance_var.to_s
81
- return if value.dim_symbols.nil? || value.dim_symbols.empty?
75
+ return if Lutaml::Model::Utils.empty?(value.symbols)
82
76
 
83
77
  @parsable = true
84
78
  value.dim_symbols_ids(@parsables, id)
@@ -2,13 +2,9 @@
2
2
 
3
3
  module Unitsml
4
4
  module Unitsdb
5
- class DimensionQuantity
6
- attr_accessor :power_numerator,
7
- :symbol,
8
- :dim_symbols
9
-
5
+ class DimensionQuantity < ::Unitsdb::DimensionDetails
10
6
  def dim_symbols_ids(hash, dim_id)
11
- dim_symbols.each { |dim_sym| hash[dim_sym.id] = dim_id }
7
+ symbols&.each { |dim_sym| hash[dim_sym.id] = dim_id }
12
8
  end
13
9
  end
14
10
  end
@@ -2,11 +2,9 @@
2
2
 
3
3
  module Unitsml
4
4
  module Unitsdb
5
- class Dimensions
6
- attr_accessor :dimensions
7
-
5
+ class Dimensions < ::Unitsdb::Dimensions
8
6
  def find_by_vector(vector)
9
- vectored
7
+ @vectored ||= dimensions.each(&:set_vector)
10
8
  find(:vector, vector)
11
9
  end
12
10
 
@@ -26,13 +24,11 @@ module Unitsml
26
24
 
27
25
  private
28
26
 
29
- def vectored
30
- @vectored ||= dimensions.each(&:set_vector)
31
- end
32
-
33
27
  def find(field, matching_data)
34
28
  dimensions.find { |dim| dim.send(field) == matching_data }
35
29
  end
36
30
  end
37
31
  end
38
32
  end
33
+
34
+ Unitsml.register.register_model(Unitsml::Unitsdb::Dimensions, id: :unitsdb_dimensions)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsml
4
+ module Unitsdb
5
+ class PrefixReference < ::Unitsdb::PrefixReference
6
+ def base
7
+ prefix.base
8
+ end
9
+
10
+ def symbolid
11
+ prefix.symbols.first.ascii
12
+ end
13
+
14
+ def power
15
+ prefix.power
16
+ end
17
+
18
+ def prefix
19
+ @prefix ||= Unitsdb.prefixes.find_by_id(id)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -2,21 +2,35 @@
2
2
 
3
3
  module Unitsml
4
4
  module Unitsdb
5
- class Prefixes
6
- attr_accessor :prefixes
5
+ class Prefixes < ::Unitsdb::Prefixes
6
+ def find_by_id(p_id)
7
+ find(p_id, :id, :identifiers)
8
+ end
7
9
 
8
10
  def find_by_symbol_name(ascii_sym)
9
- prefixes.find { |prefix| prefix.symbol.ascii == ascii_sym }
11
+ find(ascii_sym, :ascii, :symbols)
10
12
  end
11
13
 
12
14
  def ascii_symbols
13
15
  prefixes.each_with_object([]) do |prefix, names_array|
14
- symbol = prefix.symbol.ascii
16
+ symbol = prefix.symbols.map(&:ascii)
15
17
  next if symbol.empty?
16
18
 
17
- names_array << symbol
19
+ names_array.concat(symbol)
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def find(matching_data, field, prefix_method)
26
+ prefixes.find do |prefix|
27
+ prefix.public_send(prefix_method.to_sym).find do |object|
28
+ object.public_send(field) == matching_data
29
+ end
18
30
  end
19
31
  end
20
32
  end
21
33
  end
22
34
  end
35
+
36
+ Unitsml.register.register_model(Unitsml::Unitsdb::Prefixes, id: :unitsdb_prefixes)
@@ -2,12 +2,14 @@
2
2
 
3
3
  module Unitsml
4
4
  module Unitsdb
5
- class Quantities
6
- attr_accessor :quantities
7
-
5
+ class Quantities < ::Unitsdb::Quantities
8
6
  def find_by_id(q_id)
9
- quantities.find { |quantity| quantity.id == q_id }
7
+ quantities.find do |quantity|
8
+ quantity.identifiers.find { |id| id.id == q_id }
9
+ end
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
+
15
+ Unitsml.register.register_model(Unitsml::Unitsdb::Quantities, id: :unitsdb_quantities)
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsml
4
+ module Unitsdb
5
+ class Unit < ::Unitsdb::Unit
6
+ def dimension_url
7
+ quantity_id = quantity_references[0].id
8
+ quantity = Unitsdb.quantities.find_by_id(quantity_id)
9
+ quantity.dimension_reference.id
10
+ end
11
+
12
+ def en_name
13
+ names.find { |name| name.lang == "en" }&.value
14
+ end
15
+
16
+ def nist_id
17
+ identifiers.find { |id| id.type == "nist" }&.id
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,43 +2,46 @@
2
2
 
3
3
  module Unitsml
4
4
  module Unitsdb
5
- class Units
6
- attr_accessor :units
7
-
5
+ class Units < ::Unitsdb::Units
8
6
  def find_by_id(u_id)
9
- units.find { |unit| unit.id == u_id }
7
+ find(u_id, :id, :identifiers)
10
8
  end
11
9
 
12
10
  def find_by_name(u_name)
13
- units.find do |unit|
14
- unit.unit_symbols.find { |u_sym| u_sym.id == u_name }
15
- end
11
+ find(u_name, :id, :symbols)
16
12
  end
17
13
 
18
14
  def filtered
19
- @filtered ||= units_symbol_ids.reject do |unit|
15
+ @filtered ||= symbols_ids.reject do |unit|
20
16
  ((/\*|\^|\/|^1$/).match?(unit) || find_by_symbol_id(unit).prefixed)
21
17
  end
22
18
  end
23
19
 
24
20
  def find_by_symbol_id(sym_id)
25
- units_symbol_hash[sym_id]
21
+ symbols_hash[sym_id]
22
+ end
23
+
24
+ def symbols_ids
25
+ symbols_hash.keys
26
26
  end
27
27
 
28
- def units_symbol_ids
29
- units_symbol_hash.keys
28
+ def symbols_hash
29
+ @symbol_ids_hash ||= units.each_with_object({}) do |unit, object|
30
+ unit.symbols&.each { |unit_sym| object[unit_sym.id] = unit }
31
+ end
30
32
  end
31
33
 
32
- def units_symbol_hash
33
- @symbol_ids_hash ||= {}
34
+ private
34
35
 
35
- if @symbol_ids_hash.empty?
36
- units.each_with_object(@symbol_ids_hash) do |unit, object|
37
- unit.unit_symbols.each { |unit_sym| object[unit_sym.id] = unit }
36
+ def find(matching_data, field, unit_method)
37
+ units.find do |unit|
38
+ unit.public_send(unit_method.to_sym).find do |id|
39
+ id.public_send(field) == matching_data
38
40
  end
39
41
  end
40
- @symbol_ids_hash
41
42
  end
42
43
  end
43
44
  end
44
45
  end
46
+
47
+ Unitsml.register.register_model(Unitsml::Unitsdb::Units, id: :unitsdb_units)
@@ -9,19 +9,19 @@ module Unitsml
9
9
  end
10
10
 
11
11
  def units
12
- @@units_file ||= ::Unitsdb::Units.from_yaml(load_file(:units))
12
+ @@units_file ||= get_class_from_register(:unitsdb_units).from_yaml(load_file(:units))
13
13
  end
14
14
 
15
15
  def prefixes
16
- @@prefixes ||= ::Unitsdb::Prefixes.from_yaml(load_file(:prefixes))
16
+ @@prefixes ||= get_class_from_register(:unitsdb_prefixes).from_yaml(load_file(:prefixes))
17
17
  end
18
18
 
19
19
  def dimensions
20
- @@dim_file ||= ::Unitsdb::Dimensions.from_yaml(load_file(:dimensions))
20
+ @@dim_file ||= get_class_from_register(:unitsdb_dimensions).from_yaml(load_file(:dimensions))
21
21
  end
22
22
 
23
23
  def quantities
24
- @@quantities ||= ::Unitsdb::Quantities.from_yaml(load_file(:quantities))
24
+ @@quantities ||= get_class_from_register(:unitsdb_quantities).from_yaml(load_file(:quantities))
25
25
  end
26
26
 
27
27
  def prefixes_array
@@ -40,6 +40,10 @@ module Unitsml
40
40
  File.join(__dir__, "..", "..","unitsdb", "#{file_name}.yaml")
41
41
  )
42
42
  end
43
+
44
+ def get_class_from_register(class_name)
45
+ Unitsml.register.get_class(class_name)
46
+ end
43
47
  end
44
48
  end
45
49
  end
@@ -74,6 +74,7 @@ module Unitsml
74
74
  dim_hash = dims.each_with_object({}) { |h, m| m[h[:dimension]] = h }
75
75
  dims_vector = DIMS_VECTOR.map { |h| dim_hash.dig(h, :exponent) }.join(":")
76
76
  id = Unitsdb.dimensions.find_by_vector(dims_vector)&.id and return id.to_s
77
+
77
78
  "D_" + dims.map do |d|
78
79
  (U2D.dig(d[:unit], :symbol) || Dim2D.dig(d[:id], :symbol)) +
79
80
  (d[:exponent] == 1 ? "" : float_to_display(d[:exponent]))
@@ -85,18 +86,18 @@ module Unitsml
85
86
  end
86
87
 
87
88
  def decompose_unit(u)
88
- if u&.unit_name == "g" || u.system_type == "SI_base"
89
+ if u&.unit_name == "g" || Lutaml::Model::Utils.snake_case(u.system_type) == "si_base"
89
90
  { unit: u, prefix: u&.prefix }
90
91
  elsif u.si_derived_bases.nil? || u.si_derived_bases.empty?
91
92
  { unit: Unit.new("unknown") }
92
93
  else
93
94
  u.si_derived_bases.each_with_object([]) do |k, object|
94
- prefix = if !k.prefix.nil? && !k.prefix.empty?
95
- combine_prefixes(prefix_object(k.prefix), u.prefix)
95
+ prefix = if !k.prefix_reference.nil?
96
+ combine_prefixes(prefix_object(k.prefix_reference), u.prefix)
96
97
  else
97
98
  u.prefix
98
99
  end
99
- unit_name = Unitsdb.units.find_by_id(k.id).unit_symbols.first.id
100
+ unit_name = Unitsdb.units.find_by_id(k.unit_reference.id).symbols.first.id
100
101
  exponent = (k.power&.to_i || 1) * (u.power_numerator&.to_f || 1)
101
102
  object << { prefix: prefix,
102
103
  unit: Unit.new(unit_name, exponent, prefix: prefix),
@@ -144,7 +145,7 @@ module Unitsml
144
145
  attributes = {
145
146
  id: unit_id(norm_text),
146
147
  system: unitsystem(units),
147
- name: unitname(units, norm_text, name),
148
+ name: unitname(norm_text, name),
148
149
  symbol: unitsymbols(formula, options),
149
150
  root_units: rootunits(units),
150
151
  }
@@ -157,34 +158,28 @@ module Unitsml
157
158
  .gsub(/⋅/, "&#x22c5;")
158
159
  end
159
160
 
160
- def unitname(units, text, name)
161
- Model::Units::Name.new(
162
- name: unit_instance(text)&.unit_name&.first || text
163
- )
164
- end
165
-
166
- def postprocess_normtext(units)
167
- units.map { |u| "#{u.prefix_name}#{u.unit_name}#{display_exp(u)}" }.join("*")
168
- end
169
-
170
- def display_exp(unit)
171
- unit.power_numerator && unit.power_numerator != "1" ? "^#{unit.power_numerator}" : ""
161
+ def unitname(text, name)
162
+ name ||= unit_instance(text)&.en_name || text
163
+ Model::Units::Name.new(name: name)
172
164
  end
173
165
 
174
166
  def unitsymbols(formula, options)
175
167
  %w[HTML MathMl].map do |lang|
176
- Model::Units::Symbol.new(type: lang, content: formula.public_send(:"to_#{lang.downcase}", options))
168
+ Model::Units::Symbol.new(
169
+ type: lang,
170
+ content: formula.public_send(:"to_#{lang.downcase}", options),
171
+ )
177
172
  end
178
173
  end
179
174
 
180
175
  def unitsystem(units)
181
176
  ret = []
182
- if units.any? { |u| u.system_name != "SI" }
177
+ if units.any? { |u| !u.si_system_type? }
183
178
  ret << Model::Units::System.new(name: "not_SI", type: "not_SI")
184
179
  end
185
- if units.any? { |u| u.system_name == "SI" }
180
+ if units.any?(&:si_system_type?)
186
181
  if units.size == 1
187
- base = units[0].system_type == "SI-base"
182
+ base = units[0].downcase_system_type == "si_base"
188
183
  base = true if units[0].unit_name == "g" && units[0]&.prefix_name == "k"
189
184
  end
190
185
  ret << Model::Units::System.new(name: "SI", type: (base ? 'SI_base' : 'SI_derived'))
@@ -193,10 +188,9 @@ module Unitsml
193
188
  end
194
189
 
195
190
  def dimension(norm_text)
196
- dim_url = unit_instance(norm_text)&.dimension_url
197
- return unless dim_url
191
+ dim_id = unit_instance(norm_text)&.dimension_url
192
+ return unless dim_id
198
193
 
199
- dim_id = dim_url.sub("#", '')
200
194
  dim_attrs = { id: dim_id }
201
195
  dimid2dimensions(dim_id)&.compact&.each { |u| dimension1(u, dim_attrs) }
202
196
  Model::Dimension.new(dim_attrs).to_xml
@@ -225,13 +219,13 @@ module Unitsml
225
219
  {
226
220
  dimension: humanized,
227
221
  symbol: dim_quantity.symbol,
228
- exponent: dim_quantity.power_numerator,
222
+ exponent: dim_quantity.power,
229
223
  }
230
224
  end
231
225
  end
232
226
 
233
227
  def prefixes(units, options)
234
- uniq_prefixes = units.map { |unit| unit.prefix }.compact.uniq {|d| d.prefix_name }
228
+ uniq_prefixes = units.map { |unit| unit.prefix }.compact.uniq { |d| d.prefix_name }
235
229
  uniq_prefixes.map do |prefix|
236
230
  prefix_attrs = { prefix_base: prefix&.base, prefix_power: prefix&.power, id: prefix&.id }
237
231
  type_and_methods = { ASCII: :to_asciimath, unicode: :to_unicode, LaTeX: :to_latex, HTML: :to_html }
@@ -260,10 +254,10 @@ module Unitsml
260
254
  end
261
255
 
262
256
  def unit_id(text)
263
- norm_text = text
264
257
  text = text&.gsub(/[()]/, "")
265
- unit = unit_instance(norm_text)
266
- "U_#{unit ? unit.id&.gsub(/'/, '_') : norm_text&.gsub(/\*/, '.')&.gsub(/\^/, '')}"
258
+ unit = unit_instance(text)
259
+
260
+ "U_#{unit ? unit.nist_id&.gsub(/'/, '_') : text&.gsub(/\*/, '.')&.gsub(/\^/, '')}"
267
261
  end
268
262
 
269
263
  def dimension_components(dims)
@@ -276,41 +270,39 @@ module Unitsml
276
270
 
277
271
  def quantity(normtext, quantity)
278
272
  unit = unit_instance(normtext)
279
- return unless unit && unit.quantity_reference.size == 1 ||
273
+ return unless unit && unit.quantity_references.size == 1 ||
280
274
  quantity_instance(quantity)
281
275
 
282
- id = (quantity || unit.quantity_reference&.first&.url).sub('#', '')
283
- dim_url = unit.dimension_url
284
- attributes = { id: id, name: quantity_name(id), dimension_url: dim_url }
285
- Model::Quantity.new(attributes).to_xml
276
+ id = (quantity || unit.quantity_references&.first&.id)
277
+ Model::Quantity.new(
278
+ id: id,
279
+ name: quantity_name(id),
280
+ dimension_url: "##{unit.dimension_url}",
281
+ ).to_xml
286
282
  end
287
283
 
288
284
  def quantity_name(id)
289
- quantity_instance(id)&.quantity_name&.map do |content|
290
- Model::Quantities::Name.new(content: content)
285
+ quantity_instance(id)&.names&.filter_map do |name|
286
+ next unless name.lang == "en"
287
+
288
+ Model::Quantities::Name.new(content: name.value)
291
289
  end
292
290
  end
293
291
 
294
292
  def string_to_html_entity(string)
295
- entities = HTMLEntities.new
296
- entities.encode(
293
+ HTMLEntities.new.encode(
297
294
  string.frozen? ? string : string.force_encoding('UTF-8'),
298
295
  :hexadecimal,
299
296
  )
300
297
  end
301
298
 
302
299
  def html_entity_to_unicode(string)
303
- entities = HTMLEntities.new
304
- entities.decode(string)
300
+ HTMLEntities.new.decode(string)
305
301
  end
306
302
 
307
303
  def underscore(str)
308
304
  str.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
309
305
  end
310
-
311
- def class_name(klass)
312
- klass.name.split("::").last
313
- end
314
306
  end
315
307
  end
316
308
  end
@@ -1,3 +1,3 @@
1
1
  module Unitsml
2
- VERSION = "0.4.7"
2
+ VERSION = "0.5.1"
3
3
  end
data/lib/unitsml.rb CHANGED
@@ -1,43 +1,61 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "lutaml/model"
3
4
  module Unitsml
4
- UNITSML_NS = "https://schema.unitsml.org/unitsml/1.0".freeze
5
+ extend self
5
6
 
6
- def self.parse(string)
7
+ UNITSML_NS = "https://schema.unitsml.org/unitsml/1.0"
8
+ REGISTER_ID = :unitsml_ruby
9
+
10
+ def parse(string)
7
11
  Unitsml::Parser.new(string).parse
8
12
  end
13
+
14
+ def register
15
+ @register ||= Lutaml::Model::GlobalRegister.lookup(REGISTER_ID)
16
+ end
9
17
  end
10
18
 
19
+ Lutaml::Model::GlobalRegister.register(
20
+ Lutaml::Model::Register.new(Unitsml::REGISTER_ID)
21
+ )
22
+
23
+ require "unitsdb"
11
24
  require "unitsml/error"
12
25
  require "unitsml/sqrt"
13
26
  require "unitsml/unit"
14
27
  require "unitsml/parse"
15
28
  require "unitsml/parser"
16
29
  require "unitsml/prefix"
30
+ require "unitsml/fenced"
17
31
  require "unitsml/formula"
18
32
  require "unitsml/version"
19
33
  require "unitsml/unitsdb"
20
34
  require "unitsml/extender"
21
35
  require "unitsml/dimension"
22
36
  require "unitsml/transform"
37
+ require "unitsml/unitsdb/unit"
23
38
  require "unitsml/unitsdb/units"
24
39
  require "unitsml/unitsdb/prefixes"
25
40
  require "unitsml/unitsdb/dimension"
26
41
  require "unitsml/unitsdb/dimensions"
27
42
  require "unitsml/unitsdb/quantities"
43
+ require "unitsml/unitsdb/prefix_reference"
28
44
  require "unitsml/unitsdb/dimension_quantity"
29
- require "unitsdb/config"
30
- Unitsdb::Config.models = {
31
- units: Unitsml::Unitsdb::Units,
32
- prefixes: Unitsml::Unitsdb::Prefixes,
33
- dimension: Unitsml::Unitsdb::Dimension,
34
- dimensions: Unitsml::Unitsdb::Dimensions,
35
- quantities: Unitsml::Unitsdb::Quantities,
36
- dimension_quantity: Unitsml::Unitsdb::DimensionQuantity,
37
- }
38
- require "unitsdb"
39
45
 
40
- DEFAULT_XML_ADAPTER = RUBY_ENGINE == "opal" ? :oga : :ox
41
- Lutaml::Model::Config.xml_adapter_type = DEFAULT_XML_ADAPTER
42
- # TODO: Remove Moxml adapter assignment when Lutaml::Model utilizes Moxml completely
43
- Moxml::Config.default_adapter = DEFAULT_ADAPTER
46
+ {
47
+ ::Unitsdb::Unit => Unitsml::Unitsdb::Unit,
48
+ ::Unitsdb::Units => Unitsml::Unitsdb::Units,
49
+ ::Unitsdb::Prefixes => Unitsml::Unitsdb::Prefixes,
50
+ ::Unitsdb::Dimension => Unitsml::Unitsdb::Dimension,
51
+ ::Unitsdb::PrefixReference => Unitsml::Unitsdb::PrefixReference,
52
+ ::Unitsdb::DimensionDetails => Unitsml::Unitsdb::DimensionQuantity,
53
+ }.each do |key, value|
54
+ Unitsml.register
55
+ .register_global_type_substitution(
56
+ from_type: key,
57
+ to_type: value,
58
+ )
59
+ end
60
+
61
+ Lutaml::Model::Config.xml_adapter_type = RUBY_ENGINE == "opal" ? :oga : :ox
@@ -0,0 +1,53 @@
1
+ Licenses & Copyright
2
+ ====================
3
+
4
+ This license file adheres to the formatting guidelines of
5
+ [readable-licenses](https://github.com/nevir/readable-licenses).
6
+
7
+
8
+ CalConnect MIT License
9
+ ----------------------
10
+
11
+ Copyright 2020-2025, CalConnect
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
14
+ this software and associated documentation files (the “Software”), to deal in
15
+ the Software without restriction, including without limitation the rights to
16
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
17
+ the Software, and to permit persons to whom the Software is furnished to do so,
18
+ subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
26
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
27
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
+
30
+
31
+ NIST Public Domain Notice (SPDX: NIST-PD)
32
+ -----------------------------------------
33
+
34
+ This software was developed by employees of the National Institute of Standards
35
+ and Technology (NIST), and others.
36
+
37
+ This software has been contributed to the public domain.
38
+
39
+ Pursuant to title 15 Untied States Code Section 105, works of NIST employees are
40
+ not subject to copyright protection in the United States and are considered to
41
+ be in the public domain.
42
+
43
+ As a result, a formal license is not needed to use this software.
44
+
45
+ This software is provided "AS IS."
46
+
47
+ NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING,
48
+ WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
49
+ PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY.
50
+
51
+ NIST does not warrant or make any representations regarding the use of the
52
+ software or the results thereof, including but not limited to the correctness,
53
+ accuracy, reliability or usefulness of this software.