unitsdb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9cc59f72cf82c8470435a6301b122e6a8f5fc17e97b67f7356a1978242abf85e
4
+ data.tar.gz: 8f9b1f7210647662b46ba51cd152181ea070e49c766829265ef83e090930cef2
5
+ SHA512:
6
+ metadata.gz: 314d79de0bf13287ad60702c59a77989ed0e2a870d3bc30dc82f28eacb0958075abe681e3b271695ae0f15f8bfb9dd9a8ee3e8f48860cdf4d82ebe9026919609
7
+ data.tar.gz: a8989534b950c382fa387819bec1e1a7f0dbf2ada67bff1e9640788d863440f070182c755e76da8e0db1c90b0980cde444366d61fe0312f1c55c29ecd33a8546
@@ -0,0 +1,15 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ uses: metanorma/ci/.github/workflows/generic-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.UNITSML_CI_PAT_TOKEN }}
@@ -0,0 +1,23 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ repository_dispatch:
14
+ types: [ do-release ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ secrets:
22
+ rubygems-api-key: ${{ secrets.UNITSML_CI_RUBYGEMS_API_KEY }}
23
+ pat_token: ${{ secrets.UNITSML_CI_PAT_TOKEN }}
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ronald.tse@ribose.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in suma.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rubocop"
11
+ gem "rubocop-performance"
12
+ gem "rubocop-rails"
data/Gemfile.lock ADDED
@@ -0,0 +1,104 @@
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
data/LICENSE.txt ADDED
@@ -0,0 +1,33 @@
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
+ Ribose's BSD 2-Clause License
9
+ -----------------------------
10
+
11
+ Copyright (c) 2024, [Ribose Inc](https://www.ribose.com).
12
+ All rights reserved.
13
+
14
+ Redistribution and use in source and binary forms, with or without modification,
15
+ are permitted provided that the following conditions are met:
16
+
17
+ 1. Redistributions of source code must retain the above copyright notice,
18
+ this list of conditions and the following disclaimer.
19
+
20
+ 2. Redistributions in binary form must reproduce the above copyright notice,
21
+ this list of conditions and the following disclaimer in the documentation
22
+ and/or other materials provided with the distribution.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.adoc ADDED
@@ -0,0 +1,35 @@
1
+ = UnitsDB in Ruby (UnitsML)
2
+
3
+ == Purpose
4
+
5
+ UnitsML is a standard for units of measure, and UnitsDB is the database
6
+ that contains enumerative elements used by UnitsML.
7
+
8
+ UnitsDB includes the following content:
9
+
10
+ * Unit systems
11
+ * Units of measure
12
+ * Prefixes
13
+ * Constants
14
+ * Quantities
15
+
16
+ Such content is hosted at the official UnitsDB repository at
17
+ https://github.com/unitsml/unitsdb.
18
+
19
+ This repository contains the Ruby codebase for UnitsDB, which is used
20
+ to access and manipulate the UnitsDB content.
21
+
22
+ == Install
23
+
24
+ [source,sh]
25
+ ----
26
+ $ gem install unitsdb
27
+ ----
28
+
29
+ == Usage
30
+
31
+
32
+
33
+ == License
34
+
35
+ Copyright Ribose. BSD 2-clause license.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "unitsdb"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "irb"
11
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,20 @@
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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,33 @@
1
+ # # Quantities
2
+ # NISTq156:
3
+ # dimension_url: "#NISTd68"
4
+ # quantity_type: derived
5
+ # quantity_name:
6
+ # - linear expansion coefficient
7
+ # unit_reference:
8
+ # - name: kelvin to the power minus one
9
+ # url: "#NISTu5e-1/1"
10
+
11
+ # NISTq155:
12
+ # dimension_url: "#NISTd57"
13
+ # quantity_type: derived
14
+ # quantity_name:
15
+ # - area moment of inertia
16
+ # - second moment of area
17
+ # unit_reference:
18
+ # - name: inch to the fourth power
19
+ # url: "#NISTu208"
20
+
21
+ 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
28
+
29
+ class UnitReference < Lutaml::Model::Serializable
30
+ attribute :name, :string
31
+ attribute :url, :string
32
+ end
33
+ end
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,15 @@
1
+ module Unitsdb
2
+ class Symbol < Lutaml::Model::Serializable
3
+ attribute :ascii, :string
4
+ attribute :html, :string
5
+ attribute :latex, :string
6
+ attribute :unicode, :string
7
+
8
+ key_value do
9
+ map :ascii, to: :ascii
10
+ map :html, to: :html
11
+ map :latex, to: :latex
12
+ map :unicode, to: :unicode
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,64 @@
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
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,14 @@
1
+ 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
12
+
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "unit"
2
+
3
+ module Unitsdb
4
+ class Units < Lutaml::Model::Serializable
5
+ attribute :units, Unit, collection: true
6
+
7
+ key_value do
8
+ map :units, :units, child_mappings: {
9
+ id: :key,
10
+ }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsdb
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unitsdb
4
+ VERSION = "0.1.0"
5
+ end
data/lib/unitsdb.rb ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
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
+ require_relative "unitsdb/version"
15
+ require_relative "unitsdb/unit"
data/sig/unitsdb.rbs ADDED
@@ -0,0 +1,6 @@
1
+ module Unitsdb
2
+ module Ruby
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
data/unitsdb.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/unitsdb/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "unitsdb"
7
+ spec.version = Unitsdb::VERSION
8
+ spec.authors = ["Ribose Inc."]
9
+ spec.email = ["open.source@ribose.com"]
10
+
11
+ spec.summary = "Ruby library for UnitsDB"
12
+ spec.description = "Library to handle UnitsDB content."
13
+ spec.homepage = "https://github.com/unitsml/unitsdb-ruby"
14
+
15
+ spec.license = "BSD-2-Clause"
16
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = "https://github.com/unitsml/unitsdb-ruby/releases"
21
+
22
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
+ `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_dependency "lutaml-model"
37
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unitsdb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lutaml-model
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Library to handle UnitsDB content.
28
+ email:
29
+ - open.source@ribose.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/rake.yml"
35
+ - ".github/workflows/release.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".rubocop.yml"
39
+ - CODE_OF_CONDUCT.md
40
+ - Gemfile
41
+ - Gemfile.lock
42
+ - LICENSE.txt
43
+ - README.adoc
44
+ - Rakefile
45
+ - bin/console
46
+ - bin/setup
47
+ - 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
60
+ - lib/unitsdb/unit_systems.rb
61
+ - lib/unitsdb/units.rb
62
+ - lib/unitsdb/unitsdb.rb
63
+ - lib/unitsdb/version.rb
64
+ - sig/unitsdb.rbs
65
+ - unitsdb.gemspec
66
+ homepage: https://github.com/unitsml/unitsdb-ruby
67
+ licenses:
68
+ - BSD-2-Clause
69
+ metadata:
70
+ homepage_uri: https://github.com/unitsml/unitsdb-ruby
71
+ source_code_uri: https://github.com/unitsml/unitsdb-ruby
72
+ changelog_uri: https://github.com/unitsml/unitsdb-ruby/releases
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 3.0.0
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.5.22
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Ruby library for UnitsDB
92
+ test_files: []