-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support for parsing multiple documents #369
base: main
Are you sure you want to change the base?
Support for parsing multiple documents #369
Conversation
This adds `parseYAML` and `parseAllYAMLs` to the `yaml` package object. The first is the single document parsing provided by `.asNode`. The second parses a sequence of documents. To implement this, a fairly small addition was made to `Composer`: `multipleFromEvents`. Which uses `composeNode` to parse `Node`s from the events so long as there are `tail` events returned. This also exposes the `pos` method of `Node`. This is useful when writing custom decoders for nicer error messages.
@lbialy could you take a quick look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks fine, just one nitpick that I have is that the convention is to have Yaml
and not YAML
so please rename the parseYAML
to parseYaml
and parseAllYAMLs
to parseAllYamls
.
Also a comprehensive test (from String to List of some T and back) would be nice.
Thanks for the review! Made the style changes and added a minimal test. |
Could you please rebase? I think the missing commits that touched sbt conf might be causing CI to fail (no idea why though :/ ). Also, wouldn't it also make sense to add |
Sure! I'll do both
Looks like CI got the updated ubuntu image which is missing sbt. I'll
select the prior release as well
…On Thu, Jan 16, 2025, 23:42 Łukasz Biały ***@***.***> wrote:
Could you please rebase? I think the missing commits that touched sbt conf
might be causing CI to fail (no idea why though :/ ).
Also, wouldn't it also make sense to add .asMany[T] combinator in this PR?
—
Reply to this email directly, view it on GitHub
<#369 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAIMDPAURBXPTAWQ2F3D5L2LCX6FAVCNFSM6AAAAABUDOMDSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJXGYYTOOBWGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@lbialy Done with the latest set of changes. Given the term There is also style change I like, but feel free to request me to undo: Have the String extension methods forwards to top level methods: |
fixing... |
what a strange one. The implicit string conversion in base suite conflicted with the one in the package object. Yet the compile was fine with this - until I did a clean recompile. |
This adds
parseAllYamls
,parseYaml
, and theasMany
extension method to theyaml
package object.parseAllYamls
either fails or returns a list of all yaml documents (Node
) contained in the string content.parseYaml
is an explicit form of the is the single document parsing provided by.asNode
.asMany[T]
- decodes string of multiple documents into a list ofT
To implement this, a fairly small addition was made to
Composer
:multipleFromEvents
. Which usescomposeNode
to parseNode
s from the events so long as there aretail
events returned.This also exposes the
pos
method ofNode
. This is useful when writing custom decoders for nicer error messages.