Expose selected paths and format escaped selectors - #3
Merged
Merged
Conversation
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.
Shortcut Link
Summary of Changes
Applications inspecting field selectors currently have to traverse the selection tree and implement escaping themselves. Add
CompiledMask#each_pathto yield decoded path segments andJsonMask.format_pathto turn a path or prefix back into an escaped selector.JsonMask.compile("id,assets(url,width)").each_path.to_areturns[["id"], ["assets", "url"], ["assets", "width"]].JsonMask::WILDCARDdistinguishes wildcard segments from a literal"*"field. Enumeration preserves the compiled selector's whole-field and terminal-wildcard behavior; formatting preserves literal names, including whitespace and NUL.The APIs support consumers such as schema validators while keeping schema policy in the application. README examples and the changelog document the new contract. The version is prepared as 0.3.0.
Human Rationale
Bob wants MCP field validation to be easy to read, with small, decoupled abstractions. He chose path enumeration and formatting as general selector-library capabilities that can remove traversal and escaping code from Wistia. He asked for this PR to be reviewed before merging and publishing to RubyGems.
AI Usage
Codex implemented the APIs, documentation, and tests, then ran the full test/lint task and built the gem. A code-simplifier agent independently reviewed readability and correctness and checked 1,000 generated selector/value projection round trips without failures.
How to Test
Feature Flags
None.
Steps
bundle exec rake— 53 tests, 271 assertions, no failures; RuboCop inspected all 13 Ruby files with no offenses.bundle exec rake build— successfully buildspkg/json-mask-0.3.0.gem.Screenshots / Videos (User-Facing Only)
BEFORE:
selection_treeand escape diagnostic paths themselves.AFTER:
mask.each_pathandJsonMask.format_path(path).