relaton-bib 2.0.0.pre.alpha.8 → 2.1.0

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: 728031e16c72a2dd3fd0b360c160a7140835e08f106ba02cf2cd0575749943ae
4
- data.tar.gz: 73ad0387057360d47dc27e61ac2f0458e3179fde8755ab38518d50c6be243974
3
+ metadata.gz: 73e04205cda443de9b4c9f4b5d3ccbb9c62bfb5492c42a977a08ad385e2f3614
4
+ data.tar.gz: ea57c9c8ef051e0a9031595a853512c4984b52c4cfaa3e2ef565a19fb080bcd0
5
5
  SHA512:
6
- metadata.gz: 407325046db2de8f575386879ee87aa219fb244899cf22eeded21ad26e2e3267b3b584d6aec9e5af5056a202165dfe40186f96e576cf5f3a63485a41bd492a6c
7
- data.tar.gz: d495848aa3d5ec9fb69ee5987d842ae703e80e3d24d81d895d501957c02745041bb12f4f72b4de472243ff4ea0280e4280fbbccb8bb7b92b278f62e18228b05e
6
+ metadata.gz: b5ec1ef76fc6a7739713f0555bb1ed457604dd4d3465ed4108e70cc508ed7096c05dad9b61b6b719ae4318d640af1b46cb445d7c3fd6226ebed4a8123dfb1ffa
7
+ data.tar.gz: 7ab3eeef1061507bce7327b82faa10568ec201445b3e0676cec57662183b517915b450a9f92d512b5ba0945f96ffe256a1ca2de5b6cbf2aadf668608424bca1d
data/grammars/biblio.rng CHANGED
@@ -2015,15 +2015,11 @@ provided that it is not the entire bibliographic item that is so related</a:docu
2015
2015
  <a:documentation>A version of the bibliographic item (within an edition). Can be used for drafts</a:documentation>
2016
2016
  <element name="version">
2017
2017
  <optional>
2018
- <ref name="revision-date">
2019
- <a:documentation>The date at which the current version of the bibliographic item was produced</a:documentation>
2020
- </ref>
2021
- </optional>
2022
- <optional>
2023
- <ref name="draft">
2024
- <a:documentation>The identifier for the current draft of the bibliographic item</a:documentation>
2025
- </ref>
2018
+ <attribute name="type">
2019
+ <a:documentation>Versioning scheme, in case of multiple versioning schemes</a:documentation>
2020
+ </attribute>
2026
2021
  </optional>
2022
+ <text/>
2027
2023
  </element>
2028
2024
  </define>
2029
2025
  <define name="vedition">
@@ -31,5 +31,5 @@
31
31
  "relaton-model-ccsds": "",
32
32
  "relaton-model-un": "v1.0.2",
33
33
  "metanorma-model": "v2.1.6",
34
- "date": "2026-04-03T02:05:43Z"
34
+ "date": "2026-04-30T03:49:24Z"
35
35
  }
@@ -123,8 +123,8 @@ module Relaton
123
123
  def render_version(ver, prefix, count)
124
124
  pref = prefix.empty? ? prefix : "#{prefix}."
125
125
  out = count > 1 ? "#{prefix}version::\n" : ""
126
- out << "#{pref}version.revision_date:: #{ver.revision_date}\n" if ver.revision_date
127
- out << "#{pref}version.draft:: #{ver.draft}\n" if ver.draft
126
+ out << "#{pref}version:: #{ver.content}\n" if ver.content
127
+ out << "#{pref}version.type:: #{ver.type}\n" if ver.type
128
128
  out
129
129
  end
130
130
 
@@ -138,7 +138,7 @@ module Relaton
138
138
  return [] unless @reference.front.abstract&.t
139
139
 
140
140
  @reference.front.abstract.t.map do |t|
141
- Abstract.new(content: t.content, language: "en", script: "Latn")
141
+ Abstract.new(content: t.content.join, language: "en", script: "Latn")
142
142
  end
143
143
  end
144
144
 
@@ -218,7 +218,7 @@ module Relaton
218
218
  org = author.organization
219
219
  return if org.nil? || org.content.empty?
220
220
 
221
- name = ORGNAMES[org.content] || org.content
221
+ name = ORGNAMES[org.content.join] || org.content.join
222
222
  orgname = TypedLocalizedString.new(content: name, language: "en")
223
223
  abbrev = LocalizedString.new(content: org.abbrev, language: "en") if org.abbrev
224
224
  Organization.new(
@@ -120,7 +120,7 @@ module Relaton
120
120
  abbrev = org.abbreviation&.content
121
121
  orgname = resolve_orgname(org, abbrev)
122
122
  Rfcxml::V3::Organization.new(
123
- content: orgname, abbrev: abbrev,
123
+ content: [orgname], abbrev: abbrev,
124
124
  )
125
125
  end
126
126
 
@@ -283,7 +283,7 @@ module Relaton
283
283
 
284
284
  content = @item.abstract[0].content
285
285
  Rfcxml::V3::Abstract.new(
286
- t: [Rfcxml::V3::Text.new(content: content)],
286
+ t: [Rfcxml::V3::Text.new(content: [content])],
287
287
  )
288
288
  end
289
289
 
@@ -196,10 +196,23 @@ module Relaton
196
196
  def version_hash_to_bib(ret)
197
197
  return unless ret[:version]
198
198
 
199
- ret[:version] = array(ret[:version]).map do |v|
200
- v[:revision_date] &&= parse_date(v[:revision_date], str: false)
201
- Bib::Version.new(**v)
202
- end
199
+ ret[:version] = array(ret[:version]).map { |v| version_entry(v) }
200
+ end
201
+
202
+ def version_entry(hash)
203
+ return Bib::Version.new(**hash) if hash[:content]
204
+
205
+ attrs = { content: legacy_version_content(hash) }
206
+ attrs[:type] = hash[:type] if hash[:type]
207
+ Bib::Version.new(**attrs)
208
+ end
209
+
210
+ def legacy_version_content(hash)
211
+ draft = hash[:draft]
212
+ revdate = hash[:revision_date]
213
+ return "#{draft} (#{revdate})" if draft && revdate
214
+
215
+ draft || revdate
203
216
  end
204
217
 
205
218
  def biblionote_hash_to_bib(ret)
@@ -1,23 +1,10 @@
1
+ require_relative "bibdata_shared"
2
+
1
3
  module Relaton
2
4
  module Bib
3
- module BibdataShared
4
- def self.included(base)
5
- base.class_eval do
6
- model ItemData
7
-
8
- # Bibdata doesn't have id attribute.
9
- attributes.delete :id
10
- mappings[:xml].instance_variable_get(:@attributes).delete("id")
11
-
12
- xml do
13
- root "bibdata"
14
- end
15
- end
16
- end
17
- end
18
-
19
- # This class represents a bibliographic item as a bibdata.
5
+ # Bibliographic item serialized as <bibdata>. Has ext, no id.
20
6
  class Bibdata < Item
7
+ model ItemData
21
8
  include BibdataShared
22
9
  end
23
10
  end
@@ -0,0 +1,12 @@
1
+ require_relative "item_shared"
2
+
3
+ module Relaton
4
+ module Bib
5
+ module BibdataShared
6
+ def self.included(base)
7
+ base.xml { root "bibdata" }
8
+ ItemShared.prune_attribute(base, :id, "id")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,22 +1,10 @@
1
+ require_relative "bibitem_shared"
2
+
1
3
  module Relaton
2
4
  module Bib
3
- module BibitemShared
4
- def self.included(base)
5
- base.class_eval do
6
- model ItemData
7
-
8
- # This class represents a bibliographic item as a bibitem.
9
- attributes.delete :ext
10
- mappings[:xml].instance_variable_get(:@elements).delete("ext")
11
-
12
- xml do
13
- root "bibitem"
14
- end
15
- end
16
- end
17
- end
18
-
5
+ # Bibliographic item serialized as <bibitem>. Has id, no ext.
19
6
  class Bibitem < Item
7
+ model ItemData
20
8
  include BibitemShared
21
9
  end
22
10
  end
@@ -0,0 +1,12 @@
1
+ require_relative "item_shared"
2
+
3
+ module Relaton
4
+ module Bib
5
+ module BibitemShared
6
+ def self.included(base)
7
+ base.xml { root "bibitem" }
8
+ ItemShared.prune_attribute(base, :ext, "ext")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -16,56 +16,14 @@ module Relaton
16
16
  end
17
17
 
18
18
  attribute :role, Role, collection: true, initialize_empty: true
19
- # attribute :entity, ContributionInfo
20
- # @TODO: use `import_model ContributionInfo` for person and organization when Lutaml supports it
21
- choice(min: 1, max: 1) do
22
- attribute :person, Person
23
- attribute :organization, Organization
24
- end
25
- # import_model_attributes ContributionInfo
19
+ import_model_attributes ContributionInfo
26
20
 
27
21
  xml do
28
22
  root "contributor"
29
23
 
30
24
  map_element "role", to: :role
31
- # map_content to: :entity, with: { from: :entity_from_xml, to: :entity_to_xml }
32
- map_element "person", to: :person
33
- map_element "organization", to: :organization # , with: { from: :organization_from_xml, to: :organization_to_xml }
25
+ import_model_mappings ContributionInfo
34
26
  end
35
-
36
- # def entity
37
- # person || organization
38
- # end
39
-
40
- # def entity=(value)
41
- # if value.is_a? Person
42
- # self.person = value
43
- # self.organization = nil
44
- # elsif value.is_a? Organization
45
- # self.organization = value
46
- # self.person = nil
47
- # else
48
- # raise ArgumentError, "value must be a Person or Organization"
49
- # end
50
- # end
51
-
52
- # def organization_from_xml(model, node)
53
- # model.entity = Organization.of_xml node
54
- # end
55
-
56
- # def organization_to_xml(model, parent, _doc)
57
- # parent << model.entity.to_xml
58
- # end
59
-
60
- # def entity_from_xml(model, node)
61
- # n = node.instance_variable_get(:@node) || node
62
- # model.content = ContributionInfo.of_xml n
63
- # rescue StandardError
64
- # end
65
-
66
- # def entity_to_xml(model, parent, _doc)
67
- # parent << model.content.to_xml
68
- # end
69
27
  end
70
28
  end
71
29
  end
@@ -6,6 +6,7 @@ module Relaton
6
6
  attribute :primary, :boolean
7
7
 
8
8
  xml do
9
+ root "docidentifier"
9
10
  map_attribute "type", to: :type
10
11
  map_attribute "scope", to: :scope
11
12
  map_attribute "primary", to: :primary
@@ -5,7 +5,7 @@ require_relative "structured_identifier"
5
5
  module Relaton
6
6
  module Bib
7
7
  class Ext < Lutaml::Model::Serializable
8
- attribute :schema_version, :string
8
+ attribute :schema_version, :string, method: :get_schema_version
9
9
  attribute :doctype, Doctype
10
10
  attribute :subdoctype, :string
11
11
  attribute :flavor, :string
@@ -14,13 +14,26 @@ module Relaton
14
14
 
15
15
  xml do
16
16
  root "ext"
17
- map_attribute "schema-version", to: :schema_version
17
+ map_attribute "schema-version", to: :schema_version, render_default: true
18
18
  map_element "doctype", to: :doctype
19
19
  map_element "subdoctype", to: :subdoctype
20
20
  map_element "flavor", to: :flavor
21
21
  map_element "ics", to: :ics
22
22
  map_element "structuredidentifier", to: :structuredidentifier
23
23
  end
24
+
25
+ key_value do
26
+ map_element "schema_version", to: :schema_version, render_default: true
27
+ map_element "doctype", to: :doctype
28
+ map_element "subdoctype", to: :subdoctype
29
+ map_element "flavor", to: :flavor
30
+ map_element "ics", to: :ics
31
+ map_element "structuredidentifier", to: :structuredidentifier
32
+ end
33
+
34
+ # Base returns nil so direct use omits schema-version. Subclasses in
35
+ # downstream relaton gems override to return their own version.
36
+ def get_schema_version = nil
24
37
  end
25
38
  end
26
39
  end
@@ -1,5 +1,5 @@
1
1
  require "lutaml/model"
2
- require "lutaml/model/xml_adapter/nokogiri_adapter"
2
+ require "lutaml/xml"
3
3
  require_relative "localized_string_attrs"
4
4
  require_relative "localized_string"
5
5
  require_relative "formattedref"
@@ -36,9 +36,11 @@ require_relative "validity"
36
36
  require_relative "depiction"
37
37
  require_relative "source_locality_stack"
38
38
  require_relative "ext"
39
+ require_relative "item_shared"
40
+ require_relative "type/plain_date"
39
41
 
40
42
  Lutaml::Model::Config.configure do |config|
41
- config.xml_adapter = Lutaml::Model::Xml::NokogiriAdapter
43
+ config.xml_adapter_type = :nokogiri
42
44
  end
43
45
 
44
46
  module Relaton
@@ -47,91 +49,41 @@ module Relaton
47
49
  end
48
50
 
49
51
  # Item class repesents bibliographic item metadata.
52
+ # Used for YAML/JSON parsing and as the XML dispatch entry point.
50
53
  class Item < Lutaml::Model::Serializable
54
+ include NamespaceHelper
55
+
51
56
  attr_accessor :type # in some cases mehod type is unavailable
52
57
 
53
58
  model ItemData
54
59
 
60
+ def self.from_xml(xml, options = {})
61
+ return super unless self == namespace::Item
62
+
63
+ # lutaml-model has no built-in dispatch on root element name
64
+ # (polymorphic_map only works on attribute discriminators), so we
65
+ # peek at the root tag with Nokogiri and forward to the right class.
66
+ root_name = Nokogiri::XML(xml.to_s).root&.name
67
+ klass = root_name == "bibdata" ? namespace::Bibdata : namespace::Bibitem
68
+ klass.from_xml(xml, options)
69
+ end
70
+
55
71
  attribute :id, :string
56
- attribute :type, :string, values: %W[
57
- article book booklet manual proceedings presentation thesis techreport standard
58
- unpublished map electronic\sresource audiovisual film video boradcast software
59
- graphic_work music patent inbook incollection inproceedings journal website
60
- webresource dataset archival social_media alert message convesation misc
61
- ]
62
- attribute :schema_version, method: :get_schema_version
63
- attribute :fetched, :date
64
- attribute :formattedref, Formattedref
65
- attribute :title, Title, collection: true, initialize_empty: true
66
- attribute :source, Uri, collection: true, initialize_empty: true
67
- attribute :docidentifier, Docidentifier, collection: true, initialize_empty: true
68
- attribute :docnumber, :string
69
- attribute :date, Date, collection: true, initialize_empty: true
70
- attribute :contributor, Contributor, collection: true, initialize_empty: true
71
- attribute :edition, Edition
72
- attribute :version, Version, collection: true, initialize_empty: true
73
- attribute :note, Note, collection: true, initialize_empty: true
74
- attribute :language, :string, collection: true, initialize_empty: true
75
- attribute :locale, :string, collection: true, initialize_empty: true
76
- attribute :script, :string, collection: true, initialize_empty: true
77
- attribute :abstract, Abstract, collection: true, initialize_empty: true
78
- attribute :status, Status
79
- attribute :copyright, Copyright, collection: true, initialize_empty: true
80
- attribute :relation, Relation, collection: true, initialize_empty: true
81
- attribute :series, Series, collection: true, initialize_empty: true
82
- attribute :medium, Medium
83
- attribute :place, Place, collection: true, initialize_empty: true
84
- attribute :price, Price, collection: true, initialize_empty: true
85
- attribute :extent, Extent, collection: true, initialize_empty: true
86
- attribute :size, Size
87
- attribute :accesslocation, :string, collection: true, initialize_empty: true
88
- attribute :license, :string, collection: true, initialize_empty: true
89
- attribute :classification, Docidentifier, collection: true, initialize_empty: true
90
- attribute :keyword, Keyword, collection: true, initialize_empty: true
91
- attribute :validity, Validity
92
- attribute :depiction, Depiction, collection: true, initialize_empty: true
72
+ attribute :schema_version, :string, method: :get_schema_version
73
+ attribute :fetched, PlainDate
74
+ instance_exec(&ItemShared::ATTRIBUTES)
93
75
  attribute :ext, Ext
94
76
 
95
- xml do # rubocop:disable Metrics/BlockLength
77
+ xml do
96
78
  map_attribute "id", to: :id
97
79
  map_attribute "type", to: :type
98
- map_attribute "schema-version", to: :schema_version
80
+ map_attribute "schema-version", to: :schema_version, render_default: true
99
81
  map_element "fetched", to: :fetched
100
- map_element "formattedref", to: :formattedref
101
- map_element "title", to: :title # , with: { from: :title_from_xml, to: :title_to_xml }
102
- map_element "uri", to: :source
103
- map_element "docidentifier", to: :docidentifier
104
- map_element "docnumber", to: :docnumber
105
- map_element "date", to: :date
106
- map_element "contributor", to: :contributor
107
- map_element "edition", to: :edition
108
- map_element "version", to: :version
109
- map_element "note", to: :note
110
- map_element "language", to: :language
111
- map_element "locale", to: :locale
112
- map_element "script", to: :script
113
- map_element "abstract", to: :abstract
114
- map_element "status", to: :status
115
- map_element "copyright", to: :copyright
116
- map_element "relation", to: :relation # , with: { from: :relation_from_xml, to: :relation_to_xml }
117
- map_element "series", to: :series
118
- map_element "medium", to: :medium
119
- map_element "place", to: :place
120
- map_element "price", to: :price
121
- map_element "extent", to: :extent
122
- map_element "size", to: :size
123
- map_element "accesslocation", to: :accesslocation
124
- map_element "license", to: :license
125
- map_element "classification", to: :classification
126
- map_element "keyword", to: :keyword
127
- map_element "validity", to: :validity
128
- map_element "depiction", to: :depiction
82
+ instance_exec(&ItemShared::XML_BODY)
129
83
  map_element "ext", to: :ext
130
84
  end
131
85
 
132
- def get_schema_version
133
- Relaton.schema_versions["relaton-models"]
134
- end
86
+ def get_schema_version = Relaton.schema_versions["relaton-models"]
135
87
  end
136
88
  end
137
89
  end
@@ -1,27 +1,20 @@
1
1
  module Relaton
2
2
  module Bib
3
- # Module to remove id, schema-version, fetched & ext attributes from Item subclasses.
4
- # Used for bibitem/relation instances that don't need these attributes.
5
- module ItemBaseAttributes
6
- def self.included(base)
7
- # we don't need id, schema-version & fetched attributes in relation/bibitem
8
- base.mappings[:xml].instance_variable_get(:@attributes).delete("id")
9
- base.mappings[:xml].instance_variable_get(:@attributes).delete("schema-version")
10
- base.mappings[:xml].instance_variable_get(:@elements).delete("fetched")
11
- base.mappings[:xml].instance_variable_get(:@elements).delete("ext")
12
- base.attributes.delete :id
13
- base.attributes.delete :schema_version
14
- base.attributes.delete :fetched
15
- base.attributes.delete :ext
16
- end
17
- end
3
+ # Bibliographic item used as a nested element inside Relation.
4
+ # Has neither id, schema_version, fetched, nor ext.
5
+ class ItemBase < Lutaml::Model::Serializable
6
+ include NamespaceHelper
7
+
8
+ attr_accessor :type
18
9
 
19
- # The class is for relaton bibitem instances.
20
- # The in relaton bibitem instances dosn't have schema-version & fetched attributes.
21
- class ItemBase < Item
22
10
  model ItemData
23
11
 
24
- include ItemBaseAttributes
12
+ instance_exec(&ItemShared::ATTRIBUTES)
13
+
14
+ xml do
15
+ map_attribute "type", to: :type
16
+ instance_exec(&ItemShared::XML_BODY)
17
+ end
25
18
  end
26
19
  end
27
20
  end
@@ -0,0 +1,88 @@
1
+ module Relaton
2
+ module Bib
3
+ # Shared attribute and XML mapping declarations for Item/Bibitem/Bibdata/ItemBase.
4
+ # Each class composes these with its own header (id/schema_version/fetched/ext)
5
+ # via instance_exec, so subtractive monkey-patching of inherited mappings is
6
+ # not needed.
7
+ module ItemShared
8
+ ATTRIBUTES = lambda do # rubocop:disable Metrics/BlockLength
9
+ attribute :type, :string, values: %W[
10
+ article book booklet manual proceedings presentation thesis techreport standard
11
+ unpublished map electronic\sresource audiovisual film video boradcast software
12
+ graphic_work music patent inbook incollection inproceedings journal website
13
+ webresource dataset archival social_media alert message convesation misc
14
+ ]
15
+ attribute :formattedref, Formattedref
16
+ attribute :title, Title, collection: true, initialize_empty: true
17
+ attribute :source, Uri, collection: true, initialize_empty: true
18
+ attribute :docidentifier, Docidentifier, collection: true, initialize_empty: true
19
+ attribute :docnumber, :string
20
+ attribute :date, Date, collection: true, initialize_empty: true
21
+ attribute :contributor, Contributor, collection: true, initialize_empty: true
22
+ attribute :edition, Edition
23
+ attribute :version, Version, collection: true, initialize_empty: true
24
+ attribute :note, Note, collection: true, initialize_empty: true
25
+ attribute :language, :string, collection: true, initialize_empty: true
26
+ attribute :locale, :string, collection: true, initialize_empty: true
27
+ attribute :script, :string, collection: true, initialize_empty: true
28
+ attribute :abstract, Abstract, collection: true, initialize_empty: true
29
+ attribute :status, Status
30
+ attribute :copyright, Copyright, collection: true, initialize_empty: true
31
+ attribute :relation, Relation, collection: true, initialize_empty: true
32
+ attribute :series, Series, collection: true, initialize_empty: true
33
+ attribute :medium, Medium
34
+ attribute :place, Place, collection: true, initialize_empty: true
35
+ attribute :price, Price, collection: true, initialize_empty: true
36
+ attribute :extent, Extent, collection: true, initialize_empty: true
37
+ attribute :size, Size
38
+ attribute :accesslocation, :string, collection: true, initialize_empty: true
39
+ attribute :license, :string, collection: true, initialize_empty: true
40
+ attribute :classification, Docidentifier, collection: true, initialize_empty: true
41
+ attribute :keyword, Keyword, collection: true, initialize_empty: true
42
+ attribute :validity, Validity
43
+ attribute :depiction, Depiction, collection: true, initialize_empty: true
44
+ end
45
+
46
+ def self.prune_attribute(base, attr_name, xml_name)
47
+ return unless base.attributes.key?(attr_name)
48
+
49
+ xml_mapping = base.mappings[:xml]
50
+ xml_mapping.instance_variable_get(:@elements).delete(xml_name)
51
+ xml_mapping.instance_variable_get(:@attributes).delete(xml_name)
52
+ base.attributes.delete(attr_name)
53
+ end
54
+
55
+ XML_BODY = lambda do # rubocop:disable Metrics/BlockLength
56
+ map_element "formattedref", to: :formattedref
57
+ map_element "title", to: :title
58
+ map_element "uri", to: :source
59
+ map_element "docidentifier", to: :docidentifier
60
+ map_element "docnumber", to: :docnumber
61
+ map_element "date", to: :date
62
+ map_element "contributor", to: :contributor
63
+ map_element "edition", to: :edition
64
+ map_element "version", to: :version
65
+ map_element "note", to: :note
66
+ map_element "language", to: :language
67
+ map_element "locale", to: :locale
68
+ map_element "script", to: :script
69
+ map_element "abstract", to: :abstract
70
+ map_element "status", to: :status
71
+ map_element "copyright", to: :copyright
72
+ map_element "relation", to: :relation
73
+ map_element "series", to: :series
74
+ map_element "medium", to: :medium
75
+ map_element "place", to: :place
76
+ map_element "price", to: :price
77
+ map_element "extent", to: :extent
78
+ map_element "size", to: :size
79
+ map_element "accesslocation", to: :accesslocation
80
+ map_element "license", to: :license
81
+ map_element "classification", to: :classification
82
+ map_element "keyword", to: :keyword
83
+ map_element "validity", to: :validity
84
+ map_element "depiction", to: :depiction
85
+ end
86
+ end
87
+ end
88
+ end
@@ -8,7 +8,7 @@ module Relaton
8
8
  end
9
9
 
10
10
  key_value do
11
- map "content", to: :content # , with: { from: :content_from_key_value, to: :content_to_key_value }
11
+ map "content", to: :content
12
12
  map "language", to: :language
13
13
  end
14
14
  end
@@ -26,32 +26,16 @@ module Relaton
26
26
  end
27
27
 
28
28
  class LocalizedMarkedUpString < LocalizedStringAttrs
29
- attribute :content, :string
29
+ attribute :content, :string, raw: true
30
30
 
31
31
  xml do
32
- map_all to: :content, with: { from: :content_from_xml, to: :content_to_xml }
32
+ map_all to: :content
33
33
  end
34
34
 
35
35
  key_value do
36
- map "content", to: :content, with: { from: :content_from_key_value, to: :content_to_key_value }
36
+ map "content", to: :content
37
37
  map "language", to: :language
38
38
  end
39
-
40
- def content_from_xml(model, value)
41
- model.content = value
42
- end
43
-
44
- def content_to_xml(model, parent, doc)
45
- doc.add_xml_fragment parent, model.content
46
- end
47
-
48
- def content_from_key_value(model, value)
49
- model.content = value
50
- end
51
-
52
- def content_to_key_value(model, doc)
53
- doc["content"] = model.content
54
- end
55
39
  end
56
40
  end
57
41
  end
@@ -0,0 +1,16 @@
1
+ require "date"
2
+
3
+ module Relaton
4
+ module Bib
5
+ # xs:date value type that always casts to ::Date, dropping any time and
6
+ # timezone component. Without this, lutaml-model's built-in Date type
7
+ # promotes inputs like "2018-04-15T00:00:00Z" to ::DateTime and serializes
8
+ # them back as "2018-04-15Z" — valid xs:date, but not valid ISO 8601.
9
+ class PlainDate < Lutaml::Model::Type::Date
10
+ def self.cast(value, options = {})
11
+ result = super
12
+ result.is_a?(::DateTime) ? result.to_date : result
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,14 +1,43 @@
1
1
  module Relaton
2
2
  module Bib
3
3
  class Version < Lutaml::Model::Serializable
4
- attribute :revision_date, :date
4
+ attribute :type, :string
5
+ attribute :content, :string
6
+ attribute :revision_date, :string
5
7
  attribute :draft, :string
6
8
 
7
9
  xml do
8
10
  root "version"
11
+ map_attribute "type", to: :type
12
+ map_content to: :content
9
13
  map_element "revision-date", to: :revision_date
10
14
  map_element "draft", to: :draft
11
15
  end
16
+
17
+ key_value do
18
+ map "type", to: :type
19
+ map "content", to: :content
20
+ map "revision_date", to: :revision_date
21
+ map "draft", to: :draft
22
+ end
23
+
24
+ def content
25
+ return @content if @content && !@content.empty?
26
+
27
+ parts = [@draft, @revision_date].compact
28
+ case parts.size
29
+ when 2 then "#{@draft} (#{@revision_date})"
30
+ when 1 then parts.first
31
+ end
32
+ end
33
+
34
+ def revision_date
35
+ nil
36
+ end
37
+
38
+ def draft
39
+ nil
40
+ end
12
41
  end
13
42
  end
14
43
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Bib
3
- VERSION = "2.0.0-alpha.8".freeze
3
+ VERSION = "2.1.0".freeze
4
4
  end
5
5
  end
data/lib/relaton/bib.rb CHANGED
@@ -11,6 +11,8 @@ require_relative "bib/namespace_helper"
11
11
  require_relative "bib/item_data"
12
12
  require_relative "bib/model/item"
13
13
  require_relative "bib/model/item_base"
14
+ require_relative "bib/model/bibitem_shared"
15
+ require_relative "bib/model/bibdata_shared"
14
16
  require_relative "bib/model/bibitem"
15
17
  require_relative "bib/model/bibdata"
16
18
  require_relative "bib/converter/bibxml"
data/relaton-bib.gemspec CHANGED
@@ -26,10 +26,10 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "bibtex-ruby"
27
27
  spec.add_dependency "iso639"
28
28
  spec.add_dependency "isoics", "~> 0.1.0"
29
- spec.add_dependency "lutaml-model", "~> 0.7"
29
+ spec.add_dependency "lutaml-model", "~> 0.8.0"
30
30
  spec.add_dependency "nokogiri", ">= 1.16"
31
31
  spec.add_dependency "psych", "~> 5.2.0" # versin 5.3.0 crashes
32
32
  spec.add_dependency "relaton-core", "~> 0.0.8"
33
33
  spec.add_dependency "relaton-logger", "~> 0.2.0"
34
- spec.add_dependency "rfcxml", "~> 0.2.1"
34
+ spec.add_dependency "rfcxml", "~> 0.4.3"
35
35
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.8
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-05-02 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: bibtex-ruby
@@ -57,14 +58,14 @@ dependencies:
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
- version: '0.7'
61
+ version: 0.8.0
61
62
  type: :runtime
62
63
  prerelease: false
63
64
  version_requirements: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - "~>"
66
67
  - !ruby/object:Gem::Version
67
- version: '0.7'
68
+ version: 0.8.0
68
69
  - !ruby/object:Gem::Dependency
69
70
  name: nokogiri
70
71
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +128,14 @@ dependencies:
127
128
  requirements:
128
129
  - - "~>"
129
130
  - !ruby/object:Gem::Version
130
- version: 0.2.1
131
+ version: 0.4.3
131
132
  type: :runtime
132
133
  prerelease: false
133
134
  version_requirements: !ruby/object:Gem::Requirement
134
135
  requirements:
135
136
  - - "~>"
136
137
  - !ruby/object:Gem::Version
137
- version: 0.2.1
138
+ version: 0.4.3
138
139
  description: 'Relaton::Bib: Ruby XMLDOC impementation.'
139
140
  email:
140
141
  - open.source@ribose.com
@@ -181,7 +182,9 @@ files:
181
182
  - lib/relaton/bib/model/address.rb
182
183
  - lib/relaton/bib/model/affiliation.rb
183
184
  - lib/relaton/bib/model/bibdata.rb
185
+ - lib/relaton/bib/model/bibdata_shared.rb
184
186
  - lib/relaton/bib/model/bibitem.rb
187
+ - lib/relaton/bib/model/bibitem_shared.rb
185
188
  - lib/relaton/bib/model/contact.rb
186
189
  - lib/relaton/bib/model/contribution_info.rb
187
190
  - lib/relaton/bib/model/contributor.rb
@@ -200,6 +203,7 @@ files:
200
203
  - lib/relaton/bib/model/image.rb
201
204
  - lib/relaton/bib/model/item.rb
202
205
  - lib/relaton/bib/model/item_base.rb
206
+ - lib/relaton/bib/model/item_shared.rb
203
207
  - lib/relaton/bib/model/keyword.rb
204
208
  - lib/relaton/bib/model/locality.rb
205
209
  - lib/relaton/bib/model/locality_stack.rb
@@ -222,6 +226,7 @@ files:
222
226
  - lib/relaton/bib/model/structured_identifier.rb
223
227
  - lib/relaton/bib/model/subdivision.rb
224
228
  - lib/relaton/bib/model/title.rb
229
+ - lib/relaton/bib/model/type/plain_date.rb
225
230
  - lib/relaton/bib/model/type/string_date.rb
226
231
  - lib/relaton/bib/model/uri.rb
227
232
  - lib/relaton/bib/model/validity.rb
@@ -234,6 +239,7 @@ homepage: https://github.com/relaton/relaton-bib
234
239
  licenses:
235
240
  - BSD-2-Clause
236
241
  metadata: {}
242
+ post_install_message:
237
243
  rdoc_options: []
238
244
  require_paths:
239
245
  - lib
@@ -248,7 +254,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
254
  - !ruby/object:Gem::Version
249
255
  version: '0'
250
256
  requirements: []
251
- rubygems_version: 3.6.9
257
+ rubygems_version: 3.5.22
258
+ signing_key:
252
259
  specification_version: 4
253
260
  summary: 'Relaton::Bib: Ruby XMLDOC impementation.'
254
261
  test_files: []