unitsml 0.6.0 → 0.6.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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/.rubocop_todo.yml +276 -279
  4. data/Gemfile +13 -13
  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 +6 -4
  34. data/lib/unitsml/unitsdb/dimensions.rb +4 -0
  35. data/lib/unitsml/unitsdb/unit.rb +2 -2
  36. data/lib/unitsml/unitsdb/units.rb +4 -0
  37. data/lib/unitsml/unitsdb.rb +8 -19
  38. data/lib/unitsml/utility.rb +81 -70
  39. data/lib/unitsml/version.rb +1 -1
  40. data/lib/unitsml.rb +31 -31
  41. data/unitsml.gemspec +22 -19
  42. metadata +5 -23
  43. data/unitsdb/Gemfile +0 -6
  44. data/unitsdb/LICENSE.md +0 -53
  45. data/unitsdb/README.adoc +0 -1253
  46. data/unitsdb/RELEASE-NOTES.adoc +0 -269
  47. data/unitsdb/dimensions.yaml +0 -1864
  48. data/unitsdb/prefixes.yaml +0 -874
  49. data/unitsdb/quantities.yaml +0 -3715
  50. data/unitsdb/scales.yaml +0 -97
  51. data/unitsdb/schemas/README.md +0 -159
  52. data/unitsdb/schemas/dimensions-schema.yaml +0 -153
  53. data/unitsdb/schemas/prefixes-schema.yaml +0 -155
  54. data/unitsdb/schemas/quantities-schema.yaml +0 -117
  55. data/unitsdb/schemas/scales-schema.yaml +0 -106
  56. data/unitsdb/schemas/unit_systems-schema.yaml +0 -116
  57. data/unitsdb/schemas/units-schema.yaml +0 -215
  58. data/unitsdb/spec/units_spec.rb +0 -22
  59. data/unitsdb/unit_systems.yaml +0 -78
  60. data/unitsdb/units.yaml +0 -14052
  61. data/unitsdb/validate_schemas.rb +0 -203
@@ -4,29 +4,29 @@ module Unitsml
4
4
  module Utility
5
5
  # Unit to dimension
6
6
  U2D = {
7
- 'm' => { dimension: 'Length', order: 1, symbol: 'L' },
8
- 'g' => { dimension: 'Mass', order: 2, symbol: 'M' },
9
- 'kg' => { dimension: 'Mass', order: 2, symbol: 'M' },
10
- 's' => { dimension: 'Time', order: 3, symbol: 'T' },
11
- 'A' => { dimension: 'ElectricCurrent', order: 4, symbol: 'I' },
12
- 'K' => { dimension: 'ThermodynamicTemperature', order: 5,
13
- symbol: 'Theta' },
14
- 'degK' => { dimension: 'ThermodynamicTemperature', order: 5,
15
- symbol: 'Theta' },
16
- 'mol' => { dimension: 'AmountOfSubstance', order: 6, symbol: 'N' },
17
- 'cd' => { dimension: 'LuminousIntensity', order: 7, symbol: 'J' },
18
- 'deg' => { dimension: 'PlaneAngle', order: 8, symbol: 'phi' }
7
+ "m" => { dimension: "Length", order: 1, symbol: "L" },
8
+ "g" => { dimension: "Mass", order: 2, symbol: "M" },
9
+ "kg" => { dimension: "Mass", order: 2, symbol: "M" },
10
+ "s" => { dimension: "Time", order: 3, symbol: "T" },
11
+ "A" => { dimension: "ElectricCurrent", order: 4, symbol: "I" },
12
+ "K" => { dimension: "ThermodynamicTemperature", order: 5,
13
+ symbol: "Theta" },
14
+ "degK" => { dimension: "ThermodynamicTemperature", order: 5,
15
+ symbol: "Theta" },
16
+ "mol" => { dimension: "AmountOfSubstance", order: 6, symbol: "N" },
17
+ "cd" => { dimension: "LuminousIntensity", order: 7, symbol: "J" },
18
+ "deg" => { dimension: "PlaneAngle", order: 8, symbol: "phi" },
19
19
  }.freeze
20
20
  # Dimesion for dim_(dimesion) input
21
21
  DIM2D = {
22
- 'dim_L' => U2D['m'],
23
- 'dim_M' => U2D['g'],
24
- 'dim_T' => U2D['s'],
25
- 'dim_I' => U2D['A'],
26
- 'dim_Theta' => U2D['K'],
27
- 'dim_N' => U2D['mol'],
28
- 'dim_J' => U2D['cd'],
29
- 'dim_phi' => U2D['deg']
22
+ "dim_L" => U2D["m"],
23
+ "dim_M" => U2D["g"],
24
+ "dim_T" => U2D["s"],
25
+ "dim_I" => U2D["A"],
26
+ "dim_Theta" => U2D["K"],
27
+ "dim_N" => U2D["mol"],
28
+ "dim_J" => U2D["cd"],
29
+ "dim_phi" => U2D["deg"],
30
30
  }.freeze
31
31
  DIMS_VECTOR = %w[
32
32
  ThermodynamicTemperature
@@ -39,7 +39,7 @@ module Unitsml
39
39
  Time
40
40
  ].freeze
41
41
 
42
- UNKNOWN = 'unknown'
42
+ UNKNOWN = "unknown"
43
43
 
44
44
  class << self
45
45
  def unit_instance(unit)
@@ -52,7 +52,9 @@ module Unitsml
52
52
 
53
53
  def units2dimensions(units)
54
54
  norm = decompose_units_list(units)
55
- return if norm.any? { |u| u.nil? || u[:unit]&.unknown_name? || u[:prefix] == UNKNOWN }
55
+ return if norm.any? do |u|
56
+ u.nil? || u[:unit]&.unknown_name? || u[:prefix] == UNKNOWN
57
+ end
56
58
 
57
59
  norm.map do |u|
58
60
  unit_name = u[:unit].unit_name
@@ -60,7 +62,7 @@ module Unitsml
60
62
  dimension: U2D[unit_name][:dimension],
61
63
  unit: unit_name,
62
64
  exponent: u[:unit].power_numerator || 1,
63
- symbol: U2D[unit_name][:symbol]
65
+ symbol: U2D[unit_name][:symbol],
64
66
  }
65
67
  end.sort { |a, b| U2D[a[:unit]][:order] <=> U2D[b[:unit]][:order] }
66
68
  end
@@ -68,14 +70,16 @@ module Unitsml
68
70
  def dim_id(dims)
69
71
  return nil if dims.nil? || dims.empty?
70
72
 
71
- dim_hash = dims.each_with_object({}) { |h, m| m[h[:dimension]] = h }
72
- dims_vector = DIMS_VECTOR.map { |h| dim_hash.dig(h, :exponent) }.join(':')
73
+ dim_hash = dims.to_h { |h| [h[:dimension], h] }
74
+ dims_vector = DIMS_VECTOR.map do |h|
75
+ dim_hash.dig(h, :exponent)
76
+ end.join(":")
73
77
  id = Unitsdb.dimensions.find_by_vector(dims_vector)&.id and return id.to_s
74
78
 
75
- 'D_' + dims.map do |d|
79
+ "D_" + dims.map do |d|
76
80
  (U2D.dig(d[:unit], :symbol) || DIM2D.dig(d[:id], :symbol)) +
77
- (to_i_value(d[:exponent]) == 1 ? '' : float_to_display(d[:exponent]))
78
- end.join('')
81
+ (to_i_value(d[:exponent]) == 1 ? "" : float_to_display(d[:exponent]))
82
+ end.join
79
83
  end
80
84
 
81
85
  def to_i_value(object)
@@ -90,16 +94,17 @@ module Unitsml
90
94
  end
91
95
 
92
96
  def decompose_unit(u)
93
- if u&.unit_name == 'g' || Lutaml::Model::Utils.snake_case(u.system_type) == 'si_base'
97
+ if u&.unit_name == "g" || Lutaml::Model::Utils.snake_case(u.system_type) == "si_base"
94
98
  { unit: u, prefix: u&.prefix }
95
99
  elsif u.si_derived_bases.nil? || u.si_derived_bases.empty?
96
100
  { unit: Unit.new(UNKNOWN) }
97
101
  else
98
102
  u.si_derived_bases.each_with_object([]) do |k, object|
99
- prefix = if !k.prefix_reference.nil?
100
- combine_prefixes(prefix_object(k.prefix_reference), u.prefix)
101
- else
103
+ prefix = if k.prefix_reference.nil?
102
104
  u.prefix
105
+ else
106
+ combine_prefixes(prefix_object(k.prefix_reference),
107
+ u.prefix)
103
108
  end
104
109
  unit_name = Unitsdb.units.find_by_id(k.unit_reference.id).symbols.first.id
105
110
  exponent = (k.power&.to_i || 1) * (u.power_numerator&.to_f || 1)
@@ -116,8 +121,9 @@ module Unitsml
116
121
  else
117
122
  m[-1][:unit]&.power_numerator = Number.new(numerator_value(k, m))
118
123
  m[-1] = {
119
- prefix: combine_prefixes(prefix_object(m[-1][:prefix]), prefix_object(k[:prefix])),
120
- unit: m[-1][:unit]
124
+ prefix: combine_prefixes(prefix_object(m[-1][:prefix]),
125
+ prefix_object(k[:prefix])),
126
+ unit: m[-1][:unit],
121
127
  }
122
128
  end
123
129
  end
@@ -159,16 +165,16 @@ module Unitsml
159
165
  system: unitsystem(units),
160
166
  name: unitname(norm_text, name),
161
167
  symbol: unitsymbols(formula, options),
162
- root_units: rootunits(units)
168
+ root_units: rootunits(units),
163
169
  }
164
170
  attributes[:dimension_url] = "##{dim_id(dims)}" if dims
165
171
  Model::Unit.new(attributes).to_xml
166
- .force_encoding('UTF-8')
167
- .gsub('&lt;', '<')
168
- .gsub('&gt;', '>')
169
- .gsub('&amp;', '&')
170
- .gsub(/−/, '&#x2212;')
171
- .gsub(/⋅/, '&#x22c5;')
172
+ .force_encoding("UTF-8")
173
+ .gsub("&lt;", "<")
174
+ .gsub("&gt;", ">")
175
+ .gsub("&amp;", "&")
176
+ .gsub(/−/, "&#x2212;")
177
+ .gsub(/⋅/, "&#x22c5;")
172
178
  end
173
179
 
174
180
  def unitname(text, name)
@@ -180,20 +186,21 @@ module Unitsml
180
186
  %w[HTML MathMl].map do |lang|
181
187
  Model::Units::Symbol.new(
182
188
  type: lang,
183
- content: formula.public_send(:"to_#{lang.downcase}", options)
189
+ content: formula.public_send(:"to_#{lang.downcase}", options),
184
190
  )
185
191
  end
186
192
  end
187
193
 
188
194
  def unitsystem(units)
189
195
  ret = []
190
- ret << Model::Units::System.new(name: 'not_SI', type: 'not_SI') if units.any? { |u| !u.si_system_type? }
196
+ ret << Model::Units::System.new(name: "not_SI", type: "not_SI") if units.any? { |u| !u.si_system_type? }
191
197
  if units.any?(&:si_system_type?)
192
198
  if units.size == 1
193
- base = units[0].downcase_system_type == 'si_base'
194
- base = true if units[0].unit_name == 'g' && units[0]&.prefix_name == 'k'
199
+ base = units[0].downcase_system_type == "si_base"
200
+ base = true if units[0].unit_name == "g" && units[0]&.prefix_name == "k"
195
201
  end
196
- ret << Model::Units::System.new(name: 'SI', type: (base ? 'SI_base' : 'SI_derived'))
202
+ ret << Model::Units::System.new(name: "SI",
203
+ type: (base ? "SI_base" : "SI_derived"))
197
204
  end
198
205
  ret
199
206
  end
@@ -204,7 +211,7 @@ module Unitsml
204
211
 
205
212
  dim_attrs = { id: dim_id }
206
213
  dimid2dimensions(dim_id)&.compact&.each { |u| dimension1(u, dim_attrs) }
207
- Model::Dimension.new(dim_attrs).to_xml.force_encoding('UTF-8')
214
+ Model::Dimension.new(dim_attrs).to_xml.force_encoding("UTF-8")
208
215
  end
209
216
 
210
217
  def dimension1(dim, dims_hash)
@@ -212,14 +219,14 @@ module Unitsml
212
219
  dim_klass = Model::DimensionQuantities.const_get(dim_name)
213
220
  dims_hash[underscore(dim_name).to_sym] = dim_klass.new(
214
221
  symbol: dim[:symbol],
215
- power_numerator: float_to_display(dim[:exponent])
222
+ power_numerator: float_to_display(dim[:exponent]),
216
223
  )
217
224
  end
218
225
 
219
226
  def float_to_display(float)
220
227
  case float
221
228
  when Integer, Float
222
- float.to_f.round(1).to_s.sub(/\.0$/, '')
229
+ float.to_f.round(1).to_s.sub(/\.0$/, "")
223
230
  when Number, Fenced
224
231
  float.float_to_display
225
232
  end
@@ -228,31 +235,35 @@ module Unitsml
228
235
  def dimid2dimensions(normtext)
229
236
  dims = Unitsdb.dimensions.find_by_id(normtext)
230
237
  dims&.processed_keys&.map do |processed_key|
231
- humanized = processed_key.split('_').map(&:capitalize).join
238
+ humanized = processed_key.split("_").map(&:capitalize).join
232
239
  next unless DIMS_VECTOR.include?(humanized)
233
240
 
234
241
  dim_quantity = dims.public_send(processed_key)
235
242
  {
236
243
  dimension: humanized,
237
244
  symbol: dim_quantity.symbol,
238
- exponent: dim_quantity.power
245
+ exponent: dim_quantity.power,
239
246
  }
240
247
  end
241
248
  end
242
249
 
243
250
  def prefixes(units, options)
244
- uniq_prefixes = units.map(&:prefix).compact.uniq(&:prefix_name)
251
+ uniq_prefixes = units.filter_map(&:prefix).uniq(&:prefix_name)
245
252
  uniq_prefixes.map do |prefix|
246
- prefix_attrs = { prefix_base: prefix&.base, prefix_power: prefix&.power, id: prefix&.id }
247
- type_and_methods = { ASCII: :to_asciimath, unicode: :to_unicode, LaTeX: :to_latex, HTML: :to_html }
253
+ prefix_attrs = { prefix_base: prefix&.base,
254
+ prefix_power: prefix&.power, id: prefix&.id }
255
+ type_and_methods = { ASCII: :to_asciimath, unicode: :to_unicode,
256
+ LaTeX: :to_latex, HTML: :to_html }
248
257
  prefix_attrs[:name] = Model::Prefixes::Name.new(content: prefix&.name)
249
258
  prefix_attrs[:symbol] = type_and_methods.map do |type, method_name|
250
259
  Model::Prefixes::Symbol.new(
251
260
  type: type,
252
- content: prefix&.public_send(method_name, options)
261
+ content: prefix&.public_send(method_name, options),
253
262
  )
254
263
  end
255
- Model::Prefix.new(prefix_attrs).to_xml.force_encoding('UTF-8').gsub('&amp;', '&')
264
+ Model::Prefix.new(prefix_attrs).to_xml.force_encoding("UTF-8").gsub(
265
+ "&amp;", "&"
266
+ )
256
267
  end.join("\n")
257
268
  end
258
269
 
@@ -262,7 +273,7 @@ module Unitsml
262
273
  enum_root_units = units.map do |unit|
263
274
  attributes = { unit: unit.enumerated_name }
264
275
  attributes[:prefix] = unit.prefix_name if unit.prefix
265
- unit.power_numerator && unit.power_numerator != '1' and
276
+ unit.power_numerator && unit.power_numerator != "1" and
266
277
  attributes[:power_numerator] = unit.power_numerator.raw_value
267
278
  Model::Units::EnumeratedRootUnit.new(attributes)
268
279
  end
@@ -270,16 +281,16 @@ module Unitsml
270
281
  end
271
282
 
272
283
  def unit_id(text)
273
- text = text&.gsub(/[()]/, '')
284
+ text = text&.gsub(/[()]/, "")
274
285
  unit = unit_instance(text)
275
286
 
276
- format_unit_id(unit, text)&.insert(0, 'U_')
287
+ format_unit_id(unit, text)&.insert(0, "U_")
277
288
  end
278
289
 
279
290
  def format_unit_id(unit, text)
280
- return unit.nist_id&.gsub(/'/, '_') if unit
291
+ return unit.nist_id&.gsub("'", "_") if unit
281
292
 
282
- text&.gsub(/\*/, '.')&.gsub(/\^/, '')
293
+ text&.gsub("*", ".")&.gsub("^", "")
283
294
  end
284
295
 
285
296
  def dimension_components(dims)
@@ -287,7 +298,7 @@ module Unitsml
287
298
 
288
299
  dim_attrs = { id: dim_id(dims) }
289
300
  dims.map { |u| dimension1(u, dim_attrs) }
290
- Model::Dimension.new(dim_attrs).to_xml.force_encoding('UTF-8')
301
+ Model::Dimension.new(dim_attrs).to_xml.force_encoding("UTF-8")
291
302
  end
292
303
 
293
304
  def quantity(normtext, instance)
@@ -296,12 +307,12 @@ module Unitsml
296
307
 
297
308
  model_quantity_xml(
298
309
  instance || unit.quantity_references&.first&.id,
299
- "##{unit.dimension_url}"
310
+ "##{unit.dimension_url}",
300
311
  )
301
312
  end
302
313
 
303
314
  def unit_or_quantity(unit, quantity)
304
- unit && unit.quantity_references.size == 1 ||
315
+ (unit && unit.quantity_references.size == 1) ||
305
316
  quantity_instance(quantity)
306
317
  end
307
318
 
@@ -309,13 +320,13 @@ module Unitsml
309
320
  Model::Quantity.new(
310
321
  id: id,
311
322
  name: quantity_name(id),
312
- dimension_url: url
313
- ).to_xml.force_encoding('UTF-8')
323
+ dimension_url: url,
324
+ ).to_xml.force_encoding("UTF-8")
314
325
  end
315
326
 
316
327
  def quantity_name(id)
317
328
  quantity_instance(id)&.names&.filter_map do |name|
318
- next unless name.lang == 'en'
329
+ next unless name.lang == "en"
319
330
 
320
331
  Model::Quantities::Name.new(content: name.value)
321
332
  end
@@ -323,8 +334,8 @@ module Unitsml
323
334
 
324
335
  def string_to_html_entity(string)
325
336
  HTMLEntities.new.encode(
326
- string.frozen? ? string : string.force_encoding('UTF-8'),
327
- :hexadecimal
337
+ string.frozen? ? string : string.force_encoding("UTF-8"),
338
+ :hexadecimal,
328
339
  )
329
340
  end
330
341
 
@@ -339,7 +350,7 @@ module Unitsml
339
350
  def set_to_fence(set)
340
351
  return set if set.is_a?(Fenced)
341
352
 
342
- Fenced.new('(', set, ')')
353
+ Fenced.new("(", set, ")")
343
354
  end
344
355
  end
345
356
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Unitsml
4
- VERSION = '0.6.0'
4
+ VERSION = "0.6.1"
5
5
  end
data/lib/unitsml.rb CHANGED
@@ -1,30 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lutaml/model'
4
- require 'unitsdb'
3
+ require "lutaml/model"
4
+ require "unitsdb"
5
5
 
6
6
  module Unitsml
7
7
  module_function
8
8
 
9
- autoload :Dimension, 'unitsml/dimension'
10
- autoload :Errors, 'unitsml/errors'
11
- autoload :Extender, 'unitsml/extender'
12
- autoload :Fenced, 'unitsml/fenced'
13
- autoload :FencedNumeric, 'unitsml/fenced_numeric'
14
- autoload :Formula, 'unitsml/formula'
15
- autoload :IntermediateExpRules, 'unitsml/intermediate_exp_rules'
16
- autoload :Model, 'unitsml/model'
17
- autoload :Namespace, 'unitsml/namespace'
18
- autoload :Number, 'unitsml/number'
19
- autoload :Parse, 'unitsml/parse'
20
- autoload :Parser, 'unitsml/parser'
21
- autoload :Prefix, 'unitsml/prefix'
22
- autoload :Sqrt, 'unitsml/sqrt'
23
- autoload :Transform, 'unitsml/transform'
24
- autoload :Unit, 'unitsml/unit'
25
- autoload :Unitsdb, 'unitsml/unitsdb'
26
- autoload :Utility, 'unitsml/utility'
27
- autoload :VERSION, 'unitsml/version'
9
+ autoload :Dimension, "unitsml/dimension"
10
+ autoload :Errors, "unitsml/errors"
11
+ autoload :Extender, "unitsml/extender"
12
+ autoload :Fenced, "unitsml/fenced"
13
+ autoload :FencedNumeric, "unitsml/fenced_numeric"
14
+ autoload :Formula, "unitsml/formula"
15
+ autoload :IntermediateExpRules, "unitsml/intermediate_exp_rules"
16
+ autoload :Model, "unitsml/model"
17
+ autoload :Namespace, "unitsml/namespace"
18
+ autoload :Number, "unitsml/number"
19
+ autoload :Parse, "unitsml/parse"
20
+ autoload :Parser, "unitsml/parser"
21
+ autoload :Prefix, "unitsml/prefix"
22
+ autoload :Sqrt, "unitsml/sqrt"
23
+ autoload :Transform, "unitsml/transform"
24
+ autoload :Unit, "unitsml/unit"
25
+ autoload :Unitsdb, "unitsml/unitsdb"
26
+ autoload :Utility, "unitsml/utility"
27
+ autoload :VERSION, "unitsml/version"
28
28
 
29
29
  REGISTER_ID = :unitsml_ruby
30
30
 
@@ -47,22 +47,22 @@ module Unitsml
47
47
  def register_type_substitution(from:, to:)
48
48
  register.register_global_type_substitution(
49
49
  from_type: from,
50
- to_type: to
50
+ to_type: to,
51
51
  )
52
52
  end
53
53
  end
54
54
 
55
55
  Lutaml::Model::GlobalRegister.register(
56
- Lutaml::Model::Register.new(Unitsml::REGISTER_ID)
56
+ Lutaml::Model::Register.new(Unitsml::REGISTER_ID),
57
57
  )
58
58
 
59
59
  {
60
- ::Unitsdb::Unit => Unitsml::Unitsdb::Unit,
61
- ::Unitsdb::Units => Unitsml::Unitsdb::Units,
62
- ::Unitsdb::Prefixes => Unitsml::Unitsdb::Prefixes,
63
- ::Unitsdb::Dimension => Unitsml::Unitsdb::Dimension,
64
- ::Unitsdb::PrefixReference => Unitsml::Unitsdb::PrefixReference,
65
- ::Unitsdb::DimensionDetails => Unitsml::Unitsdb::DimensionQuantity
60
+ Unitsdb::Unit => Unitsml::Unitsdb::Unit,
61
+ Unitsdb::Units => Unitsml::Unitsdb::Units,
62
+ Unitsdb::Prefixes => Unitsml::Unitsdb::Prefixes,
63
+ Unitsdb::Dimension => Unitsml::Unitsdb::Dimension,
64
+ Unitsdb::PrefixReference => Unitsml::Unitsdb::PrefixReference,
65
+ Unitsdb::DimensionDetails => Unitsml::Unitsdb::DimensionQuantity,
66
66
  }.each do |key, value|
67
67
  Unitsml.register_type_substitution(from: key, to: value)
68
68
  end
@@ -71,9 +71,9 @@ end
71
71
  [Unitsml::Unitsdb::Dimensions, :unitsdb_dimensions],
72
72
  [Unitsml::Unitsdb::Prefixes, :unitsdb_prefixes],
73
73
  [Unitsml::Unitsdb::Quantities, :unitsdb_quantities],
74
- [Unitsml::Unitsdb::Units, :unitsdb_units]
74
+ [Unitsml::Unitsdb::Units, :unitsdb_units],
75
75
  ].each { |klass, id| Unitsml.register_model(klass, id: id) }
76
76
 
77
77
  Lutaml::Model::Config.configure do |config|
78
- config.xml_adapter_type = RUBY_ENGINE == 'opal' ? :oga : :ox
78
+ config.xml_adapter_type = RUBY_ENGINE == "opal" ? :oga : :ox
79
79
  end
data/unitsml.gemspec CHANGED
@@ -1,37 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/unitsml/version'
3
+ require_relative "lib/unitsml/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'unitsml'
6
+ spec.name = "unitsml"
7
7
  spec.version = Unitsml::VERSION
8
- spec.authors = ['Ribose Inc.']
9
- spec.email = ['open.source@ribose.com']
8
+ spec.authors = ["Ribose Inc."]
9
+ spec.email = ["open.source@ribose.com"]
10
10
 
11
- spec.summary = 'UnitsML in Ruby'
12
- spec.description = 'Library to work with UnitsML in Ruby'
11
+ spec.summary = "UnitsML in Ruby"
12
+ spec.description = "Library to work with UnitsML in Ruby"
13
13
 
14
- spec.homepage = 'https://github.com/unitsml/unitsml-ruby'
15
- spec.license = 'BSD-2-Clause'
14
+ spec.homepage = "https://github.com/unitsml/unitsml-ruby"
15
+ spec.license = "BSD-2-Clause"
16
16
 
17
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
17
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
18
18
 
19
- spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["rubygems_mfa_required"] = "true"
20
21
 
21
22
  # Specify which files should be added to the gem when it is released.
22
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
24
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
25
28
  end
26
- spec.files += Dir.glob('unitsdb/**/*')
29
+ spec.files += Dir.glob("unitsdb/**/*")
27
30
 
28
- spec.bindir = 'exe'
31
+ spec.bindir = "exe"
29
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ['lib', 'unitsdb/**/*.yaml']
33
+ spec.require_paths = ["lib", "unitsdb/**/*.yaml"]
31
34
 
32
- spec.add_dependency 'htmlentities'
33
- spec.add_dependency 'lutaml-model', '~> 0.8.0'
34
- spec.add_dependency 'mml'
35
- spec.add_dependency 'parslet'
36
- spec.add_dependency 'unitsdb', '~> 2.0'
35
+ spec.add_dependency "htmlentities"
36
+ spec.add_dependency "lutaml-model", "~> 0.8.0"
37
+ spec.add_dependency "mml"
38
+ spec.add_dependency "parslet"
39
+ spec.add_dependency "unitsdb", "~> 2.2.1"
37
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.0
4
+ version: 0.6.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: 2026-04-01 00:00:00.000000000 Z
11
+ date: 2026-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: 2.2.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: 2.2.1
83
83
  description: Library to work with UnitsML in Ruby
84
84
  email:
85
85
  - open.source@ribose.com
@@ -159,31 +159,13 @@ files:
159
159
  - lib/unitsml/unitsdb/units.rb
160
160
  - lib/unitsml/utility.rb
161
161
  - lib/unitsml/version.rb
162
- - unitsdb/Gemfile
163
- - unitsdb/LICENSE.md
164
- - unitsdb/README.adoc
165
- - unitsdb/RELEASE-NOTES.adoc
166
- - unitsdb/dimensions.yaml
167
- - unitsdb/prefixes.yaml
168
- - unitsdb/quantities.yaml
169
- - unitsdb/scales.yaml
170
- - unitsdb/schemas/README.md
171
- - unitsdb/schemas/dimensions-schema.yaml
172
- - unitsdb/schemas/prefixes-schema.yaml
173
- - unitsdb/schemas/quantities-schema.yaml
174
- - unitsdb/schemas/scales-schema.yaml
175
- - unitsdb/schemas/unit_systems-schema.yaml
176
- - unitsdb/schemas/units-schema.yaml
177
- - unitsdb/spec/units_spec.rb
178
- - unitsdb/unit_systems.yaml
179
- - unitsdb/units.yaml
180
- - unitsdb/validate_schemas.rb
181
162
  - unitsml.gemspec
182
163
  homepage: https://github.com/unitsml/unitsml-ruby
183
164
  licenses:
184
165
  - BSD-2-Clause
185
166
  metadata:
186
167
  homepage_uri: https://github.com/unitsml/unitsml-ruby
168
+ rubygems_mfa_required: 'true'
187
169
  post_install_message:
188
170
  rdoc_options: []
189
171
  require_paths:
data/unitsdb/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "json-schema"
6
- gem "unitsdb"
data/unitsdb/LICENSE.md DELETED
@@ -1,53 +0,0 @@
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.