Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 2.73 KB

File metadata and controls

55 lines (39 loc) · 2.73 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Development Commands

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 gem

Architecture

Bundled Data

The 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 the data/ directory inside the gem
  • Unitsdb.database — pre-loaded Database.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.

Core Classes

  • Unitsdb::Database — Loads all YAML files, provides search, get_by_id, find_by_type, find_by_symbol, match_entities, validate_uniqueness, validate_references
  • Unitsdb::Cli (Thor-based) — Command-line interface with subcommands: validate, search, get, check_si, ucum, qudt, _modify, release
  • lib/unitsdb/commands/base.rb — Base class for commands; provides load_database and @options[:database]

Model Pattern

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.

Workflow Files

Workflows in .github/workflows/ are auto-generated by Cimas (metanorma/cimas) and delegate to shared reusable workflows in metanorma/ci:

  • rake.ymlgeneric-rake.yml@main — runs tests/lint on push/PR
  • release.ymlrubygems-release.yml@main — builds and publishes gem
  • dependent-gems.ymldependent-rake.yml@main — tests downstream consumers

Git Submodule

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.