This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
bundle install # Install dependencies
bundle exec rake # Run full default task (rspec + rubocop)
bundle exec rspec # Run all tests
bundle exec rspec spec/path/to/file_spec.rb # Run single spec
bundle exec rubocop # Lint all files
bundle exec rake build # Build the gemThe gem ships UnitsDB YAML data files in data/ (a git submodule at https://github.com/unitsml/unitsdb). These are included in the published gem via spec.files += Dir.glob("data/**/*.yaml") in the gemspec.
Two entry points for the bundled data:
Unitsdb.data_dir— path to thedata/directory inside the gemUnitsdb.database— pre-loadedDatabase.from_db(data_dir)instance (cached)
The correspondence between gem version and data version is tracked via
Unitsdb::UNITS_DATA_VERSION (e.g. "2.0.0"). The UnitsDB data must be
released (tagged) before the gem can be released with updated data. When
releasing with new data: tag the data in unitsml/unitsdb, then update
.gitmodules (branch = refs/tags/new-data-tag) and bump both VERSION and
UNITS_DATA_VERSION in lib/unitsdb/version.rb.
Unitsdb::Database— Loads all YAML files, providessearch,get_by_id,find_by_type,find_by_symbol,match_entities,validate_uniqueness,validate_referencesUnitsdb::Cli(Thor-based) — Command-line interface with subcommands:validate,search,get,check_si,ucum,qudt,_modify,releaselib/unitsdb/commands/base.rb— Base class for commands; providesload_databaseand@options[:database]
Entity types (Unit, Prefix, Dimension, Quantity, UnitSystem, etc.) are Lutaml::Model-serializable classes. They are loaded from YAML via Database.from_db, which validates schema_version: "2.0.0" across all files and merges them into a single object.
Workflows in .github/workflows/ are auto-generated by Cimas (metanorma/cimas) and delegate to shared reusable workflows in metanorma/ci:
rake.yml→generic-rake.yml@main— runs tests/lint on push/PRrelease.yml→rubygems-release.yml@main— builds and publishes gemdependent-gems.yml→dependent-rake.yml@main— tests downstream consumers
data/ is a git submodule pinned to a specific tag in https://github.com/unitsml/unitsdb
(e.g. branch = refs/tags/v2.0.0 in .gitmodules). The CI rake.yml uses
submodules: 'recursive' so tests have the data available. The release workflow
uses submodules: true to initialize the submodule during checkout.