unitsdb 1.0.0 → 2.0.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/.rspec +2 -1
  4. data/.rubocop_todo.yml +168 -15
  5. data/Gemfile +3 -2
  6. data/README.adoc +803 -1
  7. data/exe/unitsdb +7 -0
  8. data/lib/unitsdb/cli.rb +88 -0
  9. data/lib/unitsdb/commands/_modify.rb +22 -0
  10. data/lib/unitsdb/commands/base.rb +26 -0
  11. data/lib/unitsdb/commands/check_si.rb +124 -0
  12. data/lib/unitsdb/commands/get.rb +133 -0
  13. data/lib/unitsdb/commands/normalize.rb +81 -0
  14. data/lib/unitsdb/commands/release.rb +73 -0
  15. data/lib/unitsdb/commands/search.rb +219 -0
  16. data/lib/unitsdb/commands/si_formatter.rb +485 -0
  17. data/lib/unitsdb/commands/si_matcher.rb +470 -0
  18. data/lib/unitsdb/commands/si_ttl_parser.rb +100 -0
  19. data/lib/unitsdb/commands/si_updater.rb +212 -0
  20. data/lib/unitsdb/commands/ucum/check.rb +126 -0
  21. data/lib/unitsdb/commands/ucum/formatter.rb +141 -0
  22. data/lib/unitsdb/commands/ucum/matcher.rb +301 -0
  23. data/lib/unitsdb/commands/ucum/update.rb +84 -0
  24. data/lib/unitsdb/commands/ucum/updater.rb +98 -0
  25. data/lib/unitsdb/commands/ucum/xml_parser.rb +34 -0
  26. data/lib/unitsdb/commands/ucum.rb +43 -0
  27. data/lib/unitsdb/commands/validate/identifiers.rb +42 -0
  28. data/lib/unitsdb/commands/validate/references.rb +318 -0
  29. data/lib/unitsdb/commands/validate/si_references.rb +109 -0
  30. data/lib/unitsdb/commands/validate.rb +40 -0
  31. data/lib/unitsdb/database.rb +662 -0
  32. data/lib/unitsdb/dimension.rb +49 -0
  33. data/lib/unitsdb/dimension_details.rb +20 -0
  34. data/lib/unitsdb/dimension_reference.rb +8 -0
  35. data/lib/unitsdb/dimensions.rb +5 -10
  36. data/lib/unitsdb/errors.rb +13 -0
  37. data/lib/unitsdb/external_reference.rb +14 -0
  38. data/lib/unitsdb/identifier.rb +8 -0
  39. data/lib/unitsdb/localized_string.rb +17 -0
  40. data/lib/unitsdb/prefix.rb +30 -0
  41. data/lib/unitsdb/prefix_reference.rb +10 -0
  42. data/lib/unitsdb/prefixes.rb +5 -11
  43. data/lib/unitsdb/quantities.rb +5 -31
  44. data/lib/unitsdb/quantity.rb +21 -0
  45. data/lib/unitsdb/quantity_reference.rb +10 -0
  46. data/lib/unitsdb/root_unit_reference.rb +14 -0
  47. data/lib/unitsdb/scale.rb +17 -0
  48. data/lib/unitsdb/scale_properties.rb +12 -0
  49. data/lib/unitsdb/scale_reference.rb +10 -0
  50. data/lib/unitsdb/scales.rb +12 -0
  51. data/lib/unitsdb/si_derived_base.rb +19 -0
  52. data/lib/unitsdb/symbol_presentations.rb +3 -8
  53. data/lib/unitsdb/ucum.rb +198 -0
  54. data/lib/unitsdb/unit.rb +63 -0
  55. data/lib/unitsdb/unit_reference.rb +10 -0
  56. data/lib/unitsdb/unit_system.rb +15 -0
  57. data/lib/unitsdb/unit_system_reference.rb +10 -0
  58. data/lib/unitsdb/unit_systems.rb +5 -10
  59. data/lib/unitsdb/units.rb +5 -10
  60. data/lib/unitsdb/utils.rb +84 -0
  61. data/lib/unitsdb/version.rb +1 -1
  62. data/lib/unitsdb.rb +12 -2
  63. data/unitsdb.gemspec +6 -3
  64. metadata +124 -20
  65. data/lib/unitsdb/dimensions/dimension.rb +0 -59
  66. data/lib/unitsdb/dimensions/quantity.rb +0 -32
  67. data/lib/unitsdb/dimensions/symbol.rb +0 -26
  68. data/lib/unitsdb/prefixes/prefix.rb +0 -35
  69. data/lib/unitsdb/prefixes/symbol.rb +0 -17
  70. data/lib/unitsdb/quantities/quantity.rb +0 -37
  71. data/lib/unitsdb/quantities/unit_reference.rb +0 -15
  72. data/lib/unitsdb/unit_systems/unit_system.rb +0 -19
  73. data/lib/unitsdb/units/quantity_reference.rb +0 -17
  74. data/lib/unitsdb/units/root_unit.rb +0 -21
  75. data/lib/unitsdb/units/root_units.rb +0 -18
  76. data/lib/unitsdb/units/si_derived_base.rb +0 -26
  77. data/lib/unitsdb/units/symbol.rb +0 -19
  78. data/lib/unitsdb/units/system.rb +0 -17
  79. data/lib/unitsdb/units/unit.rb +0 -73
  80. data/lib/unitsdb/unitsdb.rb +0 -6
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "unit_reference"
4
-
5
- # # Quantities
6
- # NISTq156:
7
- # dimension_url: "#NISTd68"
8
- # quantity_type: derived
9
- # quantity_name:
10
- # - linear expansion coefficient
11
- # unit_reference:
12
- # - name: kelvin to the power minus one
13
- # url: "#NISTu5e-1/1"
14
-
15
- # NISTq155:
16
- # dimension_url: "#NISTd57"
17
- # quantity_type: derived
18
- # quantity_name:
19
- # - area moment of inertia
20
- # - second moment of area
21
- # unit_reference:
22
- # - name: inch to the fourth power
23
- # url: "#NISTu208"
24
-
25
- module Unitsdb
26
- class Quantities
27
- class Quantity < Lutaml::Model::Serializable
28
- model Config.model_for(:quantity)
29
-
30
- attribute :id, :string
31
- attribute :dimension_url, :string
32
- attribute :quantity_type, :string
33
- attribute :quantity_name, :string, collection: true
34
- attribute :unit_reference, UnitReference, collection: true
35
- end
36
- end
37
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Unitsdb
4
- class Quantities
5
- class UnitReference < Lutaml::Model::Serializable
6
- attribute :name, :string
7
- attribute :url, :string
8
-
9
- key_value do
10
- map :name, to: :name
11
- map :url, to: :url
12
- end
13
- end
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Unitsdb
4
- class UnitSystems
5
- class UnitSystem < Lutaml::Model::Serializable
6
- model Config.model_for(:unit_system)
7
-
8
- attribute :id, :string
9
- attribute :name, :string
10
- attribute :acceptable, :boolean
11
-
12
- key_value do
13
- map :id, to: :id
14
- map :name, to: :name
15
- map :acceptable, to: :acceptable
16
- end
17
- end
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Unitsdb
4
- class Units
5
- class QuantityReference < Lutaml::Model::Serializable
6
- model Config.model_for(:quantity_reference)
7
-
8
- attribute :name, :string
9
- attribute :url, :string
10
-
11
- key_value do
12
- map :name, to: :name
13
- map :url, to: :url
14
- end
15
- end
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Unitsdb
4
- class Units
5
- class RootUnit < Lutaml::Model::Serializable
6
- model Config.model_for(:root_unit)
7
-
8
- attribute :unit, :string
9
- attribute :power_denominator, :integer
10
- attribute :power_numerator, :integer
11
- attribute :prefix, :string
12
-
13
- key_value do
14
- map :unit, to: :unit
15
- map :power_denominator, to: :power_denominator
16
- map :power_numerator, to: :power_numerator
17
- map :prefix, to: :prefix
18
- end
19
- end
20
- end
21
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "root_unit"
4
-
5
- module Unitsdb
6
- class Units
7
- class RootUnits < Lutaml::Model::Serializable
8
- model Config.model_for(:root_units)
9
-
10
- attribute :enumerated_root_units, RootUnit, collection: true
11
-
12
- key_value do
13
- map :enumerated_root_units,
14
- to: :enumerated_root_units
15
- end
16
- end
17
- end
18
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # - id: NISTu1
4
- # prefix:
5
- # power: 1
6
- # - id: NISTu1
7
- # prefix:
8
- # power: -1
9
-
10
- module Unitsdb
11
- class Units
12
- class SiDerivedBase < Lutaml::Model::Serializable
13
- model Config.model_for(:si_deribed_base)
14
-
15
- attribute :id, :string
16
- attribute :prefix, :string
17
- attribute :power, :integer
18
-
19
- key_value do
20
- map :id, to: :id
21
- map :prefix, to: :prefix, render_nil: true
22
- map :power, to: :power
23
- end
24
- end
25
- end
26
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../symbol_presentations"
4
-
5
- module Unitsdb
6
- class Units
7
- class Symbol < SymbolPresentations
8
- model Config.model_for(:unit_symbol)
9
-
10
- attribute :id, :string
11
- attribute :mathml, :string
12
-
13
- key_value do
14
- map :id, to: :id
15
- map :mathml, to: :mathml
16
- end
17
- end
18
- end
19
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Unitsdb
4
- class Units
5
- class System < Lutaml::Model::Serializable
6
- model Config.model_for(:system)
7
-
8
- attribute :name, :string
9
- attribute :type, :string
10
-
11
- key_value do
12
- map :type, to: :type
13
- map :name, to: :name
14
- end
15
- end
16
- end
17
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "symbol"
4
- require_relative "system"
5
- require_relative "root_units"
6
- require_relative "si_derived_base"
7
- require_relative "quantity_reference"
8
-
9
- # "NISTu10":
10
- # dimension_url: "#NISTd9"
11
- # short: steradian
12
- # root: true
13
- # unit_system:
14
- # type: "SI_derived_special"
15
- # name: "SI"
16
- # unit_name:
17
- # - "steradian"
18
- # unit_symbols:
19
- # - id: "sr"
20
- # ascii: "sr"
21
- # html: "sr"
22
- # mathml: "<mi mathvariant='normal'>sr</mi>"
23
- # latex: \ensuremath{\mathrm{sr}}
24
- # unicode: "sr"
25
- # root_units:
26
- # enumerated_root_units:
27
- # - unit: "steradian"
28
- # power_denominator: 1
29
- # power_numerator: 1
30
- # quantity_reference:
31
- # - name: "solid angle"
32
- # url: "#NISTq11"
33
- # si_derived_bases:
34
- # - id: NISTu1
35
- # prefix:
36
- # power: 1
37
- # - id: NISTu1
38
- # prefix:
39
- # power: -1
40
-
41
- module Unitsdb
42
- class Units
43
- class Unit < Lutaml::Model::Serializable
44
- model Config.model_for(:unit)
45
-
46
- attribute :id, :string
47
- attribute :short, :string
48
- attribute :root, :boolean
49
- attribute :prefixed, :boolean
50
- attribute :dimension_url, :string
51
- attribute :unit_system, System
52
- attribute :unit_name, :string, collection: true
53
- attribute :unit_symbols, Symbol, collection: true
54
- attribute :root_units, RootUnits, collection: true
55
- attribute :quantity_reference, QuantityReference, collection: true
56
- attribute :si_derived_bases, SiDerivedBase, collection: true
57
-
58
- key_value do
59
- map :id, to: :id
60
- map :dimension_url, to: :dimension_url
61
- map :short, to: :short, render_nil: true
62
- map :root, to: :root
63
- map :prefixed, to: :prefixed
64
- map :unit_system, to: :unit_system
65
- map :unit_name, to: :unit_name
66
- map :unit_symbols, to: :unit_symbols
67
- map :root_units, to: :root_units
68
- map :quantity_reference, to: :quantity_reference
69
- map :si_derived_bases, to: :si_derived_bases
70
- end
71
- end
72
- end
73
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Unitsdb
4
- class Error < StandardError; end
5
- # Your code goes here...
6
- end