Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SelectLocated, golangci-lint, NormalizedPath #9

Merged
merged 2 commits into from
Dec 27, 2024
Merged

Conversation

theory
Copy link
Owner

@theory theory commented Dec 27, 2024

SelectLocated works just like Select, but returns a slice of LocatedNodes that contain the same nodes as those returned by Select paired with NormalizedPaths that uniquely identify their locations within the JSON query argument. RFC 9535 section 2.7 defines normalized paths, including their string representation, implemented here. The design largely borrows from serde_json_path's query_located method.

Add SelectLocated to the Selector interface and implement it in each selector, segments, and queries. The implementation is quite similar to Select, but takes care to properly construct NormalizedPaths for each selected node. Update all tests to validate both methods.

The new NormalSelector interface defines normalized path selectors, of which there are two: Index and Name. Name, in particular, attempts to hew to the RFC's stringification grammar as closely as possible.

Also: upgrade golangci-lint to v1.62.2 and update its configuration

@theory theory self-assigned this Dec 27, 2024
Copy link

codecov bot commented Dec 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (addf9a1) to head (d812b0c).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main        #9    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           14        15     +1     
  Lines         1732      1873   +141     
==========================================
+ Hits          1732      1873   +141     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

`SelectLocated` works just like `Select`, but returns a slice of
`LocatedNode`s that contain the same nodes as those returned by `Select`
paired with `NormalizedPath`s that uniquely identify their locations
within the JSON query argument. [RFC 9535 section 2.7] defines
normalized paths, including their string representation, implemented
here. The design largely borrows from [serde_json_path]'s
[`query_located`] method.

Add `SelectLocated` to the `Selector` interface and implement it in each
selector, segments, and queries. The implementation is quite similar to
`Select`, but takes care to properly construct `NormalizedPath`s for
each selected node. Update all tests to validate both methods.

The new `NormalSelector` interface defines normalized path selectors, of
which there are two: `Index` and `Name`. `Name`, in particular, attempts
to hew to the RFC's stringification grammar as closely as possible.

Also: upgrade golangci-lint to v1.62.2 and update its configuration

[RFC 9535 section 2.7]: https://www.rfc-editor.org/rfc/rfc9535#section-2.7
[serde_json_path]: https://github.com/hiltontj/serde_json_path
[`query_located`]: https://docs.rs/serde_json_path/latest/serde_json_path/struct.JsonPath.html#method.query_located
And record the the addition of `SelectLocated` in the change log.
@theory theory merged commit d812b0c into main Dec 27, 2024
7 checks passed
@theory theory deleted the normal-path branch December 27, 2024 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant