ics: persist Isoics description so XML round-trip preserves <text>#113
Merged
Conversation
…serves <text> Under lutaml-model 0.8, child elements parsed from XML and re-serialized via a parent collection skip attributes whose backing ivar holds no explicit value (the user-defined `#text` accessor is not consulted in that path). Push the Isoics fallback through the public `text=` writer when `code` is assigned, and refuse the post-parse `using_default_for` mark, so the description is emitted on subsequent `to_xml`. Adds spec coverage for the XML round-trip behaviour: `ICS.new(code:)`, `ICS.from_xml`, `Ext.from_xml` nesting an ICS with no `<text>`, and the explicit-text-wins case. Closes #112.
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.
Summary
Fixes #112 —
<bibdata/ext/ics/text>is dropped on XML round-trip when the source omits<text>, under lutaml-model 0.8.The previous design relied on a getter-only Isoics fallback in
Relaton::Bib::ICS#text. lutaml-model 0.8 reads attribute values from the backing instance variable for nested-collection serialization (and consults@using_default[:text]), so a getter-only fallback is not picked up in that path —<text>is omitted from the output even thoughics.textreturns the Isoics description.This change pushes the Isoics fallback through the public
text=writer at the pointcodeis assigned, and refuses the post-parseusing_default_for(:text)mark so the value survives the deserialization consolidation step.Changes
lib/relaton/bib/model/ics.rbcode=override pushes Isoics description throughself.text=whenever@textis unset, so lutaml-model records the value viavalue_set_for(:text).using_default_foroverride refuses to mark:textas default when@textalready holds a string value, so the deserialization consolidation step doesn't suppress emission.#textaccessor kept as a convenience for direct readers.spec/relaton/bib/model/ics_spec.rbXML serialization with Isoics fallbackgroup adds round-trip coverage that the existing#get_textgroup did not exercise:ICS.new(code:),ICS.from_xmlstandalone,Ext.from_xmlnesting an ICS with no<text>(the canonical metanorma collection round-trip path), the explicit-text-wins case, and the invalid-code case.Test plan
bundle exec rspec spec/relaton/bib/model/ics_spec.rb— 11/11 pass (5 existing + 6 new).bundle exec rspec— full suite green (190/190).