relaton-bib 2.1.1 → 2.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbd5aea414046c022dca2c76a39b03469e284b3e40e5f466d45cc2095b872426
4
- data.tar.gz: 549058e3a8f7d02fa187cc49764c674894bbf8853ec1aca87de367320f8a3700
3
+ metadata.gz: 103ee7e7e99ea81a307302c1dd476f812a7b1f9b1653213062e0bf80b9950987
4
+ data.tar.gz: 031625043b1a7b9d6a2d2d674b68f500ccfec8f836c7d9d645a8f4e751cd88e1
5
5
  SHA512:
6
- metadata.gz: 247065b32df801e9e0d4b01b66ca3e9ce3c17840eb7209f61d0717df322e84ef0996b1de3d706990b774733f3018e5dc8fb0c4f36a320ca8f2b94b5732163748
7
- data.tar.gz: 31e0342c3793206c94478852cec92e31f4274aca78f69ed64b7ad2e79a39b66b6e68e326e22e5b38e9f8ecd2c69e38e4942a2939b7175a3869b7d73dcc273a8a
6
+ metadata.gz: 34d61ff26b50b995ac955707449111866cd15f30c68beda845f0ae3fcb7fe04e1e7999b8c560b3f874dac83e0777cbc7b26723000c8cfd8b0c2e7f11b734e7cf
7
+ data.tar.gz: 838061a378904a0a338e9c87f569099b45656e33614265eb07a61afaa9e7e0b76f5278faeb4e414451fc31c11936867c3db01e61e52f65cd7cc490510e1967bc
@@ -12,11 +12,37 @@ module Relaton
12
12
  map_element "text", to: :text
13
13
  end
14
14
 
15
+ # Returns the explicit text if set, else the Isoics description for
16
+ # `code`. Kept for consumers that read `.text` directly.
15
17
  def text
16
- val = @text
17
- return val if val && !val.empty?
18
+ return @text if @text.is_a?(String) && !@text.empty?
18
19
 
19
- Isoics.fetch(code)&.description if code
20
+ Isoics.fetch(code)&.description if code.is_a?(String) && !code.empty?
21
+ end
22
+
23
+ # When code is assigned, eagerly populate text from Isoics if no
24
+ # explicit text has been set. Going through the public writer
25
+ # registers the value with the lutaml-model `value_set_for` tracker
26
+ # so the attribute is emitted on serialization.
27
+ def code=(val)
28
+ super
29
+ return unless val.is_a?(String) && !val.empty?
30
+ return if @text.is_a?(String) && !@text.empty?
31
+
32
+ description = Isoics.fetch(val)&.description
33
+ self.text = description if description
34
+ end
35
+
36
+ # When the deserializer reaches the end of the XML element and
37
+ # records that <text> was absent, it calls `using_default_for(:text)`
38
+ # to mark the attribute as default-valued (suppressing serialization).
39
+ # Refuse that mark if we've already populated text from Isoics so the
40
+ # value survives round-trip. See #112.
41
+ def using_default_for(attribute_name)
42
+ return if attribute_name == :text &&
43
+ @text.is_a?(String) && !@text.empty?
44
+
45
+ super
20
46
  end
21
47
  end
22
48
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Bib
3
- VERSION = "2.1.1".freeze
3
+ VERSION = "2.1.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-06 00:00:00.000000000 Z
11
+ date: 2026-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bibtex-ruby