-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 YAML::Nodes::Node#kind
#10432
Add YAML::Nodes::Node#kind
#10432
Conversation
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). |
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.
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.
I'm actually not sure this is a proper term for yaml. |
In the specs the term "data type" is used, and sometimes "node kind". Node kind is scalar and can hold atomic data types. |
The parser uses |
YAML::Nodes::Node#type
YAML::Nodes::Node#kind
* Serialize Enum to underscored String by default * Quote enums that serialise to YAML keywords * Account for libyaml version Co-authored by [email protected] * 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 <[email protected]>
This method is already included in #10431 but this is a proper introduction and wide-spread adaptation.
Node#type
Node#kind
returns a string represntation of the node type (document, scalar, sequence, mapping, alias) and makes error message nicer. Now they sayExpected scalar, not sequence
instead ofExpected scalar, not YAML::Nodes::Sequence
. There's no need for the full Crystal path name.EDIT: The method name was changed from
Node#type
toNode#kind
.