Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
# See https://github.com/metanorma/cimas
name: release

permissions:
contents: write
packages: write
id-token: write

on:
workflow_dispatch:
inputs:
next_version:
description: |
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
required: true
default: 'skip'
repository_dispatch:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@

# rspec failure tracking
.rspec_status

Gemfile.lock
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ AllCops:
NewCops: enable
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/unitsdb/**/*'
75 changes: 34 additions & 41 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-07-17 07:21:41 UTC using RuboCop version 1.78.0.
# on 2026-03-27 10:55:21 UTC using RuboCop version 1.86.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'unitsdb.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'lib/unitsdb/commands/qudt/updater.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleAlignWith.
Expand All @@ -29,9 +19,9 @@ Layout/BlockAlignment:
Exclude:
- 'spec/unitsdb/commands/normalize_spec.rb'

# Offense count: 370
# Offense count: 373
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Enabled: false
Expand All @@ -40,19 +30,12 @@ Layout/LineLength:
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
Lint/DuplicateBranch:
Exclude:
- 'lib/unitsdb/commands/check_si/si_formatter.rb'
- 'lib/unitsdb/commands/qudt/matcher.rb'
- 'lib/unitsdb/commands/si_formatter.rb'
- 'lib/unitsdb/commands/ucum/matcher.rb'
- 'lib/unitsdb/database.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect.
Lint/UselessAssignment:
Exclude:
- 'lib/unitsdb/commands/qudt/updater.rb'

# Offense count: 87
# Offense count: 83
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize:
Enabled: false
Expand All @@ -63,12 +46,12 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 62

# Offense count: 77
# Offense count: 73
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/CyclomaticComplexity:
Enabled: false

# Offense count: 113
# Offense count: 110
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 150
Expand All @@ -78,7 +61,7 @@ Metrics/MethodLength:
Metrics/ParameterLists:
Max: 6

# Offense count: 68
# Offense count: 64
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/PerceivedComplexity:
Enabled: false
Expand All @@ -88,18 +71,17 @@ Metrics/PerceivedComplexity:
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/unitsdb/commands/si_ttl_parser.rb'
- 'lib/unitsdb/commands/check_si/si_ttl_parser.rb'
- 'lib/unitsdb/utils.rb'

# Offense count: 10
# Offense count: 9
# Configuration parameters: MinSize.
Performance/CollectionLiteralInLoop:
Exclude:
- 'lib/unitsdb/commands/si_formatter.rb'
- 'lib/unitsdb/commands/si_matcher.rb'
- 'lib/unitsdb/commands/si_updater.rb'
- 'lib/unitsdb/commands/check_si/si_formatter.rb'
- 'lib/unitsdb/commands/check_si/si_matcher.rb'
- 'lib/unitsdb/commands/check_si/si_updater.rb'
- 'lib/unitsdb/database.rb'
- 'test_prefixes_yaml.rb'

# Offense count: 2
RSpec/BeforeAfterAll:
Expand All @@ -114,9 +96,9 @@ RSpec/BeforeAfterAll:
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/unitsdb/commands/check_si_spec.rb'
- 'spec/unitsdb/commands/check_si_command_spec.rb'

# Offense count: 3
# Offense count: 2
# Configuration parameters: IgnoredMetadata.
RSpec/DescribeClass:
Exclude:
Expand All @@ -126,31 +108,42 @@ RSpec/DescribeClass:
- '**/spec/system/**/*'
- '**/spec/views/**/*'
- 'spec/exe/unitsdb_spec.rb'
- 'spec/fixtures/unitsdb/spec/units_spec.rb'
- 'spec/unitsdb/version_compatibility_spec.rb'

# Offense count: 32
# Offense count: 30
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 30

# Offense count: 26
RSpec/ExpectOutput:
Exclude:
- 'spec/unitsdb/commands/check_si_spec.rb'
- 'spec/unitsdb/commands/check_si_command_spec.rb'
- 'spec/unitsdb/commands/get_spec.rb'
- 'spec/unitsdb/commands/normalize_spec.rb'
- 'spec/unitsdb/commands/search_spec.rb'
- 'spec/unitsdb/commands/validate/identifiers_spec.rb'
- 'spec/unitsdb/commands/validate/si_references_spec.rb'

# Offense count: 8
RSpec/LeakyLocalVariable:
Exclude:
- 'spec/unitsdb/database_spec.rb'
- 'spec/unitsdb/dimensions_spec.rb'
- 'spec/unitsdb/prefixes_spec.rb'
- 'spec/unitsdb/quantities_spec.rb'
- 'spec/unitsdb/scales_spec.rb'
- 'spec/unitsdb/unit_spec.rb'
- 'spec/unitsdb/unit_systems_spec.rb'
- 'spec/unitsdb/units_spec.rb'

# Offense count: 7
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 44
# Offense count: 45
RSpec/MultipleExpectations:
Max: 15

Expand All @@ -176,29 +169,29 @@ RSpec/VerifiedDoubles:
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CombinableLoops:
Exclude:
- 'lib/unitsdb/commands/si_matcher.rb'
- 'lib/unitsdb/commands/check_si/si_matcher.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/IdenticalConditionalBranches:
Exclude:
- 'lib/unitsdb/commands/si_formatter.rb'
- 'lib/unitsdb/commands/check_si/si_formatter.rb'

# Offense count: 14
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/unitsdb/commands/check_si.rb'
- 'lib/unitsdb/commands/check_si/si_updater.rb'
- 'lib/unitsdb/commands/qudt/check.rb'
- 'lib/unitsdb/commands/qudt/update.rb'
- 'lib/unitsdb/commands/qudt/updater.rb'
- 'lib/unitsdb/commands/si_updater.rb'
- 'lib/unitsdb/commands/ucum/check.rb'
- 'lib/unitsdb/commands/ucum/updater.rb'

# Offense count: 1
# Configuration parameters: Max.
Style/SafeNavigationChainLength:
Exclude:
- 'lib/unitsdb/commands/si_matcher.rb'
- 'lib/unitsdb/commands/check_si/si_matcher.rb'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source "https://rubygems.org"
# Specify your gem's dependencies in suma.gemspec
gemspec

gem "diffy"
gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
gem "nokogiri"
gem "rake"
gem "rspec"
Expand Down
66 changes: 45 additions & 21 deletions lib/unitsdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,50 @@

require "lutaml/model"

# Configure XML adapter for lutaml-model
Lutaml::Model::Config.configure do |config|
require "lutaml/model/xml/nokogiri_adapter"
config.xml_adapter = Lutaml::Model::Xml::NokogiriAdapter
end

module Unitsdb
autoload :CLI, "unitsdb/cli"
autoload :Config, "unitsdb/config"
autoload :Commands, "unitsdb/commands"
autoload :Database, "unitsdb/database"
autoload :Dimension, "unitsdb/dimension"
autoload :DimensionDetails, "unitsdb/dimension_details"
autoload :DimensionReference, "unitsdb/dimension_reference"
autoload :Dimensions, "unitsdb/dimensions"
autoload :Errors, "unitsdb/errors"
autoload :ExternalReference, "unitsdb/external_reference"
autoload :Identifier, "unitsdb/identifier"
autoload :LocalizedString, "unitsdb/localized_string"
autoload :Prefix, "unitsdb/prefix"
autoload :PrefixReference, "unitsdb/prefix_reference"
autoload :Prefixes, "unitsdb/prefixes"
autoload :Quantities, "unitsdb/quantities"
autoload :Quantity, "unitsdb/quantity"
autoload :QuantityReference, "unitsdb/quantity_reference"
autoload :QudtUnit, "unitsdb/qudt"
autoload :QudtQuantityKind, "unitsdb/qudt"
autoload :QudtDimensionVector, "unitsdb/qudt"
autoload :QudtSystemOfUnits, "unitsdb/qudt"
autoload :QudtPrefix, "unitsdb/qudt"
autoload :QudtVocabularies, "unitsdb/qudt"
autoload :RootUnitReference, "unitsdb/root_unit_reference"
autoload :Scale, "unitsdb/scale"
autoload :ScaleProperties, "unitsdb/scale_properties"
autoload :ScaleReference, "unitsdb/scale_reference"
autoload :Scales, "unitsdb/scales"
autoload :SiDerivedBase, "unitsdb/si_derived_base"
autoload :SymbolPresentations, "unitsdb/symbol_presentations"
autoload :UcumBaseUnit, "unitsdb/ucum"
autoload :UcumPrefixValue, "unitsdb/ucum"
autoload :UcumPrefix, "unitsdb/ucum"
autoload :UcumUnitValueFunction, "unitsdb/ucum"
autoload :UcumUnitValue, "unitsdb/ucum"
autoload :UcumUnit, "unitsdb/ucum"
autoload :UcumFile, "unitsdb/ucum"
autoload :Unit, "unitsdb/unit"
autoload :UnitReference, "unitsdb/unit_reference"
autoload :UnitSystem, "unitsdb/unit_system"
autoload :UnitSystemReference, "unitsdb/unit_system_reference"
autoload :UnitSystems, "unitsdb/unit_systems"
autoload :Units, "unitsdb/units"
autoload :Utils, "unitsdb/utils"
end

require_relative "unitsdb/version"
require_relative "unitsdb/config"
require_relative "unitsdb/errors"
require_relative "unitsdb/database"
require_relative "unitsdb/dimensions"
require_relative "unitsdb/prefixes"
require_relative "unitsdb/quantities"
require_relative "unitsdb/unit_systems"
require_relative "unitsdb/scales"
require_relative "unitsdb/units"
require_relative "unitsdb/utils"

# CLI-related requires
require_relative "unitsdb/cli" if defined?(Thor)
11 changes: 1 addition & 10 deletions lib/unitsdb/cli.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# frozen_string_literal: true

require "thor"
require_relative "commands/base"
require_relative "commands/validate"
require_relative "commands/_modify"
require_relative "commands/ucum"
require_relative "commands/qudt"
require "fileutils"

module Unitsdb
Expand Down Expand Up @@ -41,7 +36,6 @@ def self.exit_on_failure?
desc: "Path to UnitsDB database (required)"

def search(query)
require_relative "commands/search"
Commands::Search.new(options).run(query)
end

Expand All @@ -53,7 +47,6 @@ def search(query)
option :database, type: :string, required: true, aliases: "-d",
desc: "Path to UnitsDB database (required)"
def get(id)
require_relative "commands/get"
Commands::Get.new(options).get(id)
end

Expand All @@ -73,8 +66,7 @@ def get(id)
desc: "Path to UnitsDB database (required)"

def check_si
require_relative "commands/check_si"
Commands::CheckSi.new(options).run
Commands::CheckSiCommand.new(options).run
end

desc "release", "Create release files (unified YAML and/or ZIP archive)"
Expand All @@ -87,7 +79,6 @@ def check_si
option :database, type: :string, required: true, aliases: "-d",
desc: "Path to UnitsDB database (required)"
def release
require_relative "commands/release"
Commands::Release.new(options).run
end
end
Expand Down
20 changes: 20 additions & 0 deletions lib/unitsdb/commands.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Unitsdb
module Commands
autoload :ModifyCommand, "unitsdb/commands/_modify"
autoload :Base, "unitsdb/commands/base"
autoload :CheckSi, "unitsdb/commands/check_si"
autoload :CheckSiCommand, "unitsdb/commands/check_si"
autoload :Get, "unitsdb/commands/get"
autoload :Normalize, "unitsdb/commands/normalize"
autoload :Qudt, "unitsdb/commands/qudt"
autoload :QudtCommand, "unitsdb/commands/qudt"
autoload :Release, "unitsdb/commands/release"
autoload :Search, "unitsdb/commands/search"
autoload :Ucum, "unitsdb/commands/ucum"
autoload :UcumCommand, "unitsdb/commands/ucum"
autoload :Validate, "unitsdb/commands/validate"
autoload :ValidateCommand, "unitsdb/commands/validate"
end
end
1 change: 0 additions & 1 deletion lib/unitsdb/commands/_modify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class ModifyCommand < Thor
desc: "Process all YAML files in the repository"

def normalize(input = nil, output = nil)
require_relative "normalize"
Normalize.new(options).run(input, output)
end
end
Expand Down
Loading
Loading