unitsdb 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +8 -1
  3. data/.gitignore +2 -0
  4. data/.gitmodules +4 -3
  5. data/.rubocop.yml +13 -8
  6. data/.rubocop_todo.yml +217 -100
  7. data/CLAUDE.md +55 -0
  8. data/Gemfile +4 -1
  9. data/README.adoc +283 -16
  10. data/data/dimensions.yaml +1864 -0
  11. data/data/prefixes.yaml +874 -0
  12. data/data/quantities.yaml +3715 -0
  13. data/data/scales.yaml +97 -0
  14. data/data/schemas/dimensions-schema.yaml +153 -0
  15. data/data/schemas/prefixes-schema.yaml +155 -0
  16. data/data/schemas/quantities-schema.yaml +117 -0
  17. data/data/schemas/scales-schema.yaml +106 -0
  18. data/data/schemas/unit_systems-schema.yaml +116 -0
  19. data/data/schemas/units-schema.yaml +215 -0
  20. data/data/unit_systems.yaml +78 -0
  21. data/data/units.yaml +14052 -0
  22. data/exe/unitsdb +7 -1
  23. data/lib/unitsdb/cli.rb +42 -15
  24. data/lib/unitsdb/commands/_modify.rb +40 -4
  25. data/lib/unitsdb/commands/base.rb +6 -2
  26. data/lib/unitsdb/commands/check_si/si_formatter.rb +488 -0
  27. data/lib/unitsdb/commands/check_si/si_matcher.rb +487 -0
  28. data/lib/unitsdb/commands/check_si/si_ttl_parser.rb +103 -0
  29. data/lib/unitsdb/commands/check_si/si_updater.rb +254 -0
  30. data/lib/unitsdb/commands/check_si.rb +54 -35
  31. data/lib/unitsdb/commands/get.rb +11 -10
  32. data/lib/unitsdb/commands/normalize.rb +21 -7
  33. data/lib/unitsdb/commands/qudt/check.rb +150 -0
  34. data/lib/unitsdb/commands/qudt/formatter.rb +194 -0
  35. data/lib/unitsdb/commands/qudt/matcher.rb +746 -0
  36. data/lib/unitsdb/commands/qudt/ttl_parser.rb +403 -0
  37. data/lib/unitsdb/commands/qudt/update.rb +126 -0
  38. data/lib/unitsdb/commands/qudt/updater.rb +189 -0
  39. data/lib/unitsdb/commands/qudt.rb +82 -0
  40. data/lib/unitsdb/commands/release.rb +12 -9
  41. data/lib/unitsdb/commands/search.rb +12 -11
  42. data/lib/unitsdb/commands/ucum/check.rb +42 -29
  43. data/lib/unitsdb/commands/ucum/formatter.rb +2 -1
  44. data/lib/unitsdb/commands/ucum/matcher.rb +23 -9
  45. data/lib/unitsdb/commands/ucum/update.rb +14 -13
  46. data/lib/unitsdb/commands/ucum/updater.rb +40 -6
  47. data/lib/unitsdb/commands/ucum/xml_parser.rb +0 -2
  48. data/lib/unitsdb/commands/ucum.rb +44 -4
  49. data/lib/unitsdb/commands/validate/identifiers.rb +2 -4
  50. data/lib/unitsdb/commands/validate/qudt_references.rb +111 -0
  51. data/lib/unitsdb/commands/validate/references.rb +36 -19
  52. data/lib/unitsdb/commands/validate/si_references.rb +3 -5
  53. data/lib/unitsdb/commands/validate/ucum_references.rb +105 -0
  54. data/lib/unitsdb/commands/validate.rb +67 -11
  55. data/lib/unitsdb/commands.rb +20 -0
  56. data/lib/unitsdb/database.rb +90 -52
  57. data/lib/unitsdb/dimension.rb +1 -4
  58. data/lib/unitsdb/dimension_details.rb +0 -1
  59. data/lib/unitsdb/dimensions.rb +0 -2
  60. data/lib/unitsdb/errors.rb +7 -0
  61. data/lib/unitsdb/prefix.rb +0 -4
  62. data/lib/unitsdb/prefix_reference.rb +0 -2
  63. data/lib/unitsdb/prefixes.rb +0 -1
  64. data/lib/unitsdb/quantities.rb +0 -2
  65. data/lib/unitsdb/quantity.rb +0 -6
  66. data/lib/unitsdb/qudt.rb +100 -0
  67. data/lib/unitsdb/root_unit_reference.rb +0 -3
  68. data/lib/unitsdb/scale.rb +0 -4
  69. data/lib/unitsdb/scale_reference.rb +0 -2
  70. data/lib/unitsdb/scales.rb +0 -2
  71. data/lib/unitsdb/si_derived_base.rb +0 -2
  72. data/lib/unitsdb/ucum.rb +14 -10
  73. data/lib/unitsdb/unit.rb +0 -10
  74. data/lib/unitsdb/unit_reference.rb +0 -2
  75. data/lib/unitsdb/unit_system.rb +1 -3
  76. data/lib/unitsdb/unit_system_reference.rb +0 -2
  77. data/lib/unitsdb/unit_systems.rb +0 -2
  78. data/lib/unitsdb/units.rb +0 -2
  79. data/lib/unitsdb/utils.rb +32 -21
  80. data/lib/unitsdb/version.rb +5 -1
  81. data/lib/unitsdb.rb +62 -14
  82. data/unitsdb.gemspec +6 -3
  83. metadata +52 -13
  84. data/lib/unitsdb/commands/si_formatter.rb +0 -485
  85. data/lib/unitsdb/commands/si_matcher.rb +0 -470
  86. data/lib/unitsdb/commands/si_ttl_parser.rb +0 -100
  87. data/lib/unitsdb/commands/si_updater.rb +0 -212
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d26a180d24908f27758427140cfc5e01380afc6441ae2f96856523c2dc8f1d9
4
- data.tar.gz: 3bc8f78dab0ed305d7f48bdcd07356b3914e87d9a096bdc5fb0cc177c1350d48
3
+ metadata.gz: 7fda421d6dfc06976fad5da00dd85f0fb1dbb3dc4865e2904a28b237530ace05
4
+ data.tar.gz: 9e4fdd8395fab543936c4d4b415f05c468b788d287545d3ebfd774a53a9f766c
5
5
  SHA512:
6
- metadata.gz: 8601b692c2c4e0e6191e4e0c3f74a963325c63bd4a0830e20bf7ba1216f514557af8792c137acbd2f233919df6769d90604035f9bd4a8f99f872cb5959921a2e
7
- data.tar.gz: 02f631a8c47820816d6415c30d78cb21d16eff2d00dc71ba652fd17a6b7f3e310e874ea1fa21fcb0a0ee71c65d2950dac07a3fde08cc34df8cf4e477550f5b4a
6
+ metadata.gz: 8453d7f411242d4fbf035b73cee6d968505c60e884606b872317a1fe53dd93b3e603a0497c1869b1768649dbf2c23a6fdcbe233dccf4eee95f482f1d440f2163
7
+ data.tar.gz: 5a7d1579b935b9afb7bb5e4c0ab8c25e943be6b525d401411bf97d8b3101061a0b211631af0740dcd3476fb012c2c3048dadc0399ec75f91ed425e8416bbd59e
@@ -2,12 +2,18 @@
2
2
  # See https://github.com/metanorma/cimas
3
3
  name: release
4
4
 
5
+ permissions:
6
+ contents: write
7
+ packages: write
8
+ id-token: write
9
+
5
10
  on:
6
11
  workflow_dispatch:
7
12
  inputs:
8
13
  next_version:
9
14
  description: |
10
- Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
15
+ Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
16
+ Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
11
17
  required: true
12
18
  default: 'skip'
13
19
  repository_dispatch:
@@ -18,6 +24,7 @@ jobs:
18
24
  uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
19
25
  with:
20
26
  next_version: ${{ github.event.inputs.next_version }}
27
+ submodules: true
21
28
  secrets:
22
29
  rubygems-api-key: ${{ secrets.UNITSML_CI_RUBYGEMS_API_KEY }}
23
30
  pat_token: ${{ secrets.UNITSML_CI_PAT_TOKEN }}
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ Gemfile.lock
data/.gitmodules CHANGED
@@ -1,3 +1,4 @@
1
- [submodule "spec/fixtures/unitsdb"]
2
- path = spec/fixtures/unitsdb
3
- url = https://github.com/unitsml/unitsdb/
1
+ [submodule "data"]
2
+ path = data
3
+ url = https://github.com/unitsml/unitsdb.git
4
+ branch = refs/tags/v2.0.0
data/.rubocop.yml CHANGED
@@ -1,10 +1,15 @@
1
- inherit_from: .rubocop_todo.yml
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
3
+ - .rubocop_todo.yml
2
4
 
3
- AllCops:
4
- TargetRubyVersion: 3.0
5
-
6
- Style/StringLiterals:
7
- EnforcedStyle: double_quotes
5
+ plugins:
6
+ - rubocop-performance
7
+ - rubocop-rake
8
+ - rubocop-rspec
8
9
 
9
- Style/StringLiteralsInInterpolation:
10
- EnforcedStyle: double_quotes
10
+ AllCops:
11
+ TargetRubyVersion: 3.1
12
+ NewCops: enable
13
+ Exclude:
14
+ - 'vendor/**/*'
15
+ - 'data/**/*'
data/.rubocop_todo.yml CHANGED
@@ -1,33 +1,55 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-05-21 10:17:19 UTC using RuboCop version 1.75.6.
3
+ # on 2026-04-03 22:15:03 UTC using RuboCop version 1.86.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
+ Gemspec/RequiredRubyVersion:
11
+ Exclude:
12
+ - 'unitsdb.gemspec'
13
+
14
+ # Offense count: 9
10
15
  # This cop supports safe autocorrection (--autocorrect).
11
16
  # Configuration parameters: EnforcedStyle, IndentationWidth.
12
- # SupportedStyles: with_first_element, with_fixed_indentation
13
- Layout/ArrayAlignment:
17
+ # SupportedStyles: with_first_argument, with_fixed_indentation
18
+ Layout/ArgumentAlignment:
14
19
  Exclude:
15
- - 'lib/unitsdb/commands/ucum/check.rb'
20
+ - 'lib/unitsdb/commands/get.rb'
21
+ - 'lib/unitsdb/commands/release.rb'
22
+ - 'lib/unitsdb/commands/search.rb'
23
+ - 'lib/unitsdb/commands/validate/identifiers.rb'
24
+ - 'lib/unitsdb/commands/validate/qudt_references.rb'
25
+ - 'lib/unitsdb/commands/validate/references.rb'
26
+ - 'lib/unitsdb/commands/validate/si_references.rb'
27
+ - 'lib/unitsdb/commands/validate/ucum_references.rb'
28
+ - 'spec/unitsdb/commands/normalize_spec.rb'
16
29
 
17
- # Offense count: 1
30
+ # Offense count: 6
18
31
  # This cop supports safe autocorrection (--autocorrect).
19
- # Configuration parameters: AutoCorrect, AllowBorderComment, AllowMarginComment.
20
- Layout/EmptyComment:
32
+ # Configuration parameters: EnforcedStyleAlignWith.
33
+ # SupportedStylesAlignWith: either, start_of_block, start_of_line
34
+ Layout/BlockAlignment:
21
35
  Exclude:
22
- - 'ucum-test.rb'
36
+ - 'spec/unitsdb/commands/normalize_spec.rb'
37
+ - 'spec/unitsdb/commands/qudt/update_spec.rb'
38
+ - 'spec/unitsdb/commands/search_spec.rb'
39
+ - 'spec/unitsdb/commands/validate/qudt_references_spec.rb'
40
+ - 'spec/unitsdb/commands/validate/ucum_references_spec.rb'
23
41
 
24
- # Offense count: 1
42
+ # Offense count: 5
25
43
  # This cop supports safe autocorrection (--autocorrect).
26
- Layout/EmptyLineAfterMagicComment:
44
+ Layout/BlockEndNewline:
27
45
  Exclude:
28
- - 'ucum-test.rb'
46
+ - 'spec/unitsdb/commands/normalize_spec.rb'
47
+ - 'spec/unitsdb/commands/qudt/update_spec.rb'
48
+ - 'spec/unitsdb/commands/search_spec.rb'
49
+ - 'spec/unitsdb/commands/validate/qudt_references_spec.rb'
50
+ - 'spec/unitsdb/commands/validate/ucum_references_spec.rb'
29
51
 
30
- # Offense count: 4
52
+ # Offense count: 5
31
53
  # This cop supports safe autocorrection (--autocorrect).
32
54
  # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
33
55
  # SupportedHashRocketStyles: key, separator, table
@@ -35,154 +57,249 @@ Layout/EmptyLineAfterMagicComment:
35
57
  # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
36
58
  Layout/HashAlignment:
37
59
  Exclude:
38
- - 'spec/unitsdb/commands/ucum/update_spec.rb'
60
+ - 'lib/unitsdb/cli.rb'
61
+ - 'lib/unitsdb/commands/_modify.rb'
62
+ - 'lib/unitsdb/commands/qudt.rb'
63
+ - 'lib/unitsdb/commands/ucum.rb'
64
+ - 'lib/unitsdb/commands/validate.rb'
39
65
 
40
- # Offense count: 5
66
+ # Offense count: 10
41
67
  # This cop supports safe autocorrection (--autocorrect).
42
- # Configuration parameters: AllowInHeredoc.
43
- Layout/TrailingWhitespace:
68
+ # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
69
+ # SupportedStylesAlignWith: start_of_line, relative_to_receiver
70
+ Layout/IndentationWidth:
44
71
  Exclude:
45
- - 'lib/unitsdb/commands/ucum/check.rb'
46
- - 'spec/unitsdb/commands/ucum/update_spec.rb'
72
+ - 'spec/unitsdb/commands/normalize_spec.rb'
73
+ - 'spec/unitsdb/commands/qudt/update_spec.rb'
74
+ - 'spec/unitsdb/commands/search_spec.rb'
75
+ - 'spec/unitsdb/commands/validate/qudt_references_spec.rb'
76
+ - 'spec/unitsdb/commands/validate/ucum_references_spec.rb'
47
77
 
48
- # Offense count: 1
49
- # This cop supports unsafe autocorrection (--autocorrect-all).
50
- # Configuration parameters: AllowSafeAssignment.
51
- Lint/AssignmentInCondition:
52
- Exclude:
53
- - 'lib/unitsdb/commands/ucum/updater.rb'
78
+ # Offense count: 393
79
+ # This cop supports safe autocorrection (--autocorrect).
80
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
81
+ # URISchemes: http, https
82
+ Layout/LineLength:
83
+ Enabled: false
54
84
 
55
- # Offense count: 2
56
- Lint/ShadowingOuterLocalVariable:
85
+ # Offense count: 9
86
+ # This cop supports safe autocorrection (--autocorrect).
87
+ # Configuration parameters: AllowInHeredoc.
88
+ Layout/TrailingWhitespace:
57
89
  Exclude:
90
+ - 'lib/unitsdb/commands/get.rb'
91
+ - 'lib/unitsdb/commands/release.rb'
58
92
  - 'lib/unitsdb/commands/search.rb'
93
+ - 'lib/unitsdb/commands/validate/identifiers.rb'
94
+ - 'lib/unitsdb/commands/validate/qudt_references.rb'
95
+ - 'lib/unitsdb/commands/validate/references.rb'
59
96
  - 'lib/unitsdb/commands/validate/si_references.rb'
97
+ - 'lib/unitsdb/commands/validate/ucum_references.rb'
98
+ - 'spec/unitsdb/commands/normalize_spec.rb'
60
99
 
61
- # Offense count: 47
62
- # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
100
+ # Offense count: 9
101
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
102
+ Lint/DuplicateBranch:
103
+ Exclude:
104
+ - 'lib/unitsdb/commands/check_si/si_formatter.rb'
105
+ - 'lib/unitsdb/commands/qudt/matcher.rb'
106
+ - 'lib/unitsdb/commands/ucum/matcher.rb'
107
+ - 'lib/unitsdb/database.rb'
108
+
109
+ # Offense count: 82
110
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
63
111
  Metrics/AbcSize:
64
- Max: 169
112
+ Enabled: false
65
113
 
66
- # Offense count: 31
67
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
114
+ # Offense count: 12
115
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
68
116
  # AllowedMethods: refine
69
117
  Metrics/BlockLength:
70
- Max: 173
118
+ Max: 62
71
119
 
72
- # Offense count: 3
73
- # Configuration parameters: CountComments, CountAsOne.
74
- Metrics/ClassLength:
75
- Max: 442
76
-
77
- # Offense count: 45
78
- # Configuration parameters: AllowedMethods, AllowedPatterns.
120
+ # Offense count: 73
121
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
79
122
  Metrics/CyclomaticComplexity:
80
- Max: 50
123
+ Enabled: false
81
124
 
82
- # Offense count: 58
125
+ # Offense count: 110
83
126
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
84
127
  Metrics/MethodLength:
85
- Max: 169
86
-
87
- # Offense count: 5
88
- # Configuration parameters: CountComments, CountAsOne.
89
- Metrics/ModuleLength:
90
- Max: 369
128
+ Max: 150
91
129
 
92
130
  # Offense count: 2
93
131
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
94
132
  Metrics/ParameterLists:
95
133
  Max: 6
96
134
 
97
- # Offense count: 39
98
- # Configuration parameters: AllowedMethods, AllowedPatterns.
135
+ # Offense count: 64
136
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
99
137
  Metrics/PerceivedComplexity:
100
- Max: 56
101
-
102
- # Offense count: 1
103
- Naming/AccessorMethodName:
104
- Exclude:
105
- - 'lib/unitsdb/commands/si_formatter.rb'
138
+ Enabled: false
106
139
 
107
140
  # Offense count: 3
108
141
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
109
142
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
110
143
  Naming/MethodParameterName:
111
144
  Exclude:
112
- - 'lib/unitsdb/commands/si_ttl_parser.rb'
145
+ - 'lib/unitsdb/commands/check_si/si_ttl_parser.rb'
113
146
  - 'lib/unitsdb/utils.rb'
114
147
 
115
- # Offense count: 1
116
- # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
117
- # NamePrefix: is_, has_, have_, does_
118
- # ForbiddenPrefixes: is_, has_, have_, does_
119
- # AllowedMethods: is_a?
120
- # MethodDefinitionMacros: define_method, define_singleton_method
121
- Naming/PredicateName:
148
+ # Offense count: 9
149
+ # Configuration parameters: MinSize.
150
+ Performance/CollectionLiteralInLoop:
122
151
  Exclude:
123
- - 'spec/**/*'
124
- - 'lib/unitsdb/commands/ucum/matcher.rb'
152
+ - 'lib/unitsdb/commands/check_si/si_formatter.rb'
153
+ - 'lib/unitsdb/commands/check_si/si_matcher.rb'
154
+ - 'lib/unitsdb/commands/check_si/si_updater.rb'
155
+ - 'lib/unitsdb/database.rb'
125
156
 
126
- # Offense count: 1
127
- # This cop supports unsafe autocorrection (--autocorrect-all).
128
- Style/CombinableLoops:
157
+ # Offense count: 2
158
+ RSpec/BeforeAfterAll:
129
159
  Exclude:
130
- - 'lib/unitsdb/commands/si_matcher.rb'
160
+ - '**/spec/spec_helper.rb'
161
+ - '**/spec/rails_helper.rb'
162
+ - '**/spec/support/**/*.rb'
163
+ - 'spec/unitsdb/commands/validate/references_spec.rb'
131
164
 
132
- # Offense count: 48
133
- # Configuration parameters: AllowedConstants.
134
- Style/Documentation:
135
- Enabled: false
165
+ # Offense count: 2
166
+ # Configuration parameters: Prefixes, AllowedPatterns.
167
+ # Prefixes: when, with, without
168
+ RSpec/ContextWording:
169
+ Exclude:
170
+ - 'spec/unitsdb/commands/check_si_command_spec.rb'
171
+
172
+ # Offense count: 2
173
+ # Configuration parameters: IgnoredMetadata.
174
+ RSpec/DescribeClass:
175
+ Exclude:
176
+ - '**/spec/features/**/*'
177
+ - '**/spec/requests/**/*'
178
+ - '**/spec/routing/**/*'
179
+ - '**/spec/system/**/*'
180
+ - '**/spec/views/**/*'
181
+ - 'spec/exe/unitsdb_spec.rb'
182
+ - 'spec/unitsdb/version_compatibility_spec.rb'
183
+
184
+ # Offense count: 43
185
+ # Configuration parameters: CountAsOne.
186
+ RSpec/ExampleLength:
187
+ Max: 30
188
+
189
+ # Offense count: 22
190
+ RSpec/ExpectOutput:
191
+ Exclude:
192
+ - 'spec/unitsdb/commands/check_si_command_spec.rb'
193
+ - 'spec/unitsdb/commands/get_spec.rb'
194
+ - 'spec/unitsdb/commands/normalize_spec.rb'
195
+ - 'spec/unitsdb/commands/search_spec.rb'
196
+ - 'spec/unitsdb/commands/validate/identifiers_spec.rb'
197
+ - 'spec/unitsdb/commands/validate/si_references_spec.rb'
198
+
199
+ # Offense count: 8
200
+ RSpec/LeakyLocalVariable:
201
+ Exclude:
202
+ - 'spec/unitsdb/database_spec.rb'
203
+ - 'spec/unitsdb/dimensions_spec.rb'
204
+ - 'spec/unitsdb/prefixes_spec.rb'
205
+ - 'spec/unitsdb/quantities_spec.rb'
206
+ - 'spec/unitsdb/scales_spec.rb'
207
+ - 'spec/unitsdb/unit_spec.rb'
208
+ - 'spec/unitsdb/unit_systems_spec.rb'
209
+ - 'spec/unitsdb/units_spec.rb'
210
+
211
+ # Offense count: 6
212
+ # Configuration parameters: .
213
+ # SupportedStyles: have_received, receive
214
+ RSpec/MessageSpies:
215
+ EnforcedStyle: receive
216
+
217
+ # Offense count: 52
218
+ RSpec/MultipleExpectations:
219
+ Max: 15
220
+
221
+ # Offense count: 3
222
+ # Configuration parameters: AllowSubject.
223
+ RSpec/MultipleMemoizedHelpers:
224
+ Max: 6
225
+
226
+ # Offense count: 2
227
+ # Configuration parameters: AllowedGroups.
228
+ RSpec/NestedGroups:
229
+ Max: 4
230
+
231
+ # Offense count: 2
232
+ RSpec/RepeatedExample:
233
+ Exclude:
234
+ - 'spec/exe/unitsdb_spec.rb'
136
235
 
137
236
  # Offense count: 1
237
+ # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
238
+ # SupportedInflectors: default, active_support
239
+ RSpec/SpecFilePathFormat:
240
+ Exclude:
241
+ - '**/spec/routing/**/*'
242
+ - 'spec/unitsdb/bundled_data_spec.rb'
243
+
244
+ # Offense count: 17
245
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
246
+ RSpec/VerifiedDoubles:
247
+ Exclude:
248
+ - 'spec/unitsdb/commands/validate/qudt_references_spec.rb'
249
+ - 'spec/unitsdb/commands/validate/references_spec.rb'
250
+ - 'spec/unitsdb/commands/validate/ucum_references_spec.rb'
251
+
252
+ # Offense count: 5
138
253
  # This cop supports safe autocorrection (--autocorrect).
139
- # Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments.
140
- # SupportedStyles: empty, nil, both
141
- Style/EmptyElse:
254
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
255
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
256
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
257
+ # FunctionalMethods: let, let!, subject, watch
258
+ # AllowedMethods: lambda, proc, it
259
+ Style/BlockDelimiters:
142
260
  Exclude:
143
- - 'lib/unitsdb/commands/ucum/updater.rb'
261
+ - 'spec/unitsdb/commands/normalize_spec.rb'
262
+ - 'spec/unitsdb/commands/qudt/update_spec.rb'
263
+ - 'spec/unitsdb/commands/search_spec.rb'
264
+ - 'spec/unitsdb/commands/validate/qudt_references_spec.rb'
265
+ - 'spec/unitsdb/commands/validate/ucum_references_spec.rb'
144
266
 
145
267
  # Offense count: 1
146
268
  # This cop supports unsafe autocorrection (--autocorrect-all).
147
- # Configuration parameters: EnforcedStyle.
148
- # SupportedStyles: always, always_true, never
149
- Style/FrozenStringLiteralComment:
269
+ Style/CombinableLoops:
150
270
  Exclude:
151
- - '**/*.arb'
152
- - 'ucum-test.rb'
271
+ - 'lib/unitsdb/commands/check_si/si_matcher.rb'
153
272
 
154
273
  # Offense count: 2
155
274
  # This cop supports unsafe autocorrection (--autocorrect-all).
156
275
  Style/IdenticalConditionalBranches:
157
276
  Exclude:
158
- - 'lib/unitsdb/commands/si_formatter.rb'
277
+ - 'lib/unitsdb/commands/check_si/si_formatter.rb'
159
278
 
160
279
  # Offense count: 1
161
- Style/MultilineBlockChain:
280
+ # This cop supports unsafe autocorrection (--autocorrect-all).
281
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
282
+ # SupportedStyles: predicate, comparison
283
+ Style/NumericPredicate:
162
284
  Exclude:
163
- - 'lib/unitsdb/commands/normalize.rb'
285
+ - 'spec/**/*'
286
+ - 'exe/unitsdb'
164
287
 
165
- # Offense count: 9
288
+ # Offense count: 14
166
289
  # Configuration parameters: AllowedMethods.
167
290
  # AllowedMethods: respond_to_missing?
168
291
  Style/OptionalBooleanParameter:
169
292
  Exclude:
170
293
  - 'lib/unitsdb/commands/check_si.rb'
171
- - 'lib/unitsdb/commands/si_updater.rb'
294
+ - 'lib/unitsdb/commands/check_si/si_updater.rb'
295
+ - 'lib/unitsdb/commands/qudt/check.rb'
296
+ - 'lib/unitsdb/commands/qudt/update.rb'
297
+ - 'lib/unitsdb/commands/qudt/updater.rb'
172
298
  - 'lib/unitsdb/commands/ucum/check.rb'
173
299
  - 'lib/unitsdb/commands/ucum/updater.rb'
174
300
 
175
- # Offense count: 7
176
- # This cop supports unsafe autocorrection (--autocorrect-all).
177
- # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
178
- # AllowedMethods: present?, blank?, presence, try, try!
179
- Style/SafeNavigation:
301
+ # Offense count: 1
302
+ # Configuration parameters: Max.
303
+ Style/SafeNavigationChainLength:
180
304
  Exclude:
181
- - 'lib/unitsdb/commands/ucum/matcher.rb'
182
-
183
- # Offense count: 12
184
- # This cop supports safe autocorrection (--autocorrect).
185
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
186
- # URISchemes: http, https
187
- Layout/LineLength:
188
- Max: 140
305
+ - 'lib/unitsdb/commands/check_si/si_matcher.rb'
data/CLAUDE.md ADDED
@@ -0,0 +1,55 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Development Commands
6
+
7
+ ```bash
8
+ bundle install # Install dependencies
9
+ bundle exec rake # Run full default task (rspec + rubocop)
10
+ bundle exec rspec # Run all tests
11
+ bundle exec rspec spec/path/to/file_spec.rb # Run single spec
12
+ bundle exec rubocop # Lint all files
13
+ bundle exec rake build # Build the gem
14
+ ```
15
+
16
+ ## Architecture
17
+
18
+ ### Bundled Data
19
+
20
+ 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.
21
+
22
+ Two entry points for the bundled data:
23
+ - `Unitsdb.data_dir` — path to the `data/` directory inside the gem
24
+ - `Unitsdb.database` — pre-loaded `Database.from_db(data_dir)` instance (cached)
25
+
26
+ The correspondence between gem version and data version is tracked via
27
+ `Unitsdb::UNITS_DATA_VERSION` (e.g. `"2.0.0"`). **The UnitsDB data must be
28
+ released (tagged) before the gem can be released with updated data.** When
29
+ releasing with new data: tag the data in `unitsml/unitsdb`, then update
30
+ `.gitmodules` (`branch = refs/tags/new-data-tag`) and bump both `VERSION` and
31
+ `UNITS_DATA_VERSION` in `lib/unitsdb/version.rb`.
32
+
33
+ ### Core Classes
34
+
35
+ - **`Unitsdb::Database`** — Loads all YAML files, provides `search`, `get_by_id`, `find_by_type`, `find_by_symbol`, `match_entities`, `validate_uniqueness`, `validate_references`
36
+ - **`Unitsdb::Cli`** (Thor-based) — Command-line interface with subcommands: `validate`, `search`, `get`, `check_si`, `ucum`, `qudt`, `_modify`, `release`
37
+ - **`lib/unitsdb/commands/base.rb`** — Base class for commands; provides `load_database` and `@options[:database]`
38
+
39
+ ### Model Pattern
40
+
41
+ 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.
42
+
43
+ ### Workflow Files
44
+
45
+ Workflows in `.github/workflows/` are auto-generated by **Cimas** (metanorma/cimas) and delegate to shared reusable workflows in `metanorma/ci`:
46
+ - `rake.yml` → `generic-rake.yml@main` — runs tests/lint on push/PR
47
+ - `release.yml` → `rubygems-release.yml@main` — builds and publishes gem
48
+ - `dependent-gems.yml` → `dependent-rake.yml@main` — tests downstream consumers
49
+
50
+ ### Git Submodule
51
+
52
+ `data/` is a git submodule pinned to a specific tag in https://github.com/unitsml/unitsdb
53
+ (e.g. `branch = refs/tags/v2.0.0` in `.gitmodules`). The CI `rake.yml` uses
54
+ `submodules: 'recursive'` so tests have the data available. The release workflow
55
+ uses `submodules: true` to initialize the submodule during checkout.
data/Gemfile CHANGED
@@ -5,9 +5,12 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in suma.gemspec
6
6
  gemspec
7
7
 
8
- gem "diffy"
8
+ gem "canon"
9
+ gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
9
10
  gem "nokogiri"
10
11
  gem "rake"
11
12
  gem "rspec"
12
13
  gem "rubocop"
13
14
  gem "rubocop-performance"
15
+ gem "rubocop-rake"
16
+ gem "rubocop-rspec"