Recent Releases of https://github.com/savonrb/nori
https://github.com/savonrb/nori - v2.9.1
Fixed
-
Under
:serializable, a typecast value no longer drops the node's attributes. A text node whose content gets converted to a non-String (by:advanced_typecastingor a baretype=cast) now takes the same hash shape as string values:<status source="ldap">true</status>becomes{"#text" => true, "@source" => "ldap"}instead of a baretruethat silently lost@source. This closes a data-dependent hole in the profile's no-silent-loss promise, where the same element kept or dropped its attributes depending on what its text happened to look like. The value at#textis whatever the typecasting produced. Combined withstandards: trueno typecasting happens and#textis always a string. -
The
#textkey of the:serializablehash shape now goes through:convert_tags_tolike every other key. Previously a key-converting formula (for example one that symbolizes keys) produced converted element and attribute keys next to a raw"#text"string key in the same hash. Nori's contract is that a:convert_tags_toformula sees every key it emits, which also means a caller who prefers a plaintextkey over the XML JSON convention can now map"#text"in their formula.
Changelog: https://github.com/savonrb/nori/blob/main/CHANGELOG.md
Commits: https://github.com/savonrb/nori/compare/v2.9.0...v2.9.1
- Ruby
Published by rubiii 3 months ago
https://github.com/savonrb/nori - v2.9.0
Changed
- The
:standardsprofile no longer applies schema-less typing. UnderNori.new(standards: true),:advanced_typecastingnow defaults tofalse(an explicitadvanced_typecasting: truestill wins), and the bare un-namespacedtype=andnil=attributes become ordinary attributes instead of casting instructions. No moretype=conversions (integer,date,decimal,array,file, ...), and only a prefixedxsi:nil="true"marks an element nil. These conventions come from Rails'Hash.from_xml(inherited via crack and merb), not from any XML spec. Without a schema, character data is just text. Knowing that<id>123</id>holds an integer is the business of a schema-aware layer, not a guess from string shape. Parsing without the profile is completely unchanged.
Added
- Add the
:serializableprofile option.Nori.new(serializable: true)returns plain, directly-serializable data with no custom value classes. A text node that also has attributes becomes a Hash in the XML JSON convention ({"#text" => content}merged with our existing@-prefixed attributes instead of aNori::StringWithAttributes, and a text node without attributes becomes a plainString. Atype="file"node is no longer decoded into aNori::StringIOFile, it folds into text and attributes like any other node, leaving the base64 content untouched for the caller to decode. Thattype=decoding is a Rails/ActiveSupportHash.from_xmlconvention Nori inherited via crack and merb, not part of any XML spec, which is why the plain-data profile drops it. With this, values surviveto_json,to_yaml, andMarshal. Opt-in on the 2.x line, probably the default in Nori 3.0. Reported by @ArnoldMEDLINQ (#107), thanks to @dub357 for pinpointing the cause and finding #106, and thanks to @ekzobrain whose hash-shape approach this builds on.
Changelog: https://github.com/savonrb/nori/blob/main/CHANGELOG.md
Commits: https://github.com/savonrb/nori/compare/v2.8.0...v2.9.0
- Ruby
Published by rubiii 3 months ago
https://github.com/savonrb/nori - v2.8.0
Added
-
Add the
:standardsprofile option.Nori.new(standards: true)turns on Nori's spec-correct parsing as a group rather than one flag at a time. Its first members are xml:space honoring (whitespace-only text underxml:space="preserve"is kept instead of stripped, with inheritance andxml:space="default"reset per XML 1.0 §2.10) and the XML string-value model for empty elements (implies:consistent_empty_tagswith an empty-string:empty_tag_value, both still overridable). Opt-in on the 2.x line, default in 3.0. Thanks to @md5 for raising thexml:space="preserve"case on #97. -
#97 Add the
:consistent_empty_tagsoption (#109). When enabled, every empty tag becomes the:empty_tag_value, whether it has attributes or not. A string value keeps the attributes accessible via#attributes, and an explicitxsi:nil="true"always becomesnil. Reported by @lukasbischof, who also proposed a fix in #98. Thanks to @md5 for surfacing another instance of it and pinpointing the cause.
Fixed
- Whitespace-only CDATA content is no longer stripped. A
<![CDATA[ ]]>section is the author's explicit literal-data marker, so its content is now preserved as text instead of being dropped, on both the Nokogiri and REXML parsers. Previously such a tag parsed tonil(or, with attributes, dropped the content and kept only the attributes). Non-whitespace CDATA is unchanged, and ordinary whitespace-only text is still stripped as before. Surfaced while auditing whitespace handling for #97, the same empty-tag/whitespace spec-compliance work as the:consistent_empty_tagsoption above.
Changelog: https://github.com/savonrb/nori/blob/main/CHANGELOG.md
Commits: https://github.com/savonrb/nori/compare/v2.17.1...v2.18.0
- Ruby
Published by rubiii 3 months ago
https://github.com/savonrb/nori - v2.7.1
What's Changed
- Stop monkey-patching String with #snakecase by @mchu in https://github.com/savonrb/nori/pull/102
New Contributors
- @mchu made their first contribution in https://github.com/savonrb/nori/pull/102
Full Changelog: https://github.com/savonrb/nori/compare/v2.7.0...v2.7.1
- Ruby
Published by pcai about 2 years ago
https://github.com/savonrb/nori - v2.7.0
- Added support for ruby 3.1, 3.2, 3.3. Dropped support for ruby 2.7 and below.
- Feature:
Nori::Parserhas a new option,:scrub_xml, which defaults to true, for scrubbing invalid characters (#72). This should allow documents containing invalid characters to still be parsed. - Fix: REXML parser changes
<inside CDATA to<(#94) - Change:
Object#blank?is no longer patched in.
- Ruby
Published by pcai over 2 years ago