unitsdb 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cc59f72cf82c8470435a6301b122e6a8f5fc17e97b67f7356a1978242abf85e
4
- data.tar.gz: 8f9b1f7210647662b46ba51cd152181ea070e49c766829265ef83e090930cef2
3
+ metadata.gz: 520380cf306ea06253c1d4e07b879bfac7b49e69f58514eb9cc5bc19b9c39b86
4
+ data.tar.gz: f37a0ad8ac751a634ae851d018b3a3cdcaf8e6f866743bd93f84d5a36b7aba42
5
5
  SHA512:
6
- metadata.gz: 314d79de0bf13287ad60702c59a77989ed0e2a870d3bc30dc82f28eacb0958075abe681e3b271695ae0f15f8bfb9dd9a8ee3e8f48860cdf4d82ebe9026919609
7
- data.tar.gz: a8989534b950c382fa387819bec1e1a7f0dbf2ada67bff1e9640788d863440f070182c755e76da8e0db1c90b0980cde444366d61fe0312f1c55c29ecd33a8546
6
+ metadata.gz: d6188d494f447dc5893805555b0e7d0b9ae88e1728770215f98e41c7890b0cd183fcec7818705c4d23705eca895e83c9f8e11a21a95f2b9266baf26c9e0ef9e0
7
+ data.tar.gz: b99151aa57387c0b60374a5d6cc657fec74c6f3a7c4d21887a7053910bf45912a578ff75380c9e612960d11f4a4535bcfdb24389fd22816815c654c8fc903ad8
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"
@@ -1,4 +1,6 @@
1
- require_relative "dimension_symbol"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dimension_quantity"
2
4
  # NISTd1:
3
5
  # length:
4
6
  # powerNumerator: 1
@@ -11,17 +13,43 @@ require_relative "dimension_symbol"
11
13
  # latex: \ensuremath{\mathsf{L}}
12
14
  # unicode: "𝖫"
13
15
 
16
+ # NISTd9:
17
+ # -dimensionless: true
18
+ # -plane_angle:
19
+ # - dim_symbols:
20
+ # - - ascii: phi
21
+ # - html: "𝞅"
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
+
14
29
  module Unitsdb
15
30
  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
31
+ attribute :id, :string
32
+ attribute :dimensionless, :boolean
33
+ attribute :length, DimensionQuantity
34
+ attribute :mass, DimensionQuantity
35
+ attribute :time, DimensionQuantity
36
+ attribute :electric_current, DimensionQuantity
37
+ attribute :thermodynamic_temperature, DimensionQuantity
38
+ attribute :amount_of_substance, DimensionQuantity
39
+ attribute :luminous_intensity, DimensionQuantity
40
+ attribute :plane_angle, DimensionQuantity
20
41
 
21
42
  key_value do
22
- map :powerNumerator, to: :power_numerator
23
- map :symbol, to: :symbol
24
- map :dim_symbols, to: :dim_symbols
43
+ map :id, to: :id
44
+ map :dimensionless, to: :dimensionless
45
+ map :length, to: :length
46
+ map :mass, to: :mass
47
+ map :time, to: :time
48
+ map :electric_current, to: :electric_current
49
+ map :thermodynamic_temperature, to: :thermodynamic_temperature
50
+ map :amount_of_substance, to: :amount_of_substance
51
+ map :luminous_intensity, to: :luminous_intensity
52
+ map :plane_angle, to: :plane_angle
25
53
  end
26
54
  end
27
55
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dimension_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 DimensionQuantity < Lutaml::Model::Serializable
18
+ attribute :power_numerator, :integer
19
+ attribute :symbol, :string
20
+ attribute :dim_symbols, DimensionSymbol, collection: true
21
+
22
+ key_value do
23
+ map :powerNumerator, to: :power_numerator
24
+ map :symbol, to: :symbol
25
+ map :dim_symbols, to: :dim_symbols
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "symbol"
2
4
 
3
5
  # - id: "dim_L"
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dimension"
4
+
5
+ module Unitsdb
6
+ class Dimensions < Lutaml::Model::Serializable
7
+ attribute :dimension, Dimension, collection: true
8
+
9
+ key_value do
10
+ map to: :dimension, root_mappings: {
11
+ id: :key
12
+ }
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "prefix_symbol"
2
4
  # ---
3
5
  # NISTp10_30:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # symbol:
2
4
  # ascii: R
3
5
  # html: R
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "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 < Lutaml::Model::Serializable
17
+ attribute :prefix, Prefix, collection: true
18
+
19
+ key_value do
20
+ map to: :prefix, root_mappings: {
21
+ id: :key
22
+ }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # # Quantities
4
+ # NISTq156:
5
+ # dimension_url: "#NISTd68"
6
+ # quantity_type: derived
7
+ # quantity_name:
8
+ # - linear expansion coefficient
9
+ # unit_reference:
10
+ # - name: kelvin to the power minus one
11
+ # url: "#NISTu5e-1/1"
12
+
13
+ # NISTq155:
14
+ # dimension_url: "#NISTd57"
15
+ # quantity_type: derived
16
+ # quantity_name:
17
+ # - area moment of inertia
18
+ # - second moment of area
19
+ # unit_reference:
20
+ # - name: inch to the fourth power
21
+ # url: "#NISTu208"
22
+
23
+ require_relative "quantity"
24
+
25
+ module Unitsdb
26
+ class Quantities < Lutaml::Model::Serializable
27
+ attribute :quantity, Quantity, collection: true
28
+
29
+ key_value do
30
+ map to: :quantity, root_mappings: {
31
+ id: :key
32
+ }
33
+ end
34
+ end
35
+ 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,14 @@
18
20
  # - name: inch to the fourth power
19
21
  # url: "#NISTu208"
20
22
 
23
+ require_relative "unit_reference"
24
+
21
25
  module Unitsdb
22
26
  class Quantity < Lutaml::Model::Serializable
27
+ attribute :id, :string
23
28
  attribute :dimension_url, :string
24
29
  attribute :quantity_type, :string
25
30
  attribute :quantity_name, :string, collection: true
26
31
  attribute :unit_reference, UnitReference, collection: true
27
32
  end
28
-
29
- class UnitReference < Lutaml::Model::Serializable
30
- attribute :name, :string
31
- attribute :url, :string
32
- end
33
33
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsdb
4
+ class QuantityReference < Lutaml::Model::Serializable
5
+ attribute :name, :string
6
+ attribute :url, :string
7
+
8
+ key_value do
9
+ map :name, to: :name
10
+ map :url, to: :url
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unitsdb
2
4
  class RootUnit < Lutaml::Model::Serializable
3
5
  attribute :unit, :string
@@ -1,7 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "root_unit"
4
+
1
5
  module Unitsdb
2
6
  class RootUnits < Lutaml::Model::Serializable
3
7
  attribute :unit, :string
4
8
  attribute :power_denominator, :integer
5
9
  attribute :power_numerator, :integer
10
+ attribute :enumerated_root_units, RootUnit, collection: true
11
+
12
+ key_value do
13
+ map :unit, to: :unit
14
+ map :power_denominator, to: :power_denominator
15
+ map :power_numerator, to: :power_numerator
16
+ map :enumerated_root_units,
17
+ to: :enumerated_root_units
18
+ end
6
19
  end
7
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # - id: NISTu1
2
4
  # prefix:
3
5
  # power: 1
@@ -12,7 +14,7 @@ class SiDerivedBase < Lutaml::Model::Serializable
12
14
 
13
15
  key_value do
14
16
  map :id, to: :id
15
- map :prefix, to: :prefix
17
+ map :prefix, to: :prefix, render_nil: true
16
18
  map :power, to: :power
17
19
  end
18
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unitsdb
2
4
  class Symbol < Lutaml::Model::Serializable
3
5
  attribute :ascii, :string
data/lib/unitsdb/unit.rb CHANGED
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "unit_system"
2
4
  require_relative "unit_symbol"
3
5
  require_relative "root_units"
4
6
  require_relative "si_derived_base"
7
+ require_relative "quantity_reference"
5
8
 
6
9
  # "NISTu10":
7
10
  # dimension_url: "#NISTd9"
@@ -40,22 +43,24 @@ module Unitsdb
40
43
  attribute :id, :string
41
44
  attribute :short, :string
42
45
  attribute :root, :boolean
46
+ attribute :prefixed, :boolean
43
47
  attribute :dimension_url, :string
44
48
  attribute :unit_system, UnitSystem, collection: true
45
49
  attribute :unit_name, :string, collection: true
46
50
  attribute :unit_symbol, UnitSymbol, collection: true
47
51
  attribute :root_units, RootUnits, collection: true
48
- attribute :quantity_reference, :string, collection: true
52
+ attribute :quantity_reference, QuantityReference, collection: true
49
53
  attribute :si_derived_bases, SiDerivedBase, collection: true
50
54
 
51
55
  key_value do
52
56
  map :id, to: :id
53
- map :short, to: :short
54
- map :root, to: :root
55
57
  map :dimension_url, to: :dimension_url
58
+ map :short, to: :short, render_nil: true
59
+ map :root, to: :root
60
+ map :prefixed, to: :prefixed
56
61
  map :unit_system, to: :unit_system
57
62
  map :unit_name, to: :unit_name
58
- map :unit_symbol, to: :unit_symbol
63
+ map :unit_symbols, to: :unit_symbol
59
64
  map :root_units, to: :root_units
60
65
  map :quantity_reference, to: :quantity_reference
61
66
  map :si_derived_bases, to: :si_derived_bases
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsdb
4
+ class UnitReference < Lutaml::Model::Serializable
5
+ attribute :name, :string
6
+ attribute :url, :string
7
+
8
+ key_value do
9
+ map :name, to: :name
10
+ map :url, to: :url
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "symbol"
2
4
 
3
5
  module Unitsdb
@@ -1,11 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unitsdb
2
4
  class UnitSystem < Lutaml::Model::Serializable
3
5
  attribute :id, :string
4
6
  attribute :name, :string
7
+ attribute :type, :string
5
8
  attribute :acceptable, :boolean
6
9
 
7
10
  key_value do
8
11
  map :id, to: :id
12
+ map :type, to: :type
9
13
  map :name, to: :name
10
14
  map :acceptable, to: :acceptable
11
15
  end
@@ -1,5 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unit_system"
4
+
1
5
  module Unitsdb
2
6
  class UnitSystems < Lutaml::Model::Serializable
7
+ attribute :unit_system, UnitSystem, collection: true
8
+
3
9
  # TODO: How do I parse this?
4
10
  # ---
5
11
  # - id: SI_base
@@ -10,5 +16,10 @@ module Unitsdb
10
16
  # acceptable: true
11
17
  # - id: SI_derived_non-special
12
18
 
19
+ key_value do
20
+ map to: :unit_system, root_mappings: {
21
+ id: :key
22
+ }
23
+ end
13
24
  end
14
25
  end
data/lib/unitsdb/units.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "unit"
2
4
 
3
5
  module Unitsdb
@@ -5,9 +7,9 @@ module Unitsdb
5
7
  attribute :units, Unit, collection: true
6
8
 
7
9
  key_value do
8
- map :units, :units, child_mappings: {
9
- id: :key,
10
- }
10
+ map to: :units, root_mappings: {
11
+ id: :key,
12
+ }
11
13
  end
12
14
  end
13
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Unitsdb
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/unitsdb.rb CHANGED
@@ -12,4 +12,7 @@ module Unitsdb
12
12
  end
13
13
 
14
14
  require_relative "unitsdb/version"
15
- require_relative "unitsdb/unit"
15
+ require_relative "unitsdb/units"
16
+ require_relative "unitsdb/dimensions"
17
+ require_relative "unitsdb/prefixes"
18
+ 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: 0.1.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: 2025-01-02 00:00:00.000000000 Z
11
+ date: 2025-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -36,9 +36,9 @@ files:
36
36
  - ".gitignore"
37
37
  - ".rspec"
38
38
  - ".rubocop.yml"
39
+ - ".rubocop_todo.yml"
39
40
  - CODE_OF_CONDUCT.md
40
41
  - Gemfile
41
- - Gemfile.lock
42
42
  - LICENSE.txt
43
43
  - README.adoc
44
44
  - Rakefile
@@ -46,15 +46,21 @@ files:
46
46
  - bin/setup
47
47
  - lib/unitsdb.rb
48
48
  - lib/unitsdb/dimension.rb
49
+ - lib/unitsdb/dimension_quantity.rb
49
50
  - lib/unitsdb/dimension_symbol.rb
51
+ - lib/unitsdb/dimensions.rb
50
52
  - lib/unitsdb/prefix.rb
51
53
  - lib/unitsdb/prefix_symbol.rb
54
+ - lib/unitsdb/prefixes.rb
55
+ - lib/unitsdb/quantities.rb
52
56
  - lib/unitsdb/quantity.rb
57
+ - lib/unitsdb/quantity_reference.rb
53
58
  - lib/unitsdb/root_unit.rb
54
59
  - lib/unitsdb/root_units.rb
55
60
  - lib/unitsdb/si_derived_base.rb
56
61
  - lib/unitsdb/symbol.rb
57
62
  - lib/unitsdb/unit.rb
63
+ - lib/unitsdb/unit_reference.rb
58
64
  - lib/unitsdb/unit_symbol.rb
59
65
  - lib/unitsdb/unit_system.rb
60
66
  - lib/unitsdb/unit_systems.rb
@@ -85,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
91
  - !ruby/object:Gem::Version
86
92
  version: '0'
87
93
  requirements: []
88
- rubygems_version: 3.5.22
94
+ rubygems_version: 3.3.27
89
95
  signing_key:
90
96
  specification_version: 4
91
97
  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