nori 2.9.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +5 -1
- data/lib/nori/version.rb +1 -1
- data/lib/nori/xml_utility_node.rb +17 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad5bbd690d533a62edcdedfe9a4f3d96f117e6cb744a64b9e268676189be1f92
|
|
4
|
+
data.tar.gz: f8d68043348d270b1e7eeb93b1ae9dfd7abbb18b52181a655b0001d34900d492
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 81a096bff5c1d667ba3f51d8474c6b9732cf3c128ccb0b17ccf73af780fb83e0b2f60883f4ed26b9a426465e4f4b89d77aaa2ff090d1b174ab138a779280fd0e
|
|
7
|
+
data.tar.gz: ae0f9173142a7e0f544c0a70a6de05877d96d884d03a87d8154052efb587ba6a5ca93898f2bd4127193e1742d7db1eaf500277797e561cbf6590d7ab6d50ca8d
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.9.1] - 2026-07-05
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
* 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_typecasting` or a bare `type=` cast) now takes the same hash shape as string values: `<status source="ldap">true</status>` becomes `{"#text" => true, "@source" => "ldap"}` instead of a bare `true` that 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 `#text` is whatever the typecasting produced. Combined with `standards: true` no typecasting happens and `#text` is always a string.
|
|
13
|
+
|
|
14
|
+
* The `#text` key of the `:serializable` hash shape now goes through `:convert_tags_to` like 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_to` formula sees every key it emits, which also means a caller who prefers a plain `text` key over the XML JSON convention can now map `"#text"` in their formula.
|
|
15
|
+
|
|
8
16
|
## [2.9.0] - 2026-07-05
|
|
9
17
|
|
|
10
18
|
### Changed
|
|
@@ -265,5 +273,6 @@ Please make sure to read the updated README for how to use the new version.
|
|
|
265
273
|
## 0.1.0 2009-03-28
|
|
266
274
|
* Initial release.
|
|
267
275
|
|
|
276
|
+
[2.9.1]: https://github.com/savonrb/nori/compare/v2.9.0...v2.9.1
|
|
268
277
|
[2.9.0]: https://github.com/savonrb/nori/compare/v2.8.0...v2.9.0
|
|
269
278
|
[2.8.0]: https://github.com/savonrb/nori/compare/v2.7.1...v2.8.0
|
data/README.md
CHANGED
|
@@ -219,7 +219,11 @@ Members of the profile:
|
|
|
219
219
|
with the `@`-prefixed attributes) instead of a `Nori::StringWithAttributes`.
|
|
220
220
|
This is the same `@`-keyed shape element nodes already use, so the attributes
|
|
221
221
|
survive `to_json`, `to_yaml`, and `Marshal`. A text node without attributes
|
|
222
|
-
stays a plain `String`.
|
|
222
|
+
stays a plain `String`. Typecast values keep their attributes the same way
|
|
223
|
+
(`{"#text" => true, "@source" => "ldap"}`) – attributes are never silently
|
|
224
|
+
dropped under the profile. The `#text` key goes through `convert_tags_to`
|
|
225
|
+
like every other key, so a key-converting formula can reshape it (or drop
|
|
226
|
+
the `#` entirely).
|
|
223
227
|
|
|
224
228
|
```ruby
|
|
225
229
|
Nori.new(:serializable => true).parse('<foo bar="baz">Content</foo>')
|
data/lib/nori/version.rb
CHANGED
|
@@ -255,10 +255,16 @@ class Nori
|
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
# Typecasts the text content of the node. String results are wrapped
|
|
258
|
-
# so the node's attributes stay accessible on the value.
|
|
258
|
+
# so the node's attributes stay accessible on the value. Typecast
|
|
259
|
+
# non-String results can only carry the attributes under the
|
|
260
|
+
# +:serializable+ profile, where every value with attributes takes the
|
|
261
|
+
# hash shape. Without the profile they are returned bare and the
|
|
262
|
+
# attributes are dropped, because a {StringWithAttributes} cannot wrap
|
|
263
|
+
# them.
|
|
259
264
|
def text_value
|
|
260
265
|
value = typecast_value(inner_html)
|
|
261
266
|
value = advanced_typecasting(value) if value.is_a?(String) && @options[:advanced_typecasting]
|
|
267
|
+
return serializable_value(value) if @options[:serializable]
|
|
262
268
|
value.is_a?(String) ? string_with_attributes(value) : value
|
|
263
269
|
end
|
|
264
270
|
|
|
@@ -331,19 +337,22 @@ class Nori
|
|
|
331
337
|
string
|
|
332
338
|
end
|
|
333
339
|
|
|
334
|
-
# The +:serializable+ representation of a
|
|
340
|
+
# The +:serializable+ representation of a +value+ and the node's
|
|
335
341
|
# attributes. A node with attributes maps to the XML JSON convention
|
|
336
342
|
# (+{"#text" => value}+ merged with the "@"-prefixed attributes) and a
|
|
337
|
-
# node without attributes maps to the plain
|
|
338
|
-
#
|
|
339
|
-
#
|
|
343
|
+
# node without attributes maps to the plain value. This holds for
|
|
344
|
+
# typecast non-String values too, so attributes are never silently
|
|
345
|
+
# dropped under the profile. The +#text+ key and the attribute keys go
|
|
346
|
+
# through the same tag conversion as every other key
|
|
347
|
+
# ({#prefixed_attribute_name}), so a +:convert_tags_to+ formula sees
|
|
348
|
+
# each key Nori emits.
|
|
340
349
|
#
|
|
341
|
-
# @param value [
|
|
342
|
-
# @return [Hash{String =>
|
|
350
|
+
# @param value [Object] the typecast text content of the node
|
|
351
|
+
# @return [Hash{String => Object}, Object] the hash shape when the node
|
|
343
352
|
# has attributes, otherwise the plain +value+
|
|
344
353
|
def serializable_value(value)
|
|
345
354
|
return value if attributes.empty?
|
|
346
|
-
{ "#text" => value }.merge(prefixed_attributes)
|
|
355
|
+
{ prefixed_attribute_name("#text") => value }.merge(prefixed_attributes)
|
|
347
356
|
end
|
|
348
357
|
|
|
349
358
|
def try_to_convert(value, &block)
|