feat: code generation pipeline with doubled method name fix#20
Open
feat: code generation pipeline with doubled method name fix#20
Conversation
059ee61 to
6a9dc42
Compare
4 tasks
Add full code generation pipeline: ModelGenerator creates in-memory Ruby
classes from NIST Metaschema definitions, RubySourceEmitter serializes
them to .rb source files.
Key components:
- ModelGenerator: import resolution, class generation with XML/JSON/YAML
mappings, constraint validation
- RubySourceEmitter: introspects generated classes, emits Ruby source
- TypeMapper: maps metaschema types to lutaml-model types
- ConstraintValidator, JsonSchemaGenerator, MarkdownDocGenerator,
MetapathEvaluator: supporting tooling
Fixes:
- Doubled method name bug in emit_scalar_from_method (rest.split('_').first
now uses find_attr_for_method for correct multi-word attribute resolution)
- Mixed content collection enforcement (collection: true on markup fields)
- Singleton object handling in assembly SOA JSON/YAML callbacks
- Reserve 'hash' attribute name to avoid overriding Object#hash
- Add 'augment' support to Root model, DateTime to YAML safe_load
Tests (97, 0 failures):
- 62 metaschema XML round-trip tests
- 12 source code generation tests
- 23 dynamic model creation tests with OSCAL metaschemas
(class generation, import resolution, XML/JSON/YAML round-trips,
6 real OSCAL test catalogs)
Adds usnistgov/OSCAL submodule for OSCAL metaschema definitions and
profile-resolution test fixtures.
20da7e5 to
426f156
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
emit_scalar_from_methodwhererest.split("_").firstincorrectly parsed multi-word attribute names (e.g.last_modified→last). Now usesfind_attr_for_methodto resolve from key-value mappings.to_ruby_sourceclass method on ModelGenerator for generating Ruby source from metaschema filesaugmentattribute to Root model, all autoload entriesTest plan
bundle exec rake spec)all_models.rbwith fixed emitter — 61 tests pass in oscal repo