Skip to content

UnitsDB v2 support - #47

Merged
ronaldtse merged 4 commits into
mainfrom
updated_unitsdb_version_support
Jul 23, 2025
Merged

UnitsDB v2 support#47
ronaldtse merged 4 commits into
mainfrom
updated_unitsdb_version_support

Conversation

@suleman-uzair

Copy link
Copy Markdown
Member

This PR updates the conversion methods to support the latest version of UnitsDB v2.0.

closes #44

@suleman-uzair
suleman-uzair force-pushed the updated_unitsdb_version_support branch from adb67f9 to b7b19bd Compare July 14, 2025 14:05
@suleman-uzair suleman-uzair changed the title [WIP] UnitsDB v2 support UnitsDB v2 support Jul 14, 2025
@suleman-uzair
suleman-uzair requested a review from Copilot July 14, 2025 14:09

This comment was marked as outdated.

@suleman-uzair
suleman-uzair requested a review from Copilot July 14, 2025 14:37

This comment was marked as outdated.

@suleman-uzair
suleman-uzair requested a review from Copilot July 14, 2025 14:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the library to be compatible with UnitsDB v2.0 by bumping the dependency, switching over to the new UnitsDB v2 APIs, and adjusting XML output to reflect updated identifiers and structures.

  • Bumped unitsdb dependency in the gemspec and updated the Git submodule.
  • Refactored all Unitsdb model integrations (Units, Unit, Prefixes, Dimensions, etc.) to use v2 methods and registered them with the global register.
  • Updated XML generation logic and tests to expect the new v2 identifiers and element structures.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
unitsml.gemspec Bump unitsdb dependency from ~>1.0 to ~>2.0
unitsdb Updated submodule commit to v2
spec/unitsml/conv/xml_spec.rb Updated expected XML in tests for new unit and dimension IDs
lib/unitsml/utility.rb Adjusted dimension and unit‐ID generation for v2 API
lib/unitsml/unitsdb/units.rb Refactored Units finder methods for v2
lib/unitsml/unitsdb/unit.rb Added dimension_url, en_name, nist_id for Unit class
lib/unitsml/unitsdb/quantities.rb Adapted Quantities lookup to use new identifiers
lib/unitsml/unitsdb/prefixes.rb Updated Prefixes to v2 symbol and identifier APIs
lib/unitsml/unitsdb/prefix_reference.rb New class for v2 prefix references
lib/unitsml/unitsdb/dimensions.rb Updated Dimensions lookup by vector
lib/unitsml/unitsdb/dimension_quantity.rb Adapted dimension details symbol mapping
lib/unitsml/unitsdb/dimension.rb Overrode Dimension for v2, including id and vector
lib/unitsml/unitsdb.rb Switched YAML loaders to use registered v2 classes
lib/unitsml/unit.rb Revised Unit class to use new v2 attributes and helpers
lib/unitsml/prefix.rb Updated prefix handling to match v2 symbol APIs
lib/unitsml/parser.rb Extracted unit expression parsing into helper
lib/unitsml/formula.rb Changed normalization to use xml_postprocess_name
lib/unitsml/dimension.rb Adjusted symbol lookup to match v2 API
lib/unitsml.rb Registered global type substitutions for v2 classes
Gemfile Added lutaml-model dependency from GitHub

<Time symbol="T" powerNumerator="-1"/>
</Dimension>

<Quantity xmlns="https://schema.unitsml.org/unitsml/1.0" xml:id="NISTq45" quantityType="base" dimensionURL="#NISTd24">

Copilot AI Jul 14, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Quantity element still references the old dimensionURL "#NISTd24" despite updating the to use id "NISTd101". Update the dimensionURL to "#NISTd101" so the test matches the new identifier.

Suggested change
<Quantity xmlns="https://schema.unitsml.org/unitsml/1.0" xml:id="NISTq45" quantityType="base" dimensionURL="#NISTd24">
<Quantity xmlns="https://schema.unitsml.org/unitsml/1.0" xml:id="NISTq45" quantityType="base" dimensionURL="#NISTd101">

Copilot uses AI. Check for mistakes.
@suleman-uzair
suleman-uzair marked this pull request as ready for review July 14, 2025 14:49
Comment thread lib/unitsml.rb Outdated

def register
@register ||= Lutaml::Model::GlobalRegister.lookup(
Lutaml::Model::Config.default_register,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. Is the UnitsML gem going to have its own model register? Is it sharing a model register with something else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronaldtse, good catch‒the current code uses the default register, which can be shared. I believe it would be more appropriate to create a dedicated register named unitsml-ruby. I'll update the code.

Please let me know if you have any suggestions.

@ronaldtse
ronaldtse merged commit 81a4f7a into main Jul 23, 2025
14 of 15 checks passed
@ronaldtse
ronaldtse deleted the updated_unitsdb_version_support branch July 23, 2025 11:03
@ronaldtse

Copy link
Copy Markdown
Contributor

Thank you @suleman-uzair !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt UnitsDB 2.0 (unitsdb gem 2.0)

3 participants