unitsdb 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-repos.json +5 -0
  3. data/.github/workflows/depenedent-gems.yml +16 -0
  4. data/.rubocop.yml +2 -0
  5. data/.rubocop_todo.yml +35 -0
  6. data/Gemfile +1 -1
  7. data/lib/unitsdb/config.rb +19 -0
  8. data/lib/unitsdb/dimensions/dimension.rb +59 -0
  9. data/lib/unitsdb/dimensions/quantity.rb +32 -0
  10. data/lib/unitsdb/dimensions/symbol.rb +26 -0
  11. data/lib/unitsdb/dimensions.rb +18 -0
  12. data/lib/unitsdb/prefixes/prefix.rb +35 -0
  13. data/lib/unitsdb/prefixes/symbol.rb +17 -0
  14. data/lib/unitsdb/prefixes.rb +29 -0
  15. data/lib/unitsdb/quantities/quantity.rb +37 -0
  16. data/lib/unitsdb/quantities/unit_reference.rb +15 -0
  17. data/lib/unitsdb/{quantity.rb → quantities.rb} +14 -9
  18. data/lib/unitsdb/{symbol.rb → symbol_presentations.rb} +5 -1
  19. data/lib/unitsdb/unit_systems/unit_system.rb +19 -0
  20. data/lib/unitsdb/unit_systems.rb +14 -10
  21. data/lib/unitsdb/units/quantity_reference.rb +17 -0
  22. data/lib/unitsdb/units/root_unit.rb +21 -0
  23. data/lib/unitsdb/units/root_units.rb +18 -0
  24. data/lib/unitsdb/units/si_derived_base.rb +26 -0
  25. data/lib/unitsdb/units/symbol.rb +19 -0
  26. data/lib/unitsdb/units/system.rb +17 -0
  27. data/lib/unitsdb/units/unit.rb +73 -0
  28. data/lib/unitsdb/units.rb +10 -5
  29. data/lib/unitsdb/version.rb +1 -1
  30. data/lib/unitsdb.rb +6 -10
  31. metadata +26 -16
  32. data/Gemfile.lock +0 -104
  33. data/lib/unitsdb/dimension.rb +0 -27
  34. data/lib/unitsdb/dimension_symbol.rb +0 -20
  35. data/lib/unitsdb/prefix.rb +0 -29
  36. data/lib/unitsdb/prefix_symbol.rb +0 -10
  37. data/lib/unitsdb/root_unit.rb +0 -15
  38. data/lib/unitsdb/root_units.rb +0 -7
  39. data/lib/unitsdb/si_derived_base.rb +0 -18
  40. data/lib/unitsdb/unit.rb +0 -64
  41. data/lib/unitsdb/unit_symbol.rb +0 -13
  42. data/lib/unitsdb/unit_system.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cc59f72cf82c8470435a6301b122e6a8f5fc17e97b67f7356a1978242abf85e
4
- data.tar.gz: 8f9b1f7210647662b46ba51cd152181ea070e49c766829265ef83e090930cef2
3
+ metadata.gz: 5a036c803ba8da7f845b70007e7472b55cf85f7a9de544c7b685fe34801f5876
4
+ data.tar.gz: 4f3911a631032c2fe688bbd33b49158f09feb88f2208106af5d022c9ecd57562
5
5
  SHA512:
6
- metadata.gz: 314d79de0bf13287ad60702c59a77989ed0e2a870d3bc30dc82f28eacb0958075abe681e3b271695ae0f15f8bfb9dd9a8ee3e8f48860cdf4d82ebe9026919609
7
- data.tar.gz: a8989534b950c382fa387819bec1e1a7f0dbf2ada67bff1e9640788d863440f070182c755e76da8e0db1c90b0980cde444366d61fe0312f1c55c29ecd33a8546
6
+ metadata.gz: 446489baaa5df1b34402c43ca00354ec222cb4cd9e96aab1e5815c8716c2330ce37ad995a7f5f63d55e02c0eef7170a238928ef539c54a9bf426eeb58099e4ba
7
+ data.tar.gz: 3be2b704e450eb09b37dec01d500ad4bfbaf1c669513bc31e1ad124c17252b9dd77ad42df2c3aa71b19b8a09aa656b47ce2f2ebe1b25c5146f1871e6afa9dee5
@@ -0,0 +1,5 @@
1
+ {
2
+ "repo": [
3
+ "unitsml/unitsml-ruby"
4
+ ]
5
+ }
@@ -0,0 +1,16 @@
1
+ name: dependent-gems-test
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ tags: [ v* ]
7
+ pull_request:
8
+ workflow_dispatch:
9
+ repository_dispatch:
10
+ types: [ release-passed ]
11
+
12
+ jobs:
13
+ rake:
14
+ uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
15
+ with:
16
+ command: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 3.0
3
5
 
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,35 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-01-11 04:48:38 UTC using RuboCop version 1.70.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Severity, Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/DuplicatedAssignment:
13
+ Exclude:
14
+ - 'unitsdb.gemspec'
15
+
16
+ # Offense count: 2
17
+ # This cop supports safe autocorrection (--autocorrect).
18
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
19
+ # SupportedStyles: special_inside_parentheses, consistent, align_braces
20
+ Layout/FirstHashElementIndentation:
21
+ Exclude:
22
+ - 'lib/unitsdb/units.rb'
23
+
24
+ # Offense count: 19
25
+ # Configuration parameters: AllowedConstants.
26
+ Style/Documentation:
27
+ Enabled: false
28
+
29
+ # Offense count: 1
30
+ # This cop supports safe autocorrection (--autocorrect).
31
+ # Configuration parameters: EnforcedStyleForMultiline.
32
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
33
+ Style/TrailingCommaInHashLiteral:
34
+ Exclude:
35
+ - 'lib/unitsdb/units.rb'
data/Gemfile CHANGED
@@ -5,8 +5,8 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in suma.gemspec
6
6
  gemspec
7
7
 
8
+ gem "diffy"
8
9
  gem "rake", "~> 13.0"
9
10
  gem "rspec", "~> 3.0"
10
11
  gem "rubocop"
11
12
  gem "rubocop-performance"
12
- gem "rubocop-rails"
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsdb
4
+ class Config
5
+ class << self
6
+ def models
7
+ @models ||= {}
8
+ end
9
+
10
+ def models=(user_models)
11
+ models.merge!(user_models)
12
+ end
13
+
14
+ def model_for(model_name)
15
+ models[model_name]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "quantity"
4
+ # NISTd1:
5
+ # length:
6
+ # powerNumerator: 1
7
+ # symbol: L
8
+ # dim_symbols:
9
+ # - id: "dim_L"
10
+ # ascii: "L"
11
+ # html: "&#x1D5AB;"
12
+ # mathml: "<mi mathvariant='sans-serif'>L</mi>"
13
+ # latex: \ensuremath{\mathsf{L}}
14
+ # unicode: "𝖫"
15
+
16
+ # NISTd9:
17
+ # -dimensionless: true
18
+ # -plane_angle:
19
+ # - dim_symbols:
20
+ # - - ascii: phi
21
+ # - html: "&#x1D785;"
22
+ # - id: dim_phi
23
+ # - latex: "\\ensuremath{\\mathsf{\\phi}}"
24
+ # - mathml: "<mi mathvariant='sans-serif'>&#x3c6;</mi>"
25
+ # - unicode: "\U0001D785"
26
+ # - powerNumerator: 1
27
+ # - symbol: phi
28
+
29
+ module Unitsdb
30
+ class Dimensions
31
+ class Dimension < Lutaml::Model::Serializable
32
+ model Config.model_for(:dimension)
33
+
34
+ attribute :id, :string
35
+ attribute :dimensionless, :boolean
36
+ attribute :length, Quantity
37
+ attribute :mass, Quantity
38
+ attribute :time, Quantity
39
+ attribute :electric_current, Quantity
40
+ attribute :thermodynamic_temperature, Quantity
41
+ attribute :amount_of_substance, Quantity
42
+ attribute :luminous_intensity, Quantity
43
+ attribute :plane_angle, Quantity
44
+
45
+ key_value do
46
+ map :id, to: :id
47
+ map :dimensionless, to: :dimensionless
48
+ map :length, to: :length
49
+ map :mass, to: :mass
50
+ map :time, to: :time
51
+ map :electric_current, to: :electric_current
52
+ map :thermodynamic_temperature, to: :thermodynamic_temperature
53
+ map :amount_of_substance, to: :amount_of_substance
54
+ map :luminous_intensity, to: :luminous_intensity
55
+ map :plane_angle, to: :plane_angle
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "symbol"
4
+ # NISTd1:
5
+ # length:
6
+ # powerNumerator: 1
7
+ # symbol: L
8
+ # dim_symbols:
9
+ # - id: "dim_L"
10
+ # ascii: "L"
11
+ # html: "&#x1D5AB;"
12
+ # mathml: "<mi mathvariant='sans-serif'>L</mi>"
13
+ # latex: \ensuremath{\mathsf{L}}
14
+ # unicode: "𝖫"
15
+
16
+ module Unitsdb
17
+ class Dimensions
18
+ class Quantity < Lutaml::Model::Serializable
19
+ model Config.model_for(:dimension_quantity)
20
+
21
+ attribute :power_numerator, :integer
22
+ attribute :symbol, :string
23
+ attribute :dim_symbols, Symbol, collection: true
24
+
25
+ key_value do
26
+ map :powerNumerator, to: :power_numerator
27
+ map :symbol, to: :symbol
28
+ map :dim_symbols, to: :dim_symbols
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../symbol_presentations"
4
+
5
+ # - id: "dim_L"
6
+ # ascii: "L"
7
+ # html: "&#x1D5AB;"
8
+ # mathml: "<mi mathvariant='sans-serif'>L</mi>"
9
+ # latex: \ensuremath{\mathsf{L}}
10
+ # unicode: "𝖫"
11
+
12
+ module Unitsdb
13
+ class Dimensions
14
+ class Symbol < SymbolPresentations
15
+ model Config.model_for(:dimension_symbol)
16
+
17
+ attribute :id, :string
18
+ attribute :mathml, :string
19
+
20
+ key_value do
21
+ map :id, to: :id
22
+ map :mathml, to: :mathml
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dimensions/dimension"
4
+
5
+ module Unitsdb
6
+ class Dimensions
7
+ include Lutaml::Model::Serialize
8
+ model Config.model_for(:dimensions)
9
+
10
+ attribute :dimensions, Dimension, collection: true
11
+
12
+ key_value do
13
+ map to: :dimensions, root_mappings: {
14
+ id: :key
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "symbol"
4
+ # ---
5
+ # NISTp10_30:
6
+ # name: quetta
7
+ # symbol:
8
+ # ascii: Q
9
+ # html: Q
10
+ # latex: Q
11
+ # unicode: Q
12
+ # base: 10
13
+ # power: 30
14
+
15
+ module Unitsdb
16
+ class Prefixes
17
+ class Prefix < Lutaml::Model::Serializable
18
+ model Config.model_for(:prefix)
19
+
20
+ attribute :id, :string
21
+ attribute :name, :string
22
+ attribute :symbol, Symbol
23
+ attribute :base, :integer
24
+ attribute :power, :integer
25
+
26
+ key_value do
27
+ map :id, to: :id
28
+ map :name, to: :name
29
+ map :symbol, to: :symbol
30
+ map :base, to: :base
31
+ map :power, to: :power
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../symbol_presentations"
4
+
5
+ # symbol:
6
+ # ascii: R
7
+ # html: R
8
+ # latex: R
9
+ # unicode: R
10
+
11
+ module Unitsdb
12
+ class Prefixes
13
+ class Symbol < SymbolPresentations
14
+ model Config.model_for(:prefix_symbol)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "prefixes/prefix"
4
+ # ---
5
+ # NISTp10_30:
6
+ # name: quetta
7
+ # symbol:
8
+ # ascii: Q
9
+ # html: Q
10
+ # latex: Q
11
+ # unicode: Q
12
+ # base: 10
13
+ # power: 30
14
+
15
+ module Unitsdb
16
+ class Prefixes
17
+ include Lutaml::Model::Serialize
18
+
19
+ model Config.model_for(:prefixes)
20
+
21
+ attribute :prefixes, Prefix, collection: true
22
+
23
+ key_value do
24
+ map to: :prefixes, root_mappings: {
25
+ id: :key
26
+ }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,37 @@
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
@@ -0,0 +1,15 @@
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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # # Quantities
2
4
  # NISTq156:
3
5
  # dimension_url: "#NISTd68"
@@ -18,16 +20,19 @@
18
20
  # - name: inch to the fourth power
19
21
  # url: "#NISTu208"
20
22
 
23
+ require_relative "quantities/quantity"
24
+
21
25
  module Unitsdb
22
- class Quantity < Lutaml::Model::Serializable
23
- attribute :dimension_url, :string
24
- attribute :quantity_type, :string
25
- attribute :quantity_name, :string, collection: true
26
- attribute :unit_reference, UnitReference, collection: true
27
- end
26
+ class Quantities
27
+ include Lutaml::Model::Serialize
28
+ model Config.model_for(:quantities)
29
+
30
+ attribute :quantities, Quantity, collection: true
28
31
 
29
- class UnitReference < Lutaml::Model::Serializable
30
- attribute :name, :string
31
- attribute :url, :string
32
+ key_value do
33
+ map to: :quantities, root_mappings: {
34
+ id: :key
35
+ }
36
+ end
32
37
  end
33
38
  end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unitsdb
2
- class Symbol < Lutaml::Model::Serializable
4
+ class SymbolPresentations < Lutaml::Model::Serializable
5
+ model Config.model_for(:symbol_presentations)
6
+
3
7
  attribute :ascii, :string
4
8
  attribute :html, :string
5
9
  attribute :latex, :string
@@ -0,0 +1,19 @@
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,14 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unit_systems/unit_system"
4
+
1
5
  module Unitsdb
2
- class UnitSystems < Lutaml::Model::Serializable
3
- # TODO: How do I parse this?
4
- # ---
5
- # - id: SI_base
6
- # name: SI
7
- # acceptable: true
8
- # - id: SI_derived_special
9
- # name: SI
10
- # acceptable: true
11
- # - id: SI_derived_non-special
6
+ class UnitSystems
7
+ include Lutaml::Model::Serialize
8
+ model Config.model_for(:unit_systems)
9
+
10
+ attribute :unit_systems, UnitSystem, collection: true
12
11
 
12
+ key_value do
13
+ map to: :unit_systems, root_mappings: {
14
+ id: :key
15
+ }
16
+ end
13
17
  end
14
18
  end
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,21 @@
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
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,73 @@
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
data/lib/unitsdb/units.rb CHANGED
@@ -1,13 +1,18 @@
1
- require_relative "unit"
1
+ # frozen_string_literal: true
2
+
3
+ require "unitsdb/units/unit"
2
4
 
3
5
  module Unitsdb
4
- class Units < Lutaml::Model::Serializable
6
+ class Units
7
+ include Lutaml::Model::Serialize
8
+ model Config.model_for(:units)
9
+
5
10
  attribute :units, Unit, collection: true
6
11
 
7
12
  key_value do
8
- map :units, :units, child_mappings: {
9
- id: :key,
10
- }
13
+ map to: :units, root_mappings: {
14
+ id: :key,
15
+ }
11
16
  end
12
17
  end
13
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Unitsdb
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.0"
5
5
  end
data/lib/unitsdb.rb CHANGED
@@ -2,14 +2,10 @@
2
2
 
3
3
  require "lutaml/model"
4
4
 
5
- # Lutaml::Model::Config.configure do |config|
6
- # require "lutaml/model/xml_adapter/nokogiri_adapter"
7
- # config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
8
- # end
9
-
10
- module Unitsdb
11
- class Error < StandardError; end
12
- end
13
-
14
5
  require_relative "unitsdb/version"
15
- require_relative "unitsdb/unit"
6
+ require_relative "unitsdb/config"
7
+ require_relative "unitsdb/units"
8
+ require_relative "unitsdb/unit_systems"
9
+ require_relative "unitsdb/dimensions"
10
+ require_relative "unitsdb/prefixes"
11
+ require_relative "unitsdb/quantities"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unitsdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-02 00:00:00.000000000 Z
11
+ date: 2025-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -31,34 +31,44 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".github/workflows/dependent-repos.json"
35
+ - ".github/workflows/depenedent-gems.yml"
34
36
  - ".github/workflows/rake.yml"
35
37
  - ".github/workflows/release.yml"
36
38
  - ".gitignore"
37
39
  - ".rspec"
38
40
  - ".rubocop.yml"
41
+ - ".rubocop_todo.yml"
39
42
  - CODE_OF_CONDUCT.md
40
43
  - Gemfile
41
- - Gemfile.lock
42
44
  - LICENSE.txt
43
45
  - README.adoc
44
46
  - Rakefile
45
47
  - bin/console
46
48
  - bin/setup
47
49
  - lib/unitsdb.rb
48
- - lib/unitsdb/dimension.rb
49
- - lib/unitsdb/dimension_symbol.rb
50
- - lib/unitsdb/prefix.rb
51
- - lib/unitsdb/prefix_symbol.rb
52
- - lib/unitsdb/quantity.rb
53
- - lib/unitsdb/root_unit.rb
54
- - lib/unitsdb/root_units.rb
55
- - lib/unitsdb/si_derived_base.rb
56
- - lib/unitsdb/symbol.rb
57
- - lib/unitsdb/unit.rb
58
- - lib/unitsdb/unit_symbol.rb
59
- - lib/unitsdb/unit_system.rb
50
+ - lib/unitsdb/config.rb
51
+ - lib/unitsdb/dimensions.rb
52
+ - lib/unitsdb/dimensions/dimension.rb
53
+ - lib/unitsdb/dimensions/quantity.rb
54
+ - lib/unitsdb/dimensions/symbol.rb
55
+ - lib/unitsdb/prefixes.rb
56
+ - lib/unitsdb/prefixes/prefix.rb
57
+ - lib/unitsdb/prefixes/symbol.rb
58
+ - lib/unitsdb/quantities.rb
59
+ - lib/unitsdb/quantities/quantity.rb
60
+ - lib/unitsdb/quantities/unit_reference.rb
61
+ - lib/unitsdb/symbol_presentations.rb
60
62
  - lib/unitsdb/unit_systems.rb
63
+ - lib/unitsdb/unit_systems/unit_system.rb
61
64
  - lib/unitsdb/units.rb
65
+ - lib/unitsdb/units/quantity_reference.rb
66
+ - lib/unitsdb/units/root_unit.rb
67
+ - lib/unitsdb/units/root_units.rb
68
+ - lib/unitsdb/units/si_derived_base.rb
69
+ - lib/unitsdb/units/symbol.rb
70
+ - lib/unitsdb/units/system.rb
71
+ - lib/unitsdb/units/unit.rb
62
72
  - lib/unitsdb/unitsdb.rb
63
73
  - lib/unitsdb/version.rb
64
74
  - sig/unitsdb.rbs
@@ -85,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
95
  - !ruby/object:Gem::Version
86
96
  version: '0'
87
97
  requirements: []
88
- rubygems_version: 3.5.22
98
+ rubygems_version: 3.3.27
89
99
  signing_key:
90
100
  specification_version: 4
91
101
  summary: Ruby library for UnitsDB
data/Gemfile.lock DELETED
@@ -1,104 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- unitsdb (0.1.0)
5
- lutaml-model
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activesupport (8.0.1)
11
- base64
12
- benchmark (>= 0.3)
13
- bigdecimal
14
- concurrent-ruby (~> 1.0, >= 1.3.1)
15
- connection_pool (>= 2.2.5)
16
- drb
17
- i18n (>= 1.6, < 2)
18
- logger (>= 1.4.2)
19
- minitest (>= 5.1)
20
- securerandom (>= 0.3)
21
- tzinfo (~> 2.0, >= 2.0.5)
22
- uri (>= 0.13.1)
23
- ast (2.4.2)
24
- base64 (0.2.0)
25
- benchmark (0.4.0)
26
- bigdecimal (3.1.9)
27
- concurrent-ruby (1.3.4)
28
- connection_pool (2.4.1)
29
- diff-lcs (1.5.1)
30
- drb (2.2.1)
31
- i18n (1.14.6)
32
- concurrent-ruby (~> 1.0)
33
- json (2.9.1)
34
- language_server-protocol (3.17.0.3)
35
- logger (1.6.4)
36
- lutaml-model (0.4.0)
37
- thor
38
- minitest (5.25.4)
39
- parallel (1.26.3)
40
- parser (3.3.6.0)
41
- ast (~> 2.4.1)
42
- racc
43
- racc (1.8.1)
44
- rack (3.1.8)
45
- rainbow (3.1.1)
46
- rake (13.2.1)
47
- regexp_parser (2.10.0)
48
- rspec (3.13.0)
49
- rspec-core (~> 3.13.0)
50
- rspec-expectations (~> 3.13.0)
51
- rspec-mocks (~> 3.13.0)
52
- rspec-core (3.13.2)
53
- rspec-support (~> 3.13.0)
54
- rspec-expectations (3.13.3)
55
- diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.13.0)
57
- rspec-mocks (3.13.2)
58
- diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.13.0)
60
- rspec-support (3.13.2)
61
- rubocop (1.69.2)
62
- json (~> 2.3)
63
- language_server-protocol (>= 3.17.0)
64
- parallel (~> 1.10)
65
- parser (>= 3.3.0.2)
66
- rainbow (>= 2.2.2, < 4.0)
67
- regexp_parser (>= 2.9.3, < 3.0)
68
- rubocop-ast (>= 1.36.2, < 2.0)
69
- ruby-progressbar (~> 1.7)
70
- unicode-display_width (>= 2.4.0, < 4.0)
71
- rubocop-ast (1.37.0)
72
- parser (>= 3.3.1.0)
73
- rubocop-performance (1.23.0)
74
- rubocop (>= 1.48.1, < 2.0)
75
- rubocop-ast (>= 1.31.1, < 2.0)
76
- rubocop-rails (2.28.0)
77
- activesupport (>= 4.2.0)
78
- rack (>= 1.1)
79
- rubocop (>= 1.52.0, < 2.0)
80
- rubocop-ast (>= 1.31.1, < 2.0)
81
- ruby-progressbar (1.13.0)
82
- securerandom (0.4.1)
83
- thor (1.3.2)
84
- tzinfo (2.0.6)
85
- concurrent-ruby (~> 1.0)
86
- unicode-display_width (3.1.3)
87
- unicode-emoji (~> 4.0, >= 4.0.4)
88
- unicode-emoji (4.0.4)
89
- uri (1.0.2)
90
-
91
- PLATFORMS
92
- arm64-darwin-23
93
- ruby
94
-
95
- DEPENDENCIES
96
- rake (~> 13.0)
97
- rspec (~> 3.0)
98
- rubocop
99
- rubocop-performance
100
- rubocop-rails
101
- unitsdb!
102
-
103
- BUNDLED WITH
104
- 2.5.22
@@ -1,27 +0,0 @@
1
- require_relative "dimension_symbol"
2
- # NISTd1:
3
- # length:
4
- # powerNumerator: 1
5
- # symbol: L
6
- # dim_symbols:
7
- # - id: "dim_L"
8
- # ascii: "L"
9
- # html: "&#x1D5AB;"
10
- # mathml: "<mi mathvariant='sans-serif'>L</mi>"
11
- # latex: \ensuremath{\mathsf{L}}
12
- # unicode: "𝖫"
13
-
14
- module Unitsdb
15
- class Dimension < Lutaml::Model::Serializable
16
- attribute :quantity_type, :string
17
- attribute :power_numerator, :integer
18
- attribute :symbol, :string
19
- attribute :dim_symbols, DimensionSymbol, collection: true
20
-
21
- key_value do
22
- map :powerNumerator, to: :power_numerator
23
- map :symbol, to: :symbol
24
- map :dim_symbols, to: :dim_symbols
25
- end
26
- end
27
- end
@@ -1,20 +0,0 @@
1
- require_relative "symbol"
2
-
3
- # - id: "dim_L"
4
- # ascii: "L"
5
- # html: "&#x1D5AB;"
6
- # mathml: "<mi mathvariant='sans-serif'>L</mi>"
7
- # latex: \ensuremath{\mathsf{L}}
8
- # unicode: "𝖫"
9
-
10
- module Unitsdb
11
- class DimensionSymbol < Symbol
12
- attribute :id, :string
13
- attribute :mathml, :string
14
-
15
- key_value do
16
- map :id, to: :id
17
- map :mathml, to: :mathml
18
- end
19
- end
20
- end
@@ -1,29 +0,0 @@
1
- require_relative "prefix_symbol"
2
- # ---
3
- # NISTp10_30:
4
- # name: quetta
5
- # symbol:
6
- # ascii: Q
7
- # html: Q
8
- # latex: Q
9
- # unicode: Q
10
- # base: 10
11
- # power: 30
12
-
13
- module Unitsdb
14
- class Prefix < Lutaml::Model::Serializable
15
- attribute :id, :string
16
- attribute :name, :string
17
- attribute :symbol, PrefixSymbol
18
- attribute :base, :integer
19
- attribute :power, :integer
20
-
21
- key_value do
22
- map :id, to: :id
23
- map :name, to: :name
24
- map :symbol, to: :symbol
25
- map :base, to: :base
26
- map :power, to: :power
27
- end
28
- end
29
- end
@@ -1,10 +0,0 @@
1
- # symbol:
2
- # ascii: R
3
- # html: R
4
- # latex: R
5
- # unicode: R
6
-
7
- module Unitsdb
8
- class PrefixSymbol < Symbol
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- module Unitsdb
2
- class RootUnit < Lutaml::Model::Serializable
3
- attribute :unit, :string
4
- attribute :power_denominator, :integer
5
- attribute :power_numerator, :integer
6
- attribute :prefix, :string
7
-
8
- key_value do
9
- map :unit, to: :unit
10
- map :power_denominator, to: :power_denominator
11
- map :power_numerator, to: :power_numerator
12
- map :prefix, to: :prefix
13
- end
14
- end
15
- end
@@ -1,7 +0,0 @@
1
- module Unitsdb
2
- class RootUnits < Lutaml::Model::Serializable
3
- attribute :unit, :string
4
- attribute :power_denominator, :integer
5
- attribute :power_numerator, :integer
6
- end
7
- end
@@ -1,18 +0,0 @@
1
- # - id: NISTu1
2
- # prefix:
3
- # power: 1
4
- # - id: NISTu1
5
- # prefix:
6
- # power: -1
7
-
8
- class SiDerivedBase < Lutaml::Model::Serializable
9
- attribute :id, :string
10
- attribute :prefix, :string
11
- attribute :power, :integer
12
-
13
- key_value do
14
- map :id, to: :id
15
- map :prefix, to: :prefix
16
- map :power, to: :power
17
- end
18
- end
data/lib/unitsdb/unit.rb DELETED
@@ -1,64 +0,0 @@
1
- require_relative "unit_system"
2
- require_relative "unit_symbol"
3
- require_relative "root_units"
4
- require_relative "si_derived_base"
5
-
6
- # "NISTu10":
7
- # dimension_url: "#NISTd9"
8
- # short: steradian
9
- # root: true
10
- # unit_system:
11
- # type: "SI_derived_special"
12
- # name: "SI"
13
- # unit_name:
14
- # - "steradian"
15
- # unit_symbols:
16
- # - id: "sr"
17
- # ascii: "sr"
18
- # html: "sr"
19
- # mathml: "<mi mathvariant='normal'>sr</mi>"
20
- # latex: \ensuremath{\mathrm{sr}}
21
- # unicode: "sr"
22
- # root_units:
23
- # enumerated_root_units:
24
- # - unit: "steradian"
25
- # power_denominator: 1
26
- # power_numerator: 1
27
- # quantity_reference:
28
- # - name: "solid angle"
29
- # url: "#NISTq11"
30
- # si_derived_bases:
31
- # - id: NISTu1
32
- # prefix:
33
- # power: 1
34
- # - id: NISTu1
35
- # prefix:
36
- # power: -1
37
-
38
- module Unitsdb
39
- class Unit < Lutaml::Model::Serializable
40
- attribute :id, :string
41
- attribute :short, :string
42
- attribute :root, :boolean
43
- attribute :dimension_url, :string
44
- attribute :unit_system, UnitSystem, collection: true
45
- attribute :unit_name, :string, collection: true
46
- attribute :unit_symbol, UnitSymbol, collection: true
47
- attribute :root_units, RootUnits, collection: true
48
- attribute :quantity_reference, :string, collection: true
49
- attribute :si_derived_bases, SiDerivedBase, collection: true
50
-
51
- key_value do
52
- map :id, to: :id
53
- map :short, to: :short
54
- map :root, to: :root
55
- map :dimension_url, to: :dimension_url
56
- map :unit_system, to: :unit_system
57
- map :unit_name, to: :unit_name
58
- map :unit_symbol, to: :unit_symbol
59
- map :root_units, to: :root_units
60
- map :quantity_reference, to: :quantity_reference
61
- map :si_derived_bases, to: :si_derived_bases
62
- end
63
- end
64
- end
@@ -1,13 +0,0 @@
1
- require_relative "symbol"
2
-
3
- module Unitsdb
4
- class UnitSymbol < Symbol
5
- attribute :id, :string
6
- attribute :mathml, :string
7
-
8
- key_value do
9
- map :id, to: :id
10
- map :mathml, to: :mathml
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- module Unitsdb
2
- class UnitSystem < Lutaml::Model::Serializable
3
- attribute :id, :string
4
- attribute :name, :string
5
- attribute :acceptable, :boolean
6
-
7
- key_value do
8
- map :id, to: :id
9
- map :name, to: :name
10
- map :acceptable, to: :acceptable
11
- end
12
- end
13
- end