unitsdb 2.1.0 → 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 +247 -53
  7. data/CLAUDE.md +55 -0
  8. data/Gemfile +5 -1
  9. data/README.adoc +385 -12
  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 +47 -13
  24. data/lib/unitsdb/commands/_modify.rb +41 -5
  25. data/lib/unitsdb/commands/base.rb +10 -32
  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 +50 -86
  41. data/lib/unitsdb/commands/search.rb +12 -11
  42. data/lib/unitsdb/commands/ucum/check.rb +139 -0
  43. data/lib/unitsdb/commands/ucum/formatter.rb +142 -0
  44. data/lib/unitsdb/commands/ucum/matcher.rb +315 -0
  45. data/lib/unitsdb/commands/ucum/update.rb +85 -0
  46. data/lib/unitsdb/commands/ucum/updater.rb +132 -0
  47. data/lib/unitsdb/commands/ucum/xml_parser.rb +32 -0
  48. data/lib/unitsdb/commands/ucum.rb +83 -0
  49. data/lib/unitsdb/commands/validate/identifiers.rb +3 -3
  50. data/lib/unitsdb/commands/validate/qudt_references.rb +111 -0
  51. data/lib/unitsdb/commands/validate/references.rb +37 -18
  52. data/lib/unitsdb/commands/validate/si_references.rb +3 -11
  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 +91 -52
  57. data/lib/unitsdb/dimension.rb +1 -4
  58. data/lib/unitsdb/dimension_details.rb +0 -1
  59. data/lib/unitsdb/dimensions.rb +1 -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 +1 -1
  64. data/lib/unitsdb/quantities.rb +1 -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 +1 -2
  71. data/lib/unitsdb/si_derived_base.rb +0 -2
  72. data/lib/unitsdb/ucum.rb +202 -0
  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 +1 -2
  78. data/lib/unitsdb/units.rb +1 -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 -5
  83. metadata +60 -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: 4b92f561a56f8cdd59a905cf7827c6ffda47acae64f1e31256f2c5efebfd81f2
4
- data.tar.gz: 218a47cf5fb2c178f787f05e186c09f5b40d0f4914b81d6de5884759011621ef
3
+ metadata.gz: 7fda421d6dfc06976fad5da00dd85f0fb1dbb3dc4865e2904a28b237530ace05
4
+ data.tar.gz: 9e4fdd8395fab543936c4d4b415f05c468b788d287545d3ebfd774a53a9f766c
5
5
  SHA512:
6
- metadata.gz: 82bd1ac58073379426b3378bda8b94e0bcdf46f954148d082b6008931d0c49c0c50d35b53ac64661a75e0f58bfedf46a5f53e0e948e5520584711a0260ebe638
7
- data.tar.gz: ff4538f70410cc9572f7a7719bf32aa1324f6e2cdaf7fe95acbd6426b31168b9c4ba72271d81fe8a76dd1339aa0d3d3307424a878b4cb11e96be5af9897078b0
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,111 +1,305 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-05-20 11:22:36 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
- # Configuration parameters: Severity, Include.
11
- # Include: **/*.gemspec
12
- Gemspec/DuplicatedAssignment:
10
+ Gemspec/RequiredRubyVersion:
13
11
  Exclude:
14
12
  - 'unitsdb.gemspec'
15
13
 
16
- # Offense count: 2
17
- Lint/ShadowingOuterLocalVariable:
14
+ # Offense count: 9
15
+ # This cop supports safe autocorrection (--autocorrect).
16
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
17
+ # SupportedStyles: with_first_argument, with_fixed_indentation
18
+ Layout/ArgumentAlignment:
18
19
  Exclude:
20
+ - 'lib/unitsdb/commands/get.rb'
21
+ - 'lib/unitsdb/commands/release.rb'
19
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'
20
26
  - 'lib/unitsdb/commands/validate/si_references.rb'
27
+ - 'lib/unitsdb/commands/validate/ucum_references.rb'
28
+ - 'spec/unitsdb/commands/normalize_spec.rb'
29
+
30
+ # Offense count: 6
31
+ # This cop supports safe autocorrection (--autocorrect).
32
+ # Configuration parameters: EnforcedStyleAlignWith.
33
+ # SupportedStylesAlignWith: either, start_of_block, start_of_line
34
+ Layout/BlockAlignment:
35
+ Exclude:
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'
41
+
42
+ # Offense count: 5
43
+ # This cop supports safe autocorrection (--autocorrect).
44
+ Layout/BlockEndNewline:
45
+ Exclude:
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'
51
+
52
+ # Offense count: 5
53
+ # This cop supports safe autocorrection (--autocorrect).
54
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
55
+ # SupportedHashRocketStyles: key, separator, table
56
+ # SupportedColonStyles: key, separator, table
57
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
58
+ Layout/HashAlignment:
59
+ Exclude:
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'
65
+
66
+ # Offense count: 10
67
+ # This cop supports safe autocorrection (--autocorrect).
68
+ # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
69
+ # SupportedStylesAlignWith: start_of_line, relative_to_receiver
70
+ Layout/IndentationWidth:
71
+ Exclude:
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'
77
+
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
21
84
 
22
- # Offense count: 37
23
- # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
85
+ # Offense count: 9
86
+ # This cop supports safe autocorrection (--autocorrect).
87
+ # Configuration parameters: AllowInHeredoc.
88
+ Layout/TrailingWhitespace:
89
+ Exclude:
90
+ - 'lib/unitsdb/commands/get.rb'
91
+ - 'lib/unitsdb/commands/release.rb'
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'
96
+ - 'lib/unitsdb/commands/validate/si_references.rb'
97
+ - 'lib/unitsdb/commands/validate/ucum_references.rb'
98
+ - 'spec/unitsdb/commands/normalize_spec.rb'
99
+
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.
24
111
  Metrics/AbcSize:
25
- Max: 169
112
+ Enabled: false
26
113
 
27
- # Offense count: 27
28
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
114
+ # Offense count: 12
115
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
29
116
  # AllowedMethods: refine
30
117
  Metrics/BlockLength:
31
- Max: 173
32
-
33
- # Offense count: 3
34
- # Configuration parameters: CountComments, CountAsOne.
35
- Metrics/ClassLength:
36
- Max: 441
118
+ Max: 62
37
119
 
38
- # Offense count: 38
39
- # Configuration parameters: AllowedMethods, AllowedPatterns.
120
+ # Offense count: 73
121
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
40
122
  Metrics/CyclomaticComplexity:
41
- Max: 50
123
+ Enabled: false
42
124
 
43
- # Offense count: 47
125
+ # Offense count: 110
44
126
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
45
127
  Metrics/MethodLength:
46
- Max: 169
47
-
48
- # Offense count: 3
49
- # Configuration parameters: CountComments, CountAsOne.
50
- Metrics/ModuleLength:
51
- Max: 369
128
+ Max: 150
52
129
 
53
130
  # Offense count: 2
54
131
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
55
132
  Metrics/ParameterLists:
56
133
  Max: 6
57
134
 
58
- # Offense count: 33
59
- # Configuration parameters: AllowedMethods, AllowedPatterns.
135
+ # Offense count: 64
136
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
60
137
  Metrics/PerceivedComplexity:
61
- Max: 56
62
-
63
- # Offense count: 1
64
- Naming/AccessorMethodName:
65
- Exclude:
66
- - 'lib/unitsdb/commands/si_formatter.rb'
138
+ Enabled: false
67
139
 
68
140
  # Offense count: 3
69
141
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
70
142
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
71
143
  Naming/MethodParameterName:
72
144
  Exclude:
73
- - 'lib/unitsdb/commands/si_ttl_parser.rb'
145
+ - 'lib/unitsdb/commands/check_si/si_ttl_parser.rb'
74
146
  - 'lib/unitsdb/utils.rb'
75
147
 
148
+ # Offense count: 9
149
+ # Configuration parameters: MinSize.
150
+ Performance/CollectionLiteralInLoop:
151
+ Exclude:
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'
156
+
157
+ # Offense count: 2
158
+ RSpec/BeforeAfterAll:
159
+ Exclude:
160
+ - '**/spec/spec_helper.rb'
161
+ - '**/spec/rails_helper.rb'
162
+ - '**/spec/support/**/*.rb'
163
+ - 'spec/unitsdb/commands/validate/references_spec.rb'
164
+
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'
235
+
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
253
+ # This cop supports safe autocorrection (--autocorrect).
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:
260
+ Exclude:
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'
266
+
76
267
  # Offense count: 1
77
268
  # This cop supports unsafe autocorrection (--autocorrect-all).
78
269
  Style/CombinableLoops:
79
270
  Exclude:
80
- - 'lib/unitsdb/commands/si_matcher.rb'
81
-
82
- # Offense count: 40
83
- # Configuration parameters: AllowedConstants.
84
- Style/Documentation:
85
- Enabled: false
271
+ - 'lib/unitsdb/commands/check_si/si_matcher.rb'
86
272
 
87
273
  # Offense count: 2
88
274
  # This cop supports unsafe autocorrection (--autocorrect-all).
89
275
  Style/IdenticalConditionalBranches:
90
276
  Exclude:
91
- - 'lib/unitsdb/commands/si_formatter.rb'
277
+ - 'lib/unitsdb/commands/check_si/si_formatter.rb'
92
278
 
93
279
  # Offense count: 1
94
- Style/MultilineBlockChain:
280
+ # This cop supports unsafe autocorrection (--autocorrect-all).
281
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
282
+ # SupportedStyles: predicate, comparison
283
+ Style/NumericPredicate:
95
284
  Exclude:
96
- - 'lib/unitsdb/commands/normalize.rb'
285
+ - 'spec/**/*'
286
+ - 'exe/unitsdb'
97
287
 
98
- # Offense count: 5
288
+ # Offense count: 14
99
289
  # Configuration parameters: AllowedMethods.
100
290
  # AllowedMethods: respond_to_missing?
101
291
  Style/OptionalBooleanParameter:
102
292
  Exclude:
103
293
  - 'lib/unitsdb/commands/check_si.rb'
104
- - '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'
298
+ - 'lib/unitsdb/commands/ucum/check.rb'
299
+ - 'lib/unitsdb/commands/ucum/updater.rb'
105
300
 
106
- # Offense count: 6
107
- # This cop supports safe autocorrection (--autocorrect).
108
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
109
- # URISchemes: http, https
110
- Layout/LineLength:
111
- Max: 140
301
+ # Offense count: 1
302
+ # Configuration parameters: Max.
303
+ Style/SafeNavigationChainLength:
304
+ Exclude:
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,8 +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"
10
+ gem "nokogiri"
9
11
  gem "rake"
10
12
  gem "rspec"
11
13
  gem "rubocop"
12
14
  gem "rubocop-performance"
15
+ gem "rubocop-rake"
16
+ gem "rubocop-rspec"