relaton-bib 2.0.0.pre.alpha.6 → 2.0.0.pre.alpha.7

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: df8a186e99080f04f69cd39523b60ae094d44c366519e8634b3a84732654035d
4
- data.tar.gz: 471cfc9f0cd4998e9d4b151800dad5e9d93be2e840655f029a536614ddca6180
3
+ metadata.gz: e3fe5b77c0ee8f91ec2b4e1d57c10351e0eea9ce718b28fcb0040c47b1264827
4
+ data.tar.gz: 883cdc867ba51a5101e9c288c387d23cebee1f3f4d3571a81b6061b522db2876
5
5
  SHA512:
6
- metadata.gz: ba6276c2b6af2b9bc200e71afedc86c960fb5599f24f30fcc9932853b4d8c67b58d76f82ffc264cdcec8664063a54691fb677eec016be7e0bacb5ce289209037
7
- data.tar.gz: '094187c15b5c9effa8712c463b870426b7461c140326dd93abf8be107aace294bd4d951aea18b1e26b1f448e03d744924b7b7a9f1e1594bf4fe6dc9808baa3e3'
6
+ metadata.gz: 9020cbe421387930baefbf07d6219fdb3e95733d04902c1d67d9e22fb6feca331cd5175ccdd925ba38fd70e7fb62bc005803e7513e895248ea6d0fb11a88d159
7
+ data.tar.gz: da47ca0cffcfb0a76e1632f02bc3a5faf74b7aad02c10d4a2331c6af85511910784e7ee51a5ac9c939c4ede896d24234dcc5415b8c692bd3185bb06efd32db84
@@ -187,6 +187,15 @@ Applicable to modify and delete</a:documentation>
187
187
  <a:documentation>Optional caption of this block</a:documentation>
188
188
  </attribute>
189
189
  </optional>
190
+ <optional>
191
+ <attribute name="position">
192
+ <a:documentation>For an "add" change, whether the change is added before or after the location</a:documentation>
193
+ <choice>
194
+ <value>before</value>
195
+ <value>after</value>
196
+ </choice>
197
+ </attribute>
198
+ </optional>
190
199
  <optional>
191
200
  <element name="location">
192
201
  <a:documentation>The location(s) in the original document which have undergone the change described in this block</a:documentation>
@@ -208,11 +217,15 @@ Applicable to modify and delete</a:documentation>
208
217
  </zeroOrMore>
209
218
  <optional>
210
219
  <element name="newcontent">
211
- <a:documentation>New content to be added to the document; applicable to add and modify</a:documentation>
220
+ <a:documentation>New content to be added to the document; applicable to add and modify.
221
+ Can be blocks and/or sections</a:documentation>
212
222
  <ref name="OptionalId"/>
213
223
  <zeroOrMore>
214
224
  <ref name="BasicBlock"/>
215
225
  </zeroOrMore>
226
+ <zeroOrMore>
227
+ <ref name="section"/>
228
+ </zeroOrMore>
216
229
  </element>
217
230
  </optional>
218
231
  <zeroOrMore>
data/grammars/biblio.rng CHANGED
@@ -466,11 +466,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
466
466
  <a:documentation>Contact information for the organization, including address, phone number, and email</a:documentation>
467
467
  </ref>
468
468
  </optional>
469
- <optional>
469
+ <zeroOrMore>
470
470
  <ref name="logo">
471
471
  <a:documentation>A logo for the organization</a:documentation>
472
472
  </ref>
473
- </optional>
473
+ </zeroOrMore>
474
474
  </define>
475
475
  <define name="orgname">
476
476
  <element name="name">
@@ -502,6 +502,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
502
502
  </define>
503
503
  <define name="logo">
504
504
  <element name="logo">
505
+ <optional>
506
+ <attribute name="type">
507
+ <a:documentation>The type of logo</a:documentation>
508
+ </attribute>
509
+ </optional>
505
510
  <ref name="image-no-id"/>
506
511
  </element>
507
512
  </define>
@@ -513,6 +518,11 @@ Editorial and advisory groups are represented as consecutive subdivisions of the
513
518
  <a:documentation>Description of what is being depicted</a:documentation>
514
519
  </attribute>
515
520
  </optional>
521
+ <optional>
522
+ <attribute name="type">
523
+ <a:documentation>Description of what kind of depiction this</a:documentation>
524
+ </attribute>
525
+ </optional>
516
526
  <zeroOrMore>
517
527
  <ref name="image-no-id">
518
528
  <a:documentation>A visual depiction of the bibliographic item</a:documentation>
@@ -690,7 +700,7 @@ Examples include GRID, LEI, CrossRef, and Ringgold</a:documentation>
690
700
  <define name="CitationType">
691
701
  <attribute name="bibitemid">
692
702
  <a:documentation>Bibliographic item that the citation applies to, referenced as the anchor of a bibliographic description</a:documentation>
693
- <data type="IDREF"/>
703
+ <ref name="IdRefType"/>
694
704
  </attribute>
695
705
  <choice>
696
706
  <zeroOrMore>
@@ -1132,11 +1142,11 @@ NOTE: This should preferably be encoded as a URI or short identifier, rather th
1132
1142
  <a:documentation>Information about how long the current description of the bibliographic item is valid for</a:documentation>
1133
1143
  </ref>
1134
1144
  </optional>
1135
- <optional>
1145
+ <zeroOrMore>
1136
1146
  <ref name="depiction">
1137
1147
  <a:documentation>Depiction of the bibliographic item, typically an image</a:documentation>
1138
1148
  </ref>
1139
- </optional>
1149
+ </zeroOrMore>
1140
1150
  </define>
1141
1151
  <define name="ReducedBibliographicItem">
1142
1152
  <a:documentation>Reduced description of a bibliographic resource, without mandatory title and docidentifier, used for document relations
@@ -1236,9 +1246,9 @@ Refer to `BibliographicItem` for definitions</a:documentation>
1236
1246
  <optional>
1237
1247
  <ref name="validity"/>
1238
1248
  </optional>
1239
- <optional>
1249
+ <zeroOrMore>
1240
1250
  <ref name="depiction"/>
1241
- </optional>
1251
+ </zeroOrMore>
1242
1252
  </define>
1243
1253
  <define name="btitle">
1244
1254
  <a:documentation>A title of a bibliographic item, associated with a type of title</a:documentation>
@@ -1296,17 +1306,17 @@ for which this claim of validity is made, if applicable</a:documentation>
1296
1306
  </define>
1297
1307
  <define name="validityBegins">
1298
1308
  <element name="validityBegins">
1299
- <ref name="ISO8601Date"/>
1309
+ <ref name="ISO8601DateTime"/>
1300
1310
  </element>
1301
1311
  </define>
1302
1312
  <define name="validityEnds">
1303
1313
  <element name="validityEnds">
1304
- <ref name="ISO8601Date"/>
1314
+ <ref name="ISO8601DateTime"/>
1305
1315
  </element>
1306
1316
  </define>
1307
1317
  <define name="validityRevision">
1308
1318
  <element name="revision">
1309
- <ref name="ISO8601Date"/>
1319
+ <ref name="ISO8601DateTime"/>
1310
1320
  </element>
1311
1321
  </define>
1312
1322
  <define name="TypedTitleString">
@@ -1929,10 +1939,10 @@ Detailed in https://www.relaton.org/model/relations/</a:documentation>
1929
1939
  <value>hasAnnotation</value>
1930
1940
  <value>draftOf</value>
1931
1941
  <value>hasDraft</value>
1932
- <value>preliminaryDraftOf</value>
1933
- <value>hasPreliminaryDraft</value>
1934
- <value>revisionDraftOf</value>
1935
- <value>hasRevisionDraft</value>
1942
+ <value>predecessorDraftOf</value>
1943
+ <value>hasPredecessorDraft</value>
1944
+ <value>successorDraftOf</value>
1945
+ <value>hasSuccessorDraft</value>
1936
1946
  <value>editionOf</value>
1937
1947
  <value>hasEdition</value>
1938
1948
  <value>updates</value>
@@ -2053,13 +2063,13 @@ provided that it is not the entire bibliographic item that is so related</a:docu
2053
2063
  <ref name="LocalizedString"/>
2054
2064
  </element>
2055
2065
  </optional>
2056
- <oneOrMore>
2066
+ <zeroOrMore>
2057
2067
  <element name="taxon">
2058
2068
  <a:documentation>The keywords as a hierarchical taxonomy. For example, the sequence of `taxon` elements
2059
2069
  `pump`, `centrifugal pump`, `line shaft pump` represents a taxonomic classification</a:documentation>
2060
2070
  <ref name="LocalizedString"/>
2061
2071
  </element>
2062
- </oneOrMore>
2072
+ </zeroOrMore>
2063
2073
  <zeroOrMore>
2064
2074
  <ref name="vocabid">
2065
2075
  <a:documentation>Identifiers for the keyword as a controlled vocabulary</a:documentation>
@@ -1,35 +1,35 @@
1
1
  {
2
- "relaton-models": "v1.4.1",
3
- "basicdoc-models": "v1.2.2",
2
+ "relaton-models": "v1.5.6",
3
+ "basicdoc-models": "v1.2.5",
4
4
  "metanorma-requirements-models": "v1.0.2",
5
- "relaton-model-ieee": "v1.0.1",
6
- "relaton-model-iso": "v1.0.5",
7
- "relaton-model-iec": "v1.0.0",
8
- "relaton-model-bsi": "v1.0.3",
9
- "relaton-model-gb": "v1.0.0",
5
+ "relaton-model-ieee": "v1.1.3",
6
+ "relaton-model-iso": "v1.1.2",
7
+ "relaton-model-iec": "v1.1.2",
8
+ "relaton-model-bsi": "v1.1.3",
9
+ "relaton-model-gb": "v1.1.2",
10
10
  "relaton-model-mpfa": "v1.0.0",
11
- "relaton-model-bipm": "v1.0.1",
11
+ "relaton-model-bipm": "v1.1.2",
12
12
  "relaton-model-w3c": "v1.0.0",
13
- "relaton-model-3gpp": "v1.0.1",
14
- "relaton-model-csa": "v1.0.0",
15
- "relaton-model-cc": "v1.0.0",
16
- "relaton-model-ietf": "v1.0.1",
17
- "relaton-model-iho": "v1.0.0",
18
- "relaton-model-itu": "v1.0.2",
19
- "relaton-model-m3aawg": "v1.0.0",
20
- "relaton-model-nist": "v1.0.0",
21
- "relaton-model-ribose": "v1.0.0",
22
- "relaton-model-ogc": "v1.0.1",
23
- "relaton-model-un": "v1.0.0",
13
+ "relaton-model-3gpp": "v1.0.4",
14
+ "relaton-model-cc": "v1.1.2",
15
+ "relaton-model-ietf": "v1.1.2",
16
+ "relaton-model-iho": "v1.1.2",
17
+ "relaton-model-itu": "v1.1.3",
18
+ "relaton-model-m3aawg": "v1.0.1",
19
+ "relaton-model-nist": "v1.1.2",
20
+ "relaton-model-ribose": "v1.1.2",
21
+ "relaton-model-ogc": "v1.1.2",
24
22
  "relaton-model-cen": "v1.0.1",
25
23
  "relaton-model-ecma": "v1.0.0",
26
24
  "relaton-model-cie": "v1.0.0",
27
25
  "relaton-model-iana": "v1.0.0",
28
26
  "relaton-model-omg": "v1.0.0",
29
- "relaton-model-oasis": "v1.0.1",
30
- "relaton-model-jis": "v0.0.1",
31
- "relaton-model-etsi": "v0.0.3",
32
- "relaton-model-plateau": "v0.0.2",
33
- "metanorma-model": "v1.4.1",
34
- "date": "2024-12-03T03:33:24Z"
27
+ "relaton-model-oasis": "v1.0.4",
28
+ "relaton-model-jis": "v1.0.2",
29
+ "relaton-model-etsi": "v0.1.2",
30
+ "relaton-model-plateau": "v0.1.0",
31
+ "relaton-model-ccsds": "",
32
+ "relaton-model-un": "v1.0.2",
33
+ "metanorma-model": "v2.1.6",
34
+ "date": "2026-04-03T02:05:43Z"
35
35
  }
@@ -102,7 +102,7 @@ module Relaton
102
102
 
103
103
  ed = @item.edition
104
104
  pref = "edition"
105
- out = "#{pref}.content:: #{ed.content}\n"
105
+ out = ed.content ? "#{pref}.content:: #{ed.content}\n" : ""
106
106
  out << "#{pref}.number:: #{ed.number}\n" if ed.number
107
107
  out
108
108
  end
@@ -404,7 +404,7 @@ module Relaton
404
404
  pref = prefix.empty? ? prefix : "#{prefix}."
405
405
  out = count > 1 ? "#{pref}identifier::\n" : ""
406
406
  out << "#{pref}identifier.type:: #{id.type}\n"
407
- out << "#{pref}identifier.content:: #{id.content}\n"
407
+ out << "#{pref}identifier.content:: #{id.content}\n" if id.content
408
408
  out
409
409
  end
410
410
 
@@ -422,7 +422,11 @@ module Relaton
422
422
  ids = array(org.identifier)
423
423
  ids.each { |n| out << render_org_identifier(n, pref, ids.size) }
424
424
  out << render_contact(org, pref)
425
- out << render_logo(org.logo, pref) if org.logo
425
+ logos = array(org.logo)
426
+ logos.each do |l|
427
+ out << ("#{pref}.logo::\n" if logos.size > 1).to_s
428
+ out << render_logo(l, pref)
429
+ end
426
430
  out
427
431
  end
428
432
 
@@ -430,7 +434,7 @@ module Relaton
430
434
  pref = prefix.empty? ? prefix : "#{prefix}."
431
435
  out = count > 1 ? "#{pref}identifier::\n" : ""
432
436
  out << "#{pref}identifier.type:: #{id.type}\n"
433
- out << "#{pref}identifier.content:: #{id.content}\n"
437
+ out << "#{pref}identifier.content:: #{id.content}\n" if id.content
434
438
  out
435
439
  end
436
440
 
@@ -511,7 +515,7 @@ module Relaton
511
515
  def render_bibitem(item, prefix) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
512
516
  pref = prefix.empty? ? prefix : "#{prefix}."
513
517
  out = ""
514
- out << "#{pref}formattedref:: #{item.formattedref}\n" if item.formattedref
518
+ out << "#{pref}formattedref:: #{item.formattedref.content}\n" if item.formattedref
515
519
  array(item.title).each { |t| out << render_title(t, prefix, array(item.title).size) }
516
520
  array(item.docidentifier).each do |di|
517
521
  out << render_docidentifier(di, prefix, array(item.docidentifier).size)
@@ -547,7 +551,7 @@ module Relaton
547
551
  pref = prefix.empty? ? "series" : "#{prefix}.series"
548
552
  out = count > 1 ? "#{pref}::\n" : ""
549
553
  out << "#{pref}.type:: #{ser.type}\n" if ser.type
550
- out << "#{pref}.formattedref:: #{ser.formattedref}\n" if ser.formattedref
554
+ out << "#{pref}.formattedref:: #{ser.formattedref.content}\n" if ser.formattedref
551
555
  array(ser.title).each { |t| out << render_title(t, pref, 1) }
552
556
  out << render_series_place(ser.place, pref) if ser.place
553
557
  out << "#{pref}.organization:: #{ser.organization}\n" if ser.organization
@@ -580,7 +584,7 @@ module Relaton
580
584
  end
581
585
 
582
586
  def render_formattedref
583
- @item.formattedref ? "formattedref:: #{@item.formattedref}\n" : ""
587
+ @item.formattedref ? "formattedref:: #{@item.formattedref.content}\n" : ""
584
588
  end
585
589
 
586
590
  def render_keywords
@@ -589,8 +593,11 @@ module Relaton
589
593
  end
590
594
 
591
595
  def render_keyword(kw, prefix, count)
592
- taxons = array(kw.taxon)
593
- taxons.map { |t| render_localized_string(t, prefix, count) }.join
596
+ if kw.vocab
597
+ render_localized_string(kw.vocab, prefix, count)
598
+ else
599
+ array(kw.taxon).map { |t| render_localized_string(t, prefix, count) }.join
600
+ end
594
601
  end
595
602
 
596
603
  def render_ics_collection
@@ -644,7 +651,7 @@ module Relaton
644
651
  end
645
652
 
646
653
  out = count > 1 ? "#{prefix}::\n" : ""
647
- out << "#{pref}content:: #{ls.content}\n"
654
+ out << "#{pref}content:: #{ls.content}\n" if ls.content
648
655
  out << "#{pref}language:: #{ls.language}\n" if ls.language
649
656
  out << "#{pref}script:: #{ls.script}\n" if ls.script
650
657
  out
@@ -230,7 +230,7 @@ module Relaton
230
230
  # @return [Array<Relaton::Bib::Keyword>]
231
231
  def fetch_keyword
232
232
  @entry["keywords"]&.split(/,\s?/)&.map do |kw|
233
- Keyword.new(taxon: [LocalizedString.new(content: kw)])
233
+ Keyword.new(vocab: LocalizedString.new(content: kw))
234
234
  end || []
235
235
  end
236
236
 
@@ -296,7 +296,9 @@ module Relaton # rubocop:disable Style/OneClassPerFile
296
296
  #
297
297
  def add_keyword
298
298
  if @bib.keyword&.any?
299
- @item.keywords = @bib.keyword.reduce([]) { |m, kw| m + kw.taxon.map(&:content) }.join(", ")
299
+ @item.keywords = @bib.keyword.reduce([]) do |m, kw|
300
+ m + (kw.vocab ? [kw.vocab.content] : kw.taxon.map(&:content))
301
+ end.join(", ")
300
302
  end
301
303
  end
302
304
 
@@ -129,7 +129,7 @@ module Relaton
129
129
  def formattedref
130
130
  return if @reference.front.title
131
131
 
132
- @reference.anchor
132
+ Formattedref.new(content: @reference.anchor)
133
133
  end
134
134
 
135
135
  # --- Abstract ---
@@ -138,8 +138,7 @@ module Relaton
138
138
  return [] unless @reference.front.abstract&.t
139
139
 
140
140
  @reference.front.abstract.t.map do |t|
141
- LocalizedMarkedUpString.new(content: t.content, language: "en",
142
- script: "Latn")
141
+ Abstract.new(content: t.content, language: "en", script: "Latn")
143
142
  end
144
143
  end
145
144
 
@@ -331,9 +330,9 @@ module Relaton
331
330
 
332
331
  def keyword
333
332
  (@reference.front.keyword || []).map do |kw|
334
- taxon = LocalizedString.new(content: kw.content, language: "en",
333
+ vocab = LocalizedString.new(content: kw.content, language: "en",
335
334
  script: "Latn")
336
- Keyword.new(taxon: [taxon])
335
+ Keyword.new(vocab: vocab)
337
336
  end
338
337
  end
339
338
 
@@ -270,7 +270,11 @@ module Relaton
270
270
 
271
271
  def create_keyword
272
272
  @item.keyword.inject([]) do |a, k|
273
- a + k.taxon.map { |t| Rfcxml::V3::Keyword.new content: t.content }
273
+ if k.vocab
274
+ a + [Rfcxml::V3::Keyword.new(content: k.vocab.content)]
275
+ else
276
+ a + k.taxon.map { |t| Rfcxml::V3::Keyword.new(content: t.content) }
277
+ end
274
278
  end
275
279
  end
276
280
 
@@ -74,7 +74,7 @@ module Relaton
74
74
 
75
75
  def keyword_hash_to_bib(ret)
76
76
  ret[:keyword] = array(ret[:keyword]).map do |keyword|
77
- Bib::Keyword.new taxon: [localizedstring(keyword)]
77
+ Bib::Keyword.new vocab: localizedstring(keyword)
78
78
  end
79
79
  end
80
80
 
@@ -129,7 +129,9 @@ module Relaton
129
129
 
130
130
  def abstract_hash_to_bib(ret)
131
131
  ret[:abstract] &&= array(ret[:abstract]).map do |a|
132
- localized_marked_up_string a
132
+ a = { content: a } if a.is_a?(String)
133
+ lang_scrip_array_to_string(a)
134
+ Bib::Abstract.new(**a)
133
135
  end
134
136
  end
135
137
 
@@ -267,7 +269,9 @@ module Relaton
267
269
  org[:phone] = phone_hash_to_bib(org[:contact])
268
270
  org[:email] = email_hash_to_bib(org[:contact])
269
271
  org[:uri] = uri_hash_to_bib(org[:contact] || org)
270
- org[:logo] = Bib::Logo.new image: Bib::Image.new(**org[:logo][:image]) if org[:logo]
272
+ org[:logo] = array(org[:logo]).map do |l|
273
+ Bib::Logo.new(image: Bib::Image.new(**l[:image]))
274
+ end
271
275
  org[:name] = typed_localized_string(org[:name])
272
276
  org[:abbreviation] &&= localizedstring(org[:abbreviation])
273
277
  org
@@ -599,10 +603,13 @@ module Relaton
599
603
  p = period == :ends ? -1 : 1
600
604
  case t
601
605
  when /^\d{4}$/
602
- ::Date.new(t.to_i, p, p).to_time
606
+ ::Date.new(t.to_i, p, p).to_datetime.to_time.utc
603
607
  when /^(?<year>\d{4})-(?<month>\d{1,2})$/
604
- ::Date.new($~[:year].to_i, $~[:month].to_i, p).to_time
605
- else ::Date.parse t
608
+ ::Date.new($~[:year].to_i, $~[:month].to_i, p).to_datetime.to_time.utc
609
+ else
610
+ # Default to UTC when no timezone is specified
611
+ t += " UTC" unless t.match?(/[+-]\d{2}:?\d{2}\s*$|Z\s*$/i)
612
+ ::Time.parse t
606
613
  end
607
614
  end
608
615
 
@@ -716,11 +723,10 @@ module Relaton
716
723
  # @return [Relaton::Bib::Formattedref]
717
724
  def formattedref(frf)
718
725
  if frf.is_a?(Hash)
719
- # Relaton::Bib::Formattedref.new(**frf)
720
- frf[:content]
726
+ lang_scrip_array_to_string(frf)
727
+ Relaton::Bib::Formattedref.new(**frf)
721
728
  else
722
- # Relaton::Bib::Formattedref.new(content: frf)
723
- frf
729
+ Relaton::Bib::Formattedref.new(content: frf)
724
730
  end
725
731
  end
726
732
 
@@ -9,12 +9,12 @@ module Relaton
9
9
 
10
10
  ATTRIBUTES = %i[
11
11
  type schema_version fetched formattedref docnumber edition status
12
- medium size validity depiction ext
12
+ medium size validity ext
13
13
  ].freeze
14
14
  COLLECTION_ATTRBUTES = %i[
15
15
  date contributor version note language locale script
16
16
  copyright series place price extent accesslocation license
17
- classification keyword
17
+ classification keyword depiction
18
18
  ].freeze
19
19
  COLLECTION_WRITE_ONLY_ATTRIBUTES = %i[title abstract source relation].freeze
20
20
 
@@ -0,0 +1,16 @@
1
+ module Relaton
2
+ module Bib
3
+ class Abstract < LocalizedMarkedUpString
4
+ attribute :format, :string
5
+
6
+ xml do
7
+ root "abstract"
8
+ map_attribute "format", to: :format
9
+ end
10
+
11
+ key_value do
12
+ map "format", to: :format
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,11 +2,13 @@ module Relaton
2
2
  module Bib
3
3
  class Depiction < Lutaml::Model::Serializable
4
4
  attribute :scope, :string
5
+ attribute :type, :string
5
6
  attribute :image, Image, collection: true, initialize_empty: true
6
7
 
7
8
  xml do
8
9
  root "depiction"
9
10
  map_attribute "scope", to: :scope
11
+ map_attribute "type", to: :type
10
12
  map_element "image", to: :image
11
13
  end
12
14
  end
@@ -0,0 +1,43 @@
1
+ module Relaton
2
+ module Bib
3
+ class Formattedref < LocalizedMarkedUpString
4
+ attribute :format, :string
5
+
6
+ xml do
7
+ root "formattedref"
8
+ map_attribute "format", to: :format
9
+ end
10
+
11
+ key_value do
12
+ map "format", to: :format
13
+ end
14
+
15
+ # Handle plain string input from YAML/JSON deserialization
16
+ def self.from_yaml(value)
17
+ return new(content: value) if value.is_a?(String)
18
+
19
+ super
20
+ end
21
+
22
+ def self.from_json(value)
23
+ return new(content: value) if value.is_a?(String)
24
+
25
+ super
26
+ end
27
+
28
+ # Serialize as plain string when only content is present
29
+ def self.as(format, instance, options = {})
30
+ return instance.content if simple_content?(instance, format)
31
+
32
+ super
33
+ end
34
+
35
+ def self.simple_content?(instance, format)
36
+ return false if format == :xml
37
+
38
+ instance.format.nil? && instance.language.nil? &&
39
+ instance.script.nil? && instance.locale.nil?
40
+ end
41
+ end
42
+ end
43
+ end
@@ -2,6 +2,8 @@ require "lutaml/model"
2
2
  require "lutaml/model/xml_adapter/nokogiri_adapter"
3
3
  require_relative "localized_string_attrs"
4
4
  require_relative "localized_string"
5
+ require_relative "formattedref"
6
+ require_relative "abstract"
5
7
  require_relative "date"
6
8
  require_relative "locality"
7
9
  require_relative "locality_stack"
@@ -59,7 +61,7 @@ module Relaton
59
61
  ]
60
62
  attribute :schema_version, method: :get_schema_version
61
63
  attribute :fetched, :date
62
- attribute :formattedref, :string, raw: true
64
+ attribute :formattedref, Formattedref
63
65
  attribute :title, Title, collection: true, initialize_empty: true
64
66
  attribute :source, Uri, collection: true, initialize_empty: true
65
67
  attribute :docidentifier, Docidentifier, collection: true, initialize_empty: true
@@ -72,7 +74,7 @@ module Relaton
72
74
  attribute :language, :string, collection: true, initialize_empty: true
73
75
  attribute :locale, :string, collection: true, initialize_empty: true
74
76
  attribute :script, :string, collection: true, initialize_empty: true
75
- attribute :abstract, LocalizedMarkedUpString, collection: true, initialize_empty: true
77
+ attribute :abstract, Abstract, collection: true, initialize_empty: true
76
78
  attribute :status, Status
77
79
  attribute :copyright, Copyright, collection: true, initialize_empty: true
78
80
  attribute :relation, Relation, collection: true, initialize_empty: true
@@ -87,7 +89,7 @@ module Relaton
87
89
  attribute :classification, Docidentifier, collection: true, initialize_empty: true
88
90
  attribute :keyword, Keyword, collection: true, initialize_empty: true
89
91
  attribute :validity, Validity
90
- attribute :depiction, Depiction
92
+ attribute :depiction, Depiction, collection: true, initialize_empty: true
91
93
  attribute :ext, Ext
92
94
 
93
95
  xml do # rubocop:disable Metrics/BlockLength
@@ -15,9 +15,9 @@ module Relaton
15
15
  end
16
16
  end
17
17
 
18
- attribute :vocab, LocalizedString, collection: true, initialize_empty: true
19
- attribute :taxon, LocalizedString, collection: (1..), initialize_empty: true
20
- attribute :vocabid, Vocabid
18
+ attribute :vocab, LocalizedString
19
+ attribute :taxon, LocalizedString, collection: true, initialize_empty: true
20
+ attribute :vocabid, Vocabid, collection: true, initialize_empty: true
21
21
 
22
22
  xml do
23
23
  root "keyword"
@@ -1,10 +1,12 @@
1
1
  module Relaton
2
2
  module Bib
3
3
  class Logo < Lutaml::Model::Serializable
4
+ attribute :type, :string
4
5
  attribute :image, Image
5
6
 
6
7
  xml do
7
8
  root "logo"
9
+ map_attribute "type", to: :type
8
10
  map_element "image", to: :image
9
11
  end
10
12
  end
@@ -22,7 +22,7 @@ module Relaton
22
22
  attribute :subdivision, Subdivision, collection: true, initialize_empty: true
23
23
  attribute :abbreviation, LocalizedString
24
24
  attribute :identifier, Identifier, collection: true, initialize_empty: true
25
- attribute :logo, Logo
25
+ attribute :logo, Logo, collection: true, initialize_empty: true
26
26
 
27
27
  xml do
28
28
  map_element "name", to: :name
@@ -9,8 +9,8 @@ module Relaton
9
9
  hasManifestation reproductionOf hasReproduction reprintOf hasReprint
10
10
  expressionOf hasExpression translatedFrom hasTranslation arrangementOf
11
11
  hasArrangement abridgementOf hasAbridgement annotationOf hasAnnotation
12
- draftOfhasDraft preliminaryDraftOf hasPreliminaryDraft revisionDraftOf
13
- hasRevisionDraft editionOf hasEdition updates updatedBy derivedFrom
12
+ draftOf hasDraft predecessorDraftOf hasPredecessorDraft successorDraftOf
13
+ hasSuccessorDraft editionOf hasEdition updates updatedBy derivedFrom
14
14
  derives describes describedBy catalogues cataloguedBy hasSuccessor
15
15
  successorOf adaptedFrom hasAdaptation adoptedFrom adoptedAs reviewOf
16
16
  hasReview commentaryOf hasCommentary related hasComplement complementOf
@@ -4,7 +4,7 @@ module Relaton
4
4
  module Bib
5
5
  class Series < Lutaml::Model::Serializable
6
6
  attribute :type, :string, values: %w[main alt]
7
- attribute :formattedref, :string, raw: true
7
+ attribute :formattedref, Formattedref
8
8
  attribute :title, Title, collection: (1..)
9
9
  attribute :place, Place
10
10
  attribute :organization, :string
@@ -1,9 +1,9 @@
1
1
  module Relaton
2
2
  module Bib
3
3
  class Validity < Lutaml::Model::Serializable
4
- attribute :begins, :date
5
- attribute :ends, :date
6
- attribute :revision, :date
4
+ attribute :begins, :date_time
5
+ attribute :ends, :date_time
6
+ attribute :revision, :date_time
7
7
 
8
8
  xml do
9
9
  root "validity"
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Bib
3
- VERSION = "2.0.0-alpha.6".freeze
3
+ VERSION = "2.0.0-alpha.7".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.6
4
+ version: 2.0.0.pre.alpha.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -177,6 +177,7 @@ files:
177
177
  - lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb
178
178
  - lib/relaton/bib/hash_parser_v1.rb
179
179
  - lib/relaton/bib/item_data.rb
180
+ - lib/relaton/bib/model/abstract.rb
180
181
  - lib/relaton/bib/model/address.rb
181
182
  - lib/relaton/bib/model/affiliation.rb
182
183
  - lib/relaton/bib/model/bibdata.rb
@@ -192,6 +193,7 @@ files:
192
193
  - lib/relaton/bib/model/edition.rb
193
194
  - lib/relaton/bib/model/ext.rb
194
195
  - lib/relaton/bib/model/extent.rb
196
+ - lib/relaton/bib/model/formattedref.rb
195
197
  - lib/relaton/bib/model/full_name_type.rb
196
198
  - lib/relaton/bib/model/fullname.rb
197
199
  - lib/relaton/bib/model/ics.rb