Add YAML::Nodes::Node#kind#10432
Merged
bcardiff merged 3 commits intocrystal-lang:masterfrom Feb 21, 2021
Merged
Conversation
Member
Author
|
It's a bit disappointing that only a single spec needed to be updated. This probably means that edge cases in YAML parsing are not tested much (at least not the expected error messages). |
bcardiff
approved these changes
Feb 21, 2021
Member
bcardiff
left a comment
There was a problem hiding this comment.
I usually prefer to use kind, data_type or other word that is neither class nor type. But if it's yaml jargon it could be fine.
Member
Author
|
I'm actually not sure this is a proper term for yaml. |
Member
|
In the specs the term "data type" is used, and sometimes "node kind". Node kind is scalar and can hold atomic data types. |
Member
Author
|
The parser uses |
bcardiff
approved these changes
Feb 21, 2021
YAML::Nodes::Node#typeYAML::Nodes::Node#kind
straight-shoota
added a commit
to straight-shoota/crystal
that referenced
this pull request
Feb 22, 2021
asterite
pushed a commit
that referenced
this pull request
Feb 23, 2021
* Serialize Enum to underscored String by default * Quote enums that serialise to YAML keywords * Account for libyaml version Co-authored by straightshoota@gmail.com * Serialize Flags enums to and from json as an array * Serialize Flags enums to and from yaml as an array * Sum parsed flag enum members before calling `from_value` * Add JSON::PullParser#raise * Add YAML::Nodes::Node#type * Improve specs and more strict implementation * Remove unnecessary token checks in JSON impl. * crystal tool format * Refactor to NumberConverter and simplify deserialization code * [CI] Print libyaml version * Fix spec libyaml compat * Add documentation * Update specs after #10432 Co-authored-by: Caspian Baska <caspianbaska@gmail.com>
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.
This method is already included in #10431 but this is a proper introduction and wide-spread adaptation.
Node#typeNode#kindreturns a string represntation of the node type (document, scalar, sequence, mapping, alias) and makes error message nicer. Now they sayExpected scalar, not sequenceinstead ofExpected scalar, not YAML::Nodes::Sequence. There's no need for the full Crystal path name.EDIT: The method name was changed from
Node#typetoNode#kind.