metaschema 0.1.2 → 0.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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +19 -1
  3. data/.rubocop_todo.yml +558 -8
  4. data/CLAUDE.md +78 -0
  5. data/Rakefile +3 -3
  6. data/exe/metaschema +1 -2
  7. data/lib/metaschema/allowed_value_type.rb +18 -25
  8. data/lib/metaschema/allowed_values_type.rb +15 -22
  9. data/lib/metaschema/anchor_type.rb +15 -20
  10. data/lib/metaschema/any_type.rb +2 -4
  11. data/lib/metaschema/assembly.rb +18 -27
  12. data/lib/metaschema/assembly_model_type.rb +10 -19
  13. data/lib/metaschema/assembly_reference_type.rb +16 -24
  14. data/lib/metaschema/augment_type.rb +39 -0
  15. data/lib/metaschema/block_quote_type.rb +17 -25
  16. data/lib/metaschema/choice_type.rb +6 -13
  17. data/lib/metaschema/code_type.rb +17 -23
  18. data/lib/metaschema/constraint_let_type.rb +5 -9
  19. data/lib/metaschema/constraint_validator.rb +483 -0
  20. data/lib/metaschema/define_assembly_constraints_type.rb +17 -26
  21. data/lib/metaschema/define_field_constraints_type.rb +13 -19
  22. data/lib/metaschema/define_flag_constraints_type.rb +9 -17
  23. data/lib/metaschema/example_type.rb +6 -11
  24. data/lib/metaschema/expect_constraint_type.rb +12 -18
  25. data/lib/metaschema/field.rb +13 -20
  26. data/lib/metaschema/field_reference_type.rb +19 -27
  27. data/lib/metaschema/flag.rb +9 -18
  28. data/lib/metaschema/flag_reference_type.rb +14 -21
  29. data/lib/metaschema/formal_name.rb +9 -0
  30. data/lib/metaschema/global_assembly_definition_type.rb +21 -34
  31. data/lib/metaschema/global_field_definition_type.rb +26 -39
  32. data/lib/metaschema/global_flag_definition_type.rb +18 -27
  33. data/lib/metaschema/group_as_type.rb +7 -9
  34. data/lib/metaschema/grouped_assembly_reference_type.rb +11 -18
  35. data/lib/metaschema/grouped_choice_type.rb +16 -24
  36. data/lib/metaschema/grouped_field_reference_type.rb +11 -18
  37. data/lib/metaschema/grouped_inline_assembly_definition_type.rb +17 -29
  38. data/lib/metaschema/grouped_inline_field_definition_type.rb +26 -37
  39. data/lib/metaschema/image_type.rb +5 -7
  40. data/lib/metaschema/import.rb +3 -5
  41. data/lib/metaschema/index_has_key_constraint_type.rb +12 -19
  42. data/lib/metaschema/inline_assembly_definition_type.rb +25 -38
  43. data/lib/metaschema/inline_field_definition_type.rb +31 -43
  44. data/lib/metaschema/inline_flag_definition_type.rb +17 -25
  45. data/lib/metaschema/inline_markup_type.rb +17 -22
  46. data/lib/metaschema/insert_type.rb +4 -6
  47. data/lib/metaschema/json_base_uri.rb +9 -0
  48. data/lib/metaschema/json_key_type.rb +3 -5
  49. data/lib/metaschema/json_schema_generator.rb +456 -0
  50. data/lib/metaschema/json_value_key.rb +9 -0
  51. data/lib/metaschema/json_value_key_flag_type.rb +3 -5
  52. data/lib/metaschema/key_field.rb +5 -9
  53. data/lib/metaschema/list_item_type.rb +29 -39
  54. data/lib/metaschema/list_type.rb +3 -7
  55. data/lib/metaschema/markdown_doc_generator.rb +354 -0
  56. data/lib/metaschema/markup_line_datatype.rb +16 -23
  57. data/lib/metaschema/matches_constraint_type.rb +12 -18
  58. data/lib/metaschema/metapath_evaluator.rb +385 -0
  59. data/lib/metaschema/metaschema_constraints.rb +24 -0
  60. data/lib/metaschema/metaschema_import_type.rb +3 -5
  61. data/lib/metaschema/model_generator.rb +2175 -0
  62. data/lib/metaschema/namespace.rb +8 -0
  63. data/lib/metaschema/namespace_binding_type.rb +4 -6
  64. data/lib/metaschema/namespace_value.rb +9 -0
  65. data/lib/metaschema/ordered_list_type.rb +4 -8
  66. data/lib/metaschema/preformatted_type.rb +16 -23
  67. data/lib/metaschema/property_type.rb +6 -8
  68. data/lib/metaschema/remarks_type.rb +18 -27
  69. data/lib/metaschema/root.rb +23 -31
  70. data/lib/metaschema/root_name.rb +3 -5
  71. data/lib/metaschema/ruby_source_emitter.rb +869 -0
  72. data/lib/metaschema/schema_version.rb +9 -0
  73. data/lib/metaschema/scope.rb +7 -13
  74. data/lib/metaschema/short_name.rb +9 -0
  75. data/lib/metaschema/table_cell_type.rb +18 -25
  76. data/lib/metaschema/table_row_type.rb +4 -8
  77. data/lib/metaschema/table_type.rb +3 -7
  78. data/lib/metaschema/targeted_allowed_values_constraint_type.rb +16 -23
  79. data/lib/metaschema/targeted_expect_constraint_type.rb +13 -19
  80. data/lib/metaschema/targeted_has_cardinality_constraint_type.rb +13 -19
  81. data/lib/metaschema/targeted_index_constraint_type.rb +13 -20
  82. data/lib/metaschema/targeted_index_has_key_constraint_type.rb +13 -20
  83. data/lib/metaschema/targeted_key_constraint_type.rb +12 -19
  84. data/lib/metaschema/targeted_matches_constraint_type.rb +13 -19
  85. data/lib/metaschema/type_mapper.rb +82 -0
  86. data/lib/metaschema/use_name_type.rb +3 -5
  87. data/lib/metaschema/version.rb +1 -1
  88. data/lib/metaschema.rb +97 -9
  89. metadata +28 -95
  90. data/lib/metaschema/metaschemaconstraints.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60b00aaab348d3f988738d342131af2960af449c6476284f372017a884b609ea
4
- data.tar.gz: 3d1105245b18f7db1269698ee5aaf68bc7f0c2cb40dde4efd00a6d7ba068bfc0
3
+ metadata.gz: ab01e7082a78f755a4aab0f12f4e6d0a57fda8c2c61c8820b44d084bd35e700e
4
+ data.tar.gz: dde048935f730d08385f69cf32c3b56fd3e370786a716b3a643dfe68207a5c04
5
5
  SHA512:
6
- metadata.gz: d15f2fb39b07d584bbcbb30ea497281ea9f38068ca978a746ed1afc00889e2823b89101259edb3b3c27a010b671f9c6992daed8c0db081726a1b33219fe09797
7
- data.tar.gz: 0cbe2b526a88045f7ea3cb8d75165bf00fa4c7d52cf64ea830bfd69755cedae2d77d24d7b891c9df981b32e5ce31df49294d9e62bf5c59daeca55d6c1d85dfc0
6
+ metadata.gz: 34ca02dd41aa6febd4d4dd6b167633040477381366fbd2dec9c503adcd83a7588dfcc9bdfc808ac7321940292c0c5cd35dbce22b7765a6999065eb8e2be14c3e
7
+ data.tar.gz: d7c2da1a6bd83bbacc9d301c548a124972c1280dc1f4b3429412368dc4ed0ebfa5b871e7aa18f5abc719440bb5cbcd1282c64fcd26a0e8a924ad2eb783b8fe5b
data/.rubocop.yml CHANGED
@@ -1 +1,19 @@
1
- inherit_from: .rubocop_todo.yml
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
5
+ - .rubocop_todo.yml
6
+
7
+ inherit_mode:
8
+ merge:
9
+ - Exclude
10
+
11
+ # local repo-specific modifications
12
+ # ...
13
+ plugins:
14
+ - rubocop-rspec
15
+ - rubocop-performance
16
+ - rubocop-rake
17
+
18
+ AllCops:
19
+ TargetRubyVersion: 3.0
data/.rubocop_todo.yml CHANGED
@@ -1,18 +1,568 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-01-06 00:55:21 UTC using RuboCop version 1.69.2.
3
+ # on 2026-04-21 23:09:15 UTC using RuboCop version 1.86.1.
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
- # Offense count: 3
10
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
9
+ # Offense count: 1
10
+ Gemspec/RequiredRubyVersion:
11
+ Exclude:
12
+ - 'metaschema.gemspec'
13
+
14
+ # Offense count: 21
15
+ # This cop supports safe autocorrection (--autocorrect).
16
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
17
+ # SupportedStyles: with_first_argument, with_fixed_indentation
18
+ Layout/ArgumentAlignment:
19
+ Exclude:
20
+ - 'lib/metaschema/constraint_validator.rb'
21
+ - 'lib/metaschema/model_generator.rb'
22
+ - 'lib/metaschema/ruby_source_emitter.rb'
23
+ - 'spec/model_generator_spec.rb'
24
+ - 'spec/ruby_source_emitter_spec.rb'
25
+
26
+ # Offense count: 10
27
+ # This cop supports safe autocorrection (--autocorrect).
28
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
29
+ # SupportedStyles: with_first_element, with_fixed_indentation
30
+ Layout/ArrayAlignment:
31
+ Exclude:
32
+ - 'lib/metaschema/markdown_doc_generator.rb'
33
+ - 'lib/metaschema/model_generator.rb'
34
+ - 'lib/metaschema/ruby_source_emitter.rb'
35
+
36
+ # Offense count: 6
37
+ # This cop supports safe autocorrection (--autocorrect).
38
+ # Configuration parameters: IndentationWidth.
39
+ Layout/AssignmentIndentation:
40
+ Exclude:
41
+ - 'lib/metaschema/json_schema_generator.rb'
42
+ - 'lib/metaschema/model_generator.rb'
43
+
44
+ # Offense count: 74
45
+ # This cop supports safe autocorrection (--autocorrect).
46
+ # Configuration parameters: EnforcedStyleAlignWith.
47
+ # SupportedStylesAlignWith: either, start_of_block, start_of_line
48
+ Layout/BlockAlignment:
49
+ Exclude:
50
+ - 'lib/metaschema/constraint_validator.rb'
51
+ - 'lib/metaschema/json_schema_generator.rb'
52
+ - 'lib/metaschema/markdown_doc_generator.rb'
53
+ - 'lib/metaschema/metapath_evaluator.rb'
54
+ - 'lib/metaschema/model_generator.rb'
55
+
56
+ # Offense count: 71
57
+ # This cop supports safe autocorrection (--autocorrect).
58
+ Layout/BlockEndNewline:
59
+ Exclude:
60
+ - 'lib/metaschema/constraint_validator.rb'
61
+ - 'lib/metaschema/json_schema_generator.rb'
62
+ - 'lib/metaschema/markdown_doc_generator.rb'
63
+ - 'lib/metaschema/metapath_evaluator.rb'
64
+ - 'lib/metaschema/model_generator.rb'
65
+
66
+ # Offense count: 7
67
+ # This cop supports safe autocorrection (--autocorrect).
68
+ # Configuration parameters: AllowForAlignment.
69
+ Layout/CommentIndentation:
70
+ Exclude:
71
+ - 'lib/metaschema/model_generator.rb'
72
+
73
+ # Offense count: 10
74
+ # This cop supports safe autocorrection (--autocorrect).
75
+ Layout/ElseAlignment:
76
+ Exclude:
77
+ - 'lib/metaschema/constraint_validator.rb'
78
+ - 'lib/metaschema/json_schema_generator.rb'
79
+ - 'lib/metaschema/model_generator.rb'
80
+ - 'lib/metaschema/ruby_source_emitter.rb'
81
+
82
+ # Offense count: 40
83
+ # This cop supports safe autocorrection (--autocorrect).
84
+ Layout/EmptyLineAfterGuardClause:
85
+ Exclude:
86
+ - 'lib/metaschema/constraint_validator.rb'
87
+ - 'lib/metaschema/json_schema_generator.rb'
88
+ - 'lib/metaschema/markdown_doc_generator.rb'
89
+ - 'lib/metaschema/metapath_evaluator.rb'
90
+ - 'lib/metaschema/model_generator.rb'
91
+ - 'lib/metaschema/ruby_source_emitter.rb'
92
+
93
+ # Offense count: 1
94
+ # This cop supports safe autocorrection (--autocorrect).
95
+ # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
96
+ Layout/EmptyLineBetweenDefs:
97
+ Exclude:
98
+ - 'lib/metaschema/constraint_validator.rb'
99
+
100
+ # Offense count: 1
101
+ # This cop supports safe autocorrection (--autocorrect).
102
+ Layout/EmptyLines:
103
+ Exclude:
104
+ - 'lib/metaschema/constraint_validator.rb'
105
+
106
+ # Offense count: 1
107
+ # This cop supports safe autocorrection (--autocorrect).
108
+ Layout/EmptyLinesAroundMethodBody:
109
+ Exclude:
110
+ - 'lib/metaschema/metapath_evaluator.rb'
111
+
112
+ # Offense count: 11
113
+ # This cop supports safe autocorrection (--autocorrect).
114
+ # Configuration parameters: EnforcedStyleAlignWith.
115
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
116
+ Layout/EndAlignment:
117
+ Exclude:
118
+ - 'lib/metaschema/constraint_validator.rb'
119
+ - 'lib/metaschema/model_generator.rb'
120
+ - 'lib/metaschema/ruby_source_emitter.rb'
121
+
122
+ # Offense count: 1
123
+ # This cop supports safe autocorrection (--autocorrect).
124
+ # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
125
+ Layout/ExtraSpacing:
126
+ Exclude:
127
+ - 'lib/metaschema/constraint_validator.rb'
128
+
129
+ # Offense count: 33
130
+ # This cop supports safe autocorrection (--autocorrect).
131
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
132
+ # SupportedHashRocketStyles: key, separator, table
133
+ # SupportedColonStyles: key, separator, table
134
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
135
+ Layout/HashAlignment:
136
+ Exclude:
137
+ - 'lib/metaschema/json_schema_generator.rb'
138
+ - 'lib/metaschema/model_generator.rb'
139
+ - 'spec/model_generator_spec.rb'
140
+
141
+ # Offense count: 33
142
+ # This cop supports safe autocorrection (--autocorrect).
143
+ # Configuration parameters: EnforcedStyle.
144
+ # SupportedStyles: normal, indented_internal_methods
145
+ Layout/IndentationConsistency:
146
+ Exclude:
147
+ - 'lib/metaschema/model_generator.rb'
148
+ - 'lib/metaschema/ruby_source_emitter.rb'
149
+
150
+ # Offense count: 174
151
+ # This cop supports safe autocorrection (--autocorrect).
152
+ # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
153
+ # SupportedStylesAlignWith: start_of_line, relative_to_receiver
154
+ Layout/IndentationWidth:
155
+ Exclude:
156
+ - 'lib/metaschema/constraint_validator.rb'
157
+ - 'lib/metaschema/json_schema_generator.rb'
158
+ - 'lib/metaschema/markdown_doc_generator.rb'
159
+ - 'lib/metaschema/metapath_evaluator.rb'
160
+ - 'lib/metaschema/model_generator.rb'
161
+ - 'lib/metaschema/ruby_source_emitter.rb'
162
+
163
+ # Offense count: 208
164
+ # This cop supports safe autocorrection (--autocorrect).
165
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
166
+ # URISchemes: http, https
167
+ Layout/LineLength:
168
+ Exclude:
169
+ - 'lib/metaschema/constraint_validator.rb'
170
+ - 'lib/metaschema/json_schema_generator.rb'
171
+ - 'lib/metaschema/markdown_doc_generator.rb'
172
+ - 'lib/metaschema/metapath_evaluator.rb'
173
+ - 'lib/metaschema/model_generator.rb'
174
+ - 'lib/metaschema/ruby_source_emitter.rb'
175
+ - 'spec/metaschema_spec.rb'
176
+ - 'spec/model_generator_spec.rb'
177
+ - 'spec/ruby_source_emitter_spec.rb'
178
+
179
+ # Offense count: 2
180
+ # This cop supports safe autocorrection (--autocorrect).
181
+ Layout/MultilineBlockLayout:
182
+ Exclude:
183
+ - 'lib/metaschema/model_generator.rb'
184
+
185
+ # Offense count: 5
186
+ # This cop supports safe autocorrection (--autocorrect).
187
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
188
+ # SupportedStyles: aligned, indented, indented_relative_to_receiver
189
+ Layout/MultilineMethodCallIndentation:
190
+ Exclude:
191
+ - 'lib/metaschema/model_generator.rb'
192
+ - 'lib/metaschema/ruby_source_emitter.rb'
193
+
194
+ # Offense count: 7
195
+ # This cop supports safe autocorrection (--autocorrect).
196
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
197
+ # SupportedStyles: aligned, indented
198
+ Layout/MultilineOperationIndentation:
199
+ Exclude:
200
+ - 'lib/metaschema/model_generator.rb'
201
+
202
+ # Offense count: 57
203
+ # This cop supports safe autocorrection (--autocorrect).
204
+ # Configuration parameters: AllowInHeredoc.
205
+ Layout/TrailingWhitespace:
206
+ Exclude:
207
+ - 'lib/metaschema/constraint_validator.rb'
208
+ - 'lib/metaschema/json_schema_generator.rb'
209
+ - 'lib/metaschema/markdown_doc_generator.rb'
210
+ - 'lib/metaschema/metapath_evaluator.rb'
211
+ - 'lib/metaschema/model_generator.rb'
212
+ - 'lib/metaschema/ruby_source_emitter.rb'
213
+ - 'spec/ruby_source_emitter_spec.rb'
214
+
215
+ # Offense count: 4
216
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
217
+ Lint/DuplicateBranch:
218
+ Exclude:
219
+ - 'lib/metaschema/constraint_validator.rb'
220
+ - 'lib/metaschema/model_generator.rb'
221
+
222
+ # Offense count: 1
223
+ Lint/IneffectiveAccessModifier:
224
+ Exclude:
225
+ - 'lib/metaschema/constraint_validator.rb'
226
+
227
+ # Offense count: 6
228
+ # This cop supports unsafe autocorrection (--autocorrect-all).
229
+ # Configuration parameters: AllowedMethods, InferNonNilReceiver, AdditionalNilMethods.
230
+ # AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
231
+ # AdditionalNilMethods: present?, blank?, try, try!
232
+ Lint/RedundantSafeNavigation:
233
+ Exclude:
234
+ - 'lib/metaschema/json_schema_generator.rb'
235
+ - 'lib/metaschema/markdown_doc_generator.rb'
236
+ - 'lib/metaschema/model_generator.rb'
237
+ - 'lib/metaschema/ruby_source_emitter.rb'
238
+
239
+ # Offense count: 2
240
+ # This cop supports safe autocorrection (--autocorrect).
241
+ # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
242
+ Lint/UnusedBlockArgument:
243
+ Exclude:
244
+ - 'lib/metaschema/model_generator.rb'
245
+ - 'lib/metaschema/ruby_source_emitter.rb'
246
+
247
+ # Offense count: 10
248
+ # This cop supports safe autocorrection (--autocorrect).
249
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
250
+ # NotImplementedExceptions: NotImplementedError
251
+ Lint/UnusedMethodArgument:
252
+ Exclude:
253
+ - 'lib/metaschema/constraint_validator.rb'
254
+ - 'lib/metaschema/json_schema_generator.rb'
255
+ - 'lib/metaschema/markdown_doc_generator.rb'
256
+ - 'lib/metaschema/model_generator.rb'
257
+ - 'lib/metaschema/ruby_source_emitter.rb'
258
+
259
+ # Offense count: 1
260
+ # This cop supports safe autocorrection (--autocorrect).
261
+ # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
262
+ Lint/UselessAccessModifier:
263
+ Exclude:
264
+ - 'lib/metaschema/constraint_validator.rb'
265
+
266
+ # Offense count: 4
267
+ # This cop supports safe autocorrection (--autocorrect).
268
+ Lint/UselessAssignment:
269
+ Exclude:
270
+ - 'lib/metaschema/constraint_validator.rb'
271
+ - 'lib/metaschema/json_schema_generator.rb'
272
+ - 'lib/metaschema/model_generator.rb'
273
+ - 'lib/metaschema/ruby_source_emitter.rb'
274
+
275
+ # Offense count: 82
276
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
277
+ Metrics/AbcSize:
278
+ Exclude:
279
+ - 'lib/metaschema/constraint_validator.rb'
280
+ - 'lib/metaschema/json_schema_generator.rb'
281
+ - 'lib/metaschema/markdown_doc_generator.rb'
282
+ - 'lib/metaschema/metapath_evaluator.rb'
283
+ - 'lib/metaschema/model_generator.rb'
284
+ - 'lib/metaschema/ruby_source_emitter.rb'
285
+ - 'lib/metaschema/type_mapper.rb'
286
+
287
+ # Offense count: 15
288
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
11
289
  # AllowedMethods: refine
12
290
  Metrics/BlockLength:
13
- Max: 44
291
+ Max: 52
292
+
293
+ # Offense count: 86
294
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
295
+ Metrics/CyclomaticComplexity:
296
+ Exclude:
297
+ - 'lib/metaschema/constraint_validator.rb'
298
+ - 'lib/metaschema/json_schema_generator.rb'
299
+ - 'lib/metaschema/markdown_doc_generator.rb'
300
+ - 'lib/metaschema/metapath_evaluator.rb'
301
+ - 'lib/metaschema/model_generator.rb'
302
+ - 'lib/metaschema/ruby_source_emitter.rb'
303
+
304
+ # Offense count: 106
305
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
306
+ Metrics/MethodLength:
307
+ Max: 283
308
+
309
+ # Offense count: 2
310
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
311
+ Metrics/ParameterLists:
312
+ Max: 7
313
+
314
+ # Offense count: 72
315
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
316
+ Metrics/PerceivedComplexity:
317
+ Exclude:
318
+ - 'lib/metaschema/constraint_validator.rb'
319
+ - 'lib/metaschema/json_schema_generator.rb'
320
+ - 'lib/metaschema/markdown_doc_generator.rb'
321
+ - 'lib/metaschema/metapath_evaluator.rb'
322
+ - 'lib/metaschema/model_generator.rb'
323
+ - 'lib/metaschema/ruby_source_emitter.rb'
324
+
325
+ # Offense count: 20
326
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
327
+ # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
328
+ Naming/MethodParameterName:
329
+ Exclude:
330
+ - 'lib/metaschema/json_schema_generator.rb'
331
+ - 'lib/metaschema/markdown_doc_generator.rb'
332
+ - 'lib/metaschema/metapath_evaluator.rb'
333
+
334
+ # Offense count: 23
335
+ # This cop supports unsafe autocorrection (--autocorrect-all).
336
+ Performance/MapCompact:
337
+ Exclude:
338
+ - 'lib/metaschema/constraint_validator.rb'
339
+ - 'lib/metaschema/json_schema_generator.rb'
340
+ - 'lib/metaschema/markdown_doc_generator.rb'
341
+ - 'lib/metaschema/model_generator.rb'
342
+
343
+ # Offense count: 8
344
+ # This cop supports safe autocorrection (--autocorrect).
345
+ Performance/StringIdentifierArgument:
346
+ Exclude:
347
+ - 'lib/metaschema/model_generator.rb'
348
+
349
+ # Offense count: 1
350
+ # This cop supports unsafe autocorrection (--autocorrect-all).
351
+ Performance/StringInclude:
352
+ Exclude:
353
+ - 'lib/metaschema/constraint_validator.rb'
354
+
355
+ # Offense count: 1
356
+ RSpec/DescribeMethod:
357
+ Exclude:
358
+ - 'spec/model_generator_spec.rb'
359
+
360
+ # Offense count: 8
361
+ # Configuration parameters: CountAsOne.
362
+ RSpec/ExampleLength:
363
+ Max: 10
364
+
365
+ # Offense count: 9
366
+ RSpec/MultipleExpectations:
367
+ Max: 2
368
+
369
+ # Offense count: 4
370
+ # Configuration parameters: AllowSubject.
371
+ RSpec/MultipleMemoizedHelpers:
372
+ Max: 7
373
+
374
+ # Offense count: 1
375
+ # Configuration parameters: AllowedPatterns.
376
+ # AllowedPatterns: ^expect_, ^assert_
377
+ RSpec/NoExpectationExample:
378
+ Exclude:
379
+ - 'spec/metaschema_spec.rb'
380
+
381
+ # Offense count: 2
382
+ # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
383
+ # SupportedInflectors: default, active_support
384
+ RSpec/SpecFilePathFormat:
385
+ Exclude:
386
+ - 'spec/model_generator_spec.rb'
387
+ - 'spec/ruby_source_emitter_spec.rb'
388
+
389
+ # Offense count: 137
390
+ # This cop supports safe autocorrection (--autocorrect).
391
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
392
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
393
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
394
+ # FunctionalMethods: let, let!, subject, watch
395
+ # AllowedMethods: lambda, proc, it
396
+ Style/BlockDelimiters:
397
+ Exclude:
398
+ - 'lib/metaschema/constraint_validator.rb'
399
+ - 'lib/metaschema/json_schema_generator.rb'
400
+ - 'lib/metaschema/markdown_doc_generator.rb'
401
+ - 'lib/metaschema/metapath_evaluator.rb'
402
+ - 'lib/metaschema/model_generator.rb'
403
+
404
+ # Offense count: 3
405
+ # This cop supports unsafe autocorrection (--autocorrect-all).
406
+ Style/CombinableLoops:
407
+ Exclude:
408
+ - 'lib/metaschema/model_generator.rb'
409
+
410
+ # Offense count: 4
411
+ # This cop supports safe autocorrection (--autocorrect).
412
+ # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
413
+ # SupportedStyles: assign_to_condition, assign_inside_condition
414
+ Style/ConditionalAssignment:
415
+ Exclude:
416
+ - 'lib/metaschema/json_schema_generator.rb'
417
+ - 'lib/metaschema/model_generator.rb'
418
+ - 'lib/metaschema/ruby_source_emitter.rb'
419
+
420
+ # Offense count: 1
421
+ # This cop supports safe autocorrection (--autocorrect).
422
+ # Configuration parameters: EnforcedStyle, AllowComments.
423
+ # SupportedStyles: empty, nil, both
424
+ Style/EmptyElse:
425
+ Exclude:
426
+ - 'lib/metaschema/ruby_source_emitter.rb'
427
+
428
+ # Offense count: 3
429
+ # This cop supports unsafe autocorrection (--autocorrect-all).
430
+ # Configuration parameters: AllowedReceivers.
431
+ # AllowedReceivers: Thread.current
432
+ Style/HashEachMethods:
433
+ Exclude:
434
+ - 'lib/metaschema/constraint_validator.rb'
435
+ - 'lib/metaschema/metapath_evaluator.rb'
436
+ - 'lib/metaschema/ruby_source_emitter.rb'
437
+
438
+ # Offense count: 1
439
+ # This cop supports unsafe autocorrection (--autocorrect-all).
440
+ Style/HashExcept:
441
+ Exclude:
442
+ - 'lib/metaschema/ruby_source_emitter.rb'
443
+
444
+ # Offense count: 16
445
+ # This cop supports unsafe autocorrection (--autocorrect-all).
446
+ Style/IdenticalConditionalBranches:
447
+ Exclude:
448
+ - 'lib/metaschema/model_generator.rb'
449
+ - 'lib/metaschema/ruby_source_emitter.rb'
450
+
451
+ # Offense count: 3
452
+ # This cop supports unsafe autocorrection (--autocorrect-all).
453
+ Style/MapIntoArray:
454
+ Exclude:
455
+ - 'lib/metaschema/markdown_doc_generator.rb'
456
+
457
+ # Offense count: 1
458
+ # This cop supports safe autocorrection (--autocorrect).
459
+ Style/ModuleMemberExistenceCheck:
460
+ Exclude:
461
+ - 'lib/metaschema/model_generator.rb'
462
+
463
+ # Offense count: 18
464
+ # This cop supports safe autocorrection (--autocorrect).
465
+ Style/MultilineIfModifier:
466
+ Exclude:
467
+ - 'lib/metaschema/constraint_validator.rb'
468
+ - 'lib/metaschema/model_generator.rb'
469
+
470
+ # Offense count: 4
471
+ # This cop supports safe autocorrection (--autocorrect).
472
+ Style/MultilineTernaryOperator:
473
+ Exclude:
474
+ - 'lib/metaschema/constraint_validator.rb'
475
+ - 'lib/metaschema/model_generator.rb'
476
+
477
+ # Offense count: 1
478
+ # This cop supports safe autocorrection (--autocorrect).
479
+ # Configuration parameters: AllowMethodComparison, ComparisonsThreshold.
480
+ Style/MultipleComparison:
481
+ Exclude:
482
+ - 'lib/metaschema/model_generator.rb'
483
+
484
+ # Offense count: 6
485
+ # This cop supports unsafe autocorrection (--autocorrect-all).
486
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
487
+ # SupportedStyles: predicate, comparison
488
+ Style/NumericPredicate:
489
+ Exclude:
490
+ - 'lib/metaschema/constraint_validator.rb'
491
+ - 'lib/metaschema/markdown_doc_generator.rb'
492
+ - 'lib/metaschema/metapath_evaluator.rb'
493
+ - 'lib/metaschema/model_generator.rb'
494
+
495
+ # Offense count: 1
496
+ # Configuration parameters: AllowedMethods.
497
+ # AllowedMethods: respond_to_missing?
498
+ Style/OptionalBooleanParameter:
499
+ Exclude:
500
+ - 'lib/metaschema/model_generator.rb'
501
+
502
+ # Offense count: 1
503
+ # This cop supports safe autocorrection (--autocorrect).
504
+ Style/RedundantAssignment:
505
+ Exclude:
506
+ - 'lib/metaschema/metapath_evaluator.rb'
507
+
508
+ # Offense count: 1
509
+ # This cop supports safe autocorrection (--autocorrect).
510
+ # Configuration parameters: AllowedMethods.
511
+ # AllowedMethods: infinite?, nonzero?
512
+ Style/RedundantCondition:
513
+ Exclude:
514
+ - 'lib/metaschema/model_generator.rb'
515
+
516
+ # Offense count: 3
517
+ # This cop supports safe autocorrection (--autocorrect).
518
+ Style/RedundantParentheses:
519
+ Exclude:
520
+ - 'lib/metaschema/json_schema_generator.rb'
521
+ - 'lib/metaschema/model_generator.rb'
522
+
523
+ # Offense count: 1
524
+ # This cop supports safe autocorrection (--autocorrect).
525
+ # Configuration parameters: EnforcedStyle.
526
+ # SupportedStyles: implicit, explicit
527
+ Style/RescueStandardError:
528
+ Exclude:
529
+ - 'lib/metaschema/model_generator.rb'
530
+
531
+ # Offense count: 2
532
+ # This cop supports unsafe autocorrection (--autocorrect-all).
533
+ # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
534
+ # AllowedMethods: present?, blank?, presence, try, try!
535
+ Style/SafeNavigation:
536
+ Exclude:
537
+ - 'lib/metaschema/constraint_validator.rb'
538
+ - 'lib/metaschema/ruby_source_emitter.rb'
539
+
540
+ # Offense count: 1
541
+ # This cop supports unsafe autocorrection (--autocorrect-all).
542
+ Style/SlicingWithRange:
543
+ Exclude:
544
+ - 'lib/metaschema/constraint_validator.rb'
545
+
546
+ # Offense count: 1
547
+ # This cop supports safe autocorrection (--autocorrect).
548
+ # Configuration parameters: AllowModifier.
549
+ Style/SoleNestedConditional:
550
+ Exclude:
551
+ - 'lib/metaschema/model_generator.rb'
552
+
553
+ # Offense count: 12
554
+ # This cop supports unsafe autocorrection (--autocorrect-all).
555
+ # Configuration parameters: Mode.
556
+ Style/StringConcatenation:
557
+ Exclude:
558
+ - 'lib/metaschema/ruby_source_emitter.rb'
14
559
 
15
- # Offense count: 66
16
- # Configuration parameters: AllowedConstants.
17
- Style/Documentation:
18
- Enabled: false
560
+ # Offense count: 4
561
+ # This cop supports safe autocorrection (--autocorrect).
562
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
563
+ # SupportedStyles: single_quotes, double_quotes
564
+ Style/StringLiterals:
565
+ Exclude:
566
+ - 'lib/metaschema/constraint_validator.rb'
567
+ - 'lib/metaschema/model_generator.rb'
568
+ - 'spec/ruby_source_emitter_spec.rb'
data/CLAUDE.md ADDED
@@ -0,0 +1,78 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Overview
6
+
7
+ This is a Ruby gem implementing a parser and generator for the [NIST Metaschema Information Modeling Framework](https://pages.nist.gov/metaschema). It parses Metaschema XML files and can round-trip them (parse to Ruby objects and back to XML).
8
+
9
+ ## Common Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ bundle install
14
+
15
+ # Run tests
16
+ bundle exec rake spec
17
+
18
+ # Run a single test file
19
+ bundle exec rspec spec/metaschema_spec.rb
20
+
21
+ # Run tests with specific format
22
+ bundle exec rspec spec/metaschema_spec.rb --format documentation
23
+
24
+ # Run linting
25
+ bundle exec rake rubocop
26
+
27
+ # Auto-correct linting issues
28
+ bundle exec rake rubocop:autocorrect_all
29
+
30
+ # Build the gem
31
+ bundle exec rake build
32
+ ```
33
+
34
+ ## Architecture
35
+
36
+ The gem uses **lutaml-model** with **Nokogiri** for XML serialization/deserialization. All model classes inherit from `Lutaml::Model::Serializable`.
37
+
38
+ ### Entry Point
39
+
40
+ `lib/metaschema/root.rb` - The `Metaschema::Root` class is the top-level model representing a complete Metaschema XML document. It contains:
41
+ - `schema_name`, `schema_version`, `short_name`, `namespace`, `json_base_uri`
42
+ - Top-level definitions: `define_assembly`, `define_field`, `define_flag`
43
+ - Imports and namespace bindings
44
+
45
+ ### Type System
46
+
47
+ The `lib/metaschema/` directory contains ~74 type classes. Key patterns:
48
+
49
+ - **Definition types** (e.g., `GlobalAssemblyDefinitionType`, `GlobalFieldDefinitionType`) - Define schema structures with `name`, `formal_name`, `description`, `model`, `constraint`
50
+ - **Reference types** (e.g., `AssemblyReferenceType`, `FieldReferenceType`) - Reference definitions by name
51
+ - **Inline definition types** (e.g., `InlineAssemblyDefinitionType`) - Definitions nested within other definitions
52
+ - **Constraint types** (e.g., `DefineAssemblyConstraintsType`, `AllowedValuesType`) - Validation constraints
53
+ - **Value types** (e.g., `MarkupLineDatatype`, `FormalName`) - Simple value wrappers
54
+
55
+ Each type class uses the lutaml-model XML DSL:
56
+ ```ruby
57
+ xml do
58
+ element "ElementName"
59
+ ordered # children must appear in defined order
60
+ namespace ::Metaschema::Namespace
61
+ map_attribute "attr", to: :attr_name
62
+ map_element "child-element", to: :child_attr
63
+ end
64
+ ```
65
+
66
+ ### Test Fixtures
67
+
68
+ - `spec/fixtures/metaschema/` - Submoduled NIST Metaschema project containing test schemas
69
+ - `spec/fixtures/metaschema/examples/` - Example Metaschema XML files (e.g., `computer-example.xml`)
70
+ - `spec/fixtures/metaschema/test-suite/schema-generation/` - Feature-specific test cases
71
+
72
+ ### Loading a Metaschema File
73
+
74
+ ```ruby
75
+ require 'metaschema'
76
+ ms = Metaschema::Root.from_file("path/to/metaschema.xml")
77
+ ms.to_xml # Returns XML string
78
+ ```