RBS, Color, Tag, DSL, Text Schema and Literals - #50
Open
rickmark wants to merge 17 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR substantially expands RASN1’s authoring and introspection capabilities by adding a block-based model DSL, schema/value-notation parsing/emission, dynamic tagging (including 4CC-style tag IDs), and optional colorized tracing, alongside introducing Steep/RBS typing infrastructure.
Changes:
- Add block-based DSL support for defining constructed model content (including nested blocks and wrapper-in-block forms).
- Introduce ASN.1 text schema parsing (
SchemaParser) and ASN.1 value notation parsing/emission (ValueNotation), plusModel#to_asn1. - Add dynamic tagging support (
Types::Tag) and support string/symbol tag IDs (4CC-style), plus optional Pastel-colored trace output.
Reviewed changes
Copilot reviewed 59 out of 64 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Steepfile | Adds Steep configuration to typecheck lib against sig. |
| spec/wrapper_spec.rb | Adds tests for 4CC-style string/symbol tag IDs in wrappers. |
| spec/value_notation_spec.rb | Adds tests for parsing/emitting ASN.1 value notation and round-tripping. |
| spec/types/generic_spec.rb | Adds tests for new Types::Tag behavior (single/multi-tag/any-private). |
| spec/types/base_spec.rb | Adds tests for 4CC-style string/symbol tag IDs at the Types::Base level. |
| spec/tracer_spec.rb | Adds tests for colorized tracing and RASN1.trace(color: true). |
| spec/schema_parser_spec.rb | Adds tests for parsing ASN.1 schemas into generated Model classes. |
| spec/model_block_dsl_spec.rb | Adds tests for the new block-based model definition DSL. |
| spec/fixtures/personal_module.asn | Adds schema fixture used by SchemaParser/ValueNotation tests. |
| spec/fixtures/personal_instance.asn | Adds value-notation fixture used by ValueNotation tests. |
| sig/rasn1/wrapper.rbs | Introduces/updates wrapper signatures for Steep. |
| sig/rasn1/version.rbs | Adds RBS version constant declaration. |
| sig/rasn1/types/visible_string.rbs | Adds/updates VisibleString RBS signature. |
| sig/rasn1/types/utf8_string.rbs | Adds/updates Utf8String RBS signature. |
| sig/rasn1/types/utc_time.rbs | Adds/updates UtcTime RBS signature. |
| sig/rasn1/types/universal_string.rbs | Adds/updates UniversalString RBS signature. |
| sig/rasn1/types/set.rbs | Adds/updates Set RBS signature. |
| sig/rasn1/types/set_of.rbs | Adds/updates SetOf RBS signature. |
| sig/rasn1/types/sequence.rbs | Adds/updates Sequence RBS signature. |
| sig/rasn1/types/sequence_of.rbs | Adds/updates SequenceOf RBS signature. |
| sig/rasn1/types/printable_string.rbs | Adds/updates PrintableString RBS signature. |
| sig/rasn1/types/primitive.rbs | Adds/updates Primitive base RBS signature. |
| sig/rasn1/types/octet_string.rbs | Adds/updates OctetString RBS signature. |
| sig/rasn1/types/object_id.rbs | Adds/updates ObjectId RBS signature. |
| sig/rasn1/types/numeric_string.rbs | Adds/updates NumericString RBS signature. |
| sig/rasn1/types/null.rbs | Adds/updates Null RBS signature. |
| sig/rasn1/types/integer.rbs | Adds/updates Integer RBS signature. |
| sig/rasn1/types/ia5string.rbs | Adds/updates IA5String RBS signature. |
| sig/rasn1/types/generalized_time.rbs | Adds/updates GeneralizedTime RBS signature. |
| sig/rasn1/types/enumerated.rbs | Adds/updates Enumerated RBS signature. |
| sig/rasn1/types/constructed.rbs | Adds/updates Constructed base RBS signature. |
| sig/rasn1/types/constrained.rbs | Adds/updates Constrained mixin RBS signature. |
| sig/rasn1/types/choice.rbs | Adds/updates Choice RBS signature. |
| sig/rasn1/types/boolean.rbs | Adds/updates Boolean RBS signature. |
| sig/rasn1/types/bmp_string.rbs | Adds/updates BmpString RBS signature. |
| sig/rasn1/types/bit_string.rbs | Adds/updates BitString RBS signature. |
| sig/rasn1/types/base.rbs | Adds/updates Types::Base RBS signature. |
| sig/rasn1/types/any.rbs | Adds/updates Any RBS signature. |
| sig/rasn1/types.rbs | Adds/updates Types module RBS signature. |
| sig/rasn1/tracer.rbs | Adds/updates tracer RBS signature. |
| sig/rasn1/model.rbs | Adds/updates model RBS signature (including new DSL behavior). |
| sig/rasn1/errors.rbs | Adds/updates error classes RBS signature. |
| sig/rasn1.rbs | Adds/updates top-level RASN1 RBS signature. |
| rbs_collection.yaml | Adds RBS collection configuration. |
| rbs_collection.lock.yaml | Adds RBS collection lockfile for reproducible installs. |
| rasn1.gemspec | Adds pastel runtime dependency. |
| Rakefile | Updates Rake tasks (yard/rubocop/steep) setup. |
| lib/rasn1/wrapper.rb | Adds 4CC-style tag ID conversion for wrapper explicit/implicit tags. |
| lib/rasn1/value_notation.rb | Adds ValueNotation parser/emitter implementation. |
| lib/rasn1/types/tag.rb | Adds new dynamic tag-accepting constructed type Types::Tag. |
| lib/rasn1/types/base.rb | Adds 4CC-style tag ID conversion for explicit/implicit/tag_value. |
| lib/rasn1/types.rb | Requires the new types/tag implementation. |
| lib/rasn1/tracer.rb | Adds optional Pastel colorized output and color: plumbing. |
| lib/rasn1/schema_parser.rb | Adds ASN.1 schema-to-model parser implementation. |
| lib/rasn1/model.rb | Adds block-based DSL for content, wrapper blocks, and Model#to_asn1. |
| lib/rasn1.rb | Requires new schema/value-notation components. |
| Gemfile | Updates development/test dependencies (adds steep/rbs; loosens version pins). |
| Changelog.md | Documents new DSL/wrapper-block additions in Unreleased section. |
| .rubocop.yml | Adds rubocop-rspec plugin and adjusts RuboCop settings. |
| .idea/vcs.xml | Adds IDE configuration (VCS mappings). |
| .idea/rasn1.iml | Adds IDE module file. |
| .idea/modules.xml | Adds IDE module list. |
| .idea/.gitignore | Adds IDE-local ignore rules. |
| .gitignore | Ignores .gem_rbs_collection/ and normalizes workspace ignore entry. |
Files not reviewed (4)
- .idea/.gitignore: Generated file
- .idea/modules.xml: Generated file
- .idea/rasn1.iml: Generated file
- .idea/vcs.xml: Generated file
Suppressed comments (1)
sig/rasn1/tracer.rbs:44
RASN1.tracenow accepts acolor:keyword argument in the Ruby implementation, but the RBS signature doesn't include it. Update the signature to match to avoid Steep errors when callingRASN1.trace(..., color: true)from typed code.
def self.trace: (?untyped io) { (untyped) -> untyped } -> untyped
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
1
to
+4
| plugins: | ||
| - rubocop-performance | ||
| - rubocop-rspec | ||
| - rubocop-rspec |
Comment on lines
+79
to
+83
| def der_to_value(der, ber: false) # rubocop:disable Lint/UnusedMethodArgument | ||
| if @value.is_a?(Array) && !@value.empty? | ||
| nb_bytes = 0 | ||
| @value.each do |element| | ||
| nb_bytes += element.parse!(der[nb_bytes..]) |
Comment on lines
+488
to
+490
| else | ||
| value | ||
| end |
Comment on lines
+232
to
+234
| else | ||
| value | ||
| end |
Comment on lines
+18
to
+20
| # @param [IO] io | ||
| def initialize: (untyped io) -> void | ||
|
|
Comment on lines
+3
to
+5
| # @abstract This class SHOULD be used as base class for all ASN.1 primitive | ||
| # types. | ||
| # Base class for all ASN.1 constructed types |
Comment on lines
+6
to
+8
| # SetOf id value | ||
| ID: untyped | ||
|
|
Comment on lines
+5
to
+8
| target :lib do | ||
| signature 'sig' | ||
|
|
||
| check 'lib' |
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.
I know this is a large update, and yes, I did use some (highly verified) agentic AI since the ASN1 problem space is fairly well understood and the test suite was substantial...
tagbased API to permit the definition of constructed with any private ID (common in Apple land)