relaton-bib 1.20.7 → 2.0.0.pre.alpha.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.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/README.adoc +183 -154
  4. data/bin/console +1 -1
  5. data/grammars/basicdoc.rng +1516 -645
  6. data/grammars/biblio-standoc.rng +100 -20
  7. data/grammars/biblio.rng +959 -356
  8. data/grammars/versions.json +10 -10
  9. data/lib/relaton/bib/hash_parser_v1.rb +711 -0
  10. data/lib/relaton/bib/item_data.rb +168 -0
  11. data/lib/relaton/bib/model/address.rb +22 -0
  12. data/lib/relaton/bib/model/affiliation.rb +16 -0
  13. data/lib/relaton/bib/model/bibdata.rb +24 -0
  14. data/lib/relaton/bib/model/bibitem.rb +23 -0
  15. data/lib/relaton/bib/model/contact.rb +18 -0
  16. data/lib/relaton/bib/model/contribution_info.rb +16 -0
  17. data/lib/relaton/bib/model/contributor.rb +71 -0
  18. data/lib/relaton/bib/model/copyright.rb +27 -0
  19. data/lib/relaton/bib/model/date.rb +29 -0
  20. data/lib/relaton/bib/model/depiction.rb +14 -0
  21. data/lib/relaton/bib/model/docidentifier.rb +33 -0
  22. data/lib/relaton/bib/model/doctype.rb +14 -0
  23. data/lib/relaton/bib/model/edition.rb +14 -0
  24. data/lib/relaton/bib/model/editorial_group.rb +14 -0
  25. data/lib/relaton/bib/model/ext.rb +29 -0
  26. data/lib/relaton/bib/model/extent.rb +16 -0
  27. data/lib/relaton/bib/model/full_name_type.rb +64 -0
  28. data/lib/relaton/bib/model/fullname.rb +11 -0
  29. data/lib/relaton/bib/model/ics.rb +14 -0
  30. data/lib/relaton/bib/model/image.rb +28 -0
  31. data/lib/relaton/bib/model/item.rb +129 -0
  32. data/lib/relaton/bib/model/item_base.rb +19 -0
  33. data/lib/relaton/bib/model/keyword.rb +30 -0
  34. data/lib/relaton/bib/model/locality.rb +18 -0
  35. data/lib/relaton/bib/model/locality_stack.rb +14 -0
  36. data/lib/relaton/bib/model/localized_string.rb +57 -0
  37. data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
  38. data/lib/relaton/bib/model/logo.rb +12 -0
  39. data/lib/relaton/bib/model/medium.rb +22 -0
  40. data/lib/relaton/bib/model/note.rb +16 -0
  41. data/lib/relaton/bib/model/organization.rb +13 -0
  42. data/lib/relaton/bib/model/organization_type.rb +42 -0
  43. data/lib/relaton/bib/model/person.rb +36 -0
  44. data/lib/relaton/bib/model/phone.rb +14 -0
  45. data/lib/relaton/bib/model/place.rb +33 -0
  46. data/lib/relaton/bib/model/price.rb +14 -0
  47. data/lib/relaton/bib/model/relation.rb +43 -0
  48. data/lib/relaton/bib/model/series.rb +32 -0
  49. data/lib/relaton/bib/model/size.rb +23 -0
  50. data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
  51. data/lib/relaton/bib/model/status.rb +27 -0
  52. data/lib/relaton/bib/model/structured_identifier.rb +48 -0
  53. data/lib/relaton/bib/model/subdivision.rb +14 -0
  54. data/lib/relaton/bib/model/technical_committee.rb +14 -0
  55. data/lib/relaton/bib/model/title.rb +18 -0
  56. data/lib/relaton/bib/model/uri.rb +18 -0
  57. data/lib/relaton/bib/model/validity.rb +16 -0
  58. data/lib/relaton/bib/model/version.rb +14 -0
  59. data/lib/relaton/bib/model/workgroup.rb +20 -0
  60. data/lib/relaton/bib/parser/rfc_address.rb +60 -0
  61. data/lib/relaton/bib/parser/rfc_contacts.rb +35 -0
  62. data/lib/relaton/bib/parser/rfc_docidentifier.rb +70 -0
  63. data/lib/relaton/bib/parser/rfc_organization.rb +31 -0
  64. data/lib/relaton/bib/parser/rfc_person.rb +42 -0
  65. data/lib/relaton/bib/parser/rfc_reference.rb +143 -0
  66. data/lib/relaton/bib/parser/rfc_referencegroup.rb +45 -0
  67. data/lib/relaton/bib/parser/rfc_shared.rb +23 -0
  68. data/lib/relaton/bib/renderer/bibtex_builder.rb +348 -0
  69. data/lib/relaton/bib/renderer/rfc.rb +297 -0
  70. data/lib/relaton/bib/util.rb +18 -0
  71. data/lib/relaton/bib/version.rb +5 -0
  72. data/lib/{relaton_bib.rb → relaton/bib.rb} +47 -36
  73. data/lib/{relaton_bib → relaton}/bibtex_parser.rb +24 -27
  74. data/lib/{relaton_bib → relaton}/bibxml_parser.rb +43 -46
  75. data/lib/{relaton_bib → relaton}/hit.rb +3 -3
  76. data/lib/{relaton_bib → relaton}/hit_collection.rb +2 -2
  77. data/lib/{relaton_bib → relaton}/workers_pool.rb +1 -1
  78. data/lib/{relaton_bib → relaton}/xml_parser.rb +49 -51
  79. data/relaton-bib.gemspec +8 -8
  80. metadata +95 -74
  81. data/lib/relaton_bib/bib_item_locality.rb +0 -175
  82. data/lib/relaton_bib/biblio_note.rb +0 -72
  83. data/lib/relaton_bib/biblio_version.rb +0 -46
  84. data/lib/relaton_bib/bibliographic_date.rb +0 -119
  85. data/lib/relaton_bib/bibliographic_item.rb +0 -668
  86. data/lib/relaton_bib/bibliographic_size.rb +0 -103
  87. data/lib/relaton_bib/classification.rb +0 -40
  88. data/lib/relaton_bib/config.rb +0 -16
  89. data/lib/relaton_bib/contribution_info.rb +0 -117
  90. data/lib/relaton_bib/contributor.rb +0 -277
  91. data/lib/relaton_bib/copyright_association.rb +0 -79
  92. data/lib/relaton_bib/document_identifier.rb +0 -118
  93. data/lib/relaton_bib/document_relation.rb +0 -95
  94. data/lib/relaton_bib/document_relation_collection.rb +0 -57
  95. data/lib/relaton_bib/document_status.rb +0 -92
  96. data/lib/relaton_bib/document_type.rb +0 -52
  97. data/lib/relaton_bib/edition.rb +0 -55
  98. data/lib/relaton_bib/editorial_group.rb +0 -41
  99. data/lib/relaton_bib/extent.rb +0 -39
  100. data/lib/relaton_bib/forename.rb +0 -65
  101. data/lib/relaton_bib/formatted_ref.rb +0 -17
  102. data/lib/relaton_bib/formatted_string.rb +0 -133
  103. data/lib/relaton_bib/full_name.rb +0 -108
  104. data/lib/relaton_bib/hash_converter.rb +0 -568
  105. data/lib/relaton_bib/ics.rb +0 -42
  106. data/lib/relaton_bib/image.rb +0 -95
  107. data/lib/relaton_bib/localized_string.rb +0 -149
  108. data/lib/relaton_bib/medium.rb +0 -76
  109. data/lib/relaton_bib/organization.rb +0 -165
  110. data/lib/relaton_bib/person.rb +0 -129
  111. data/lib/relaton_bib/place.rb +0 -203
  112. data/lib/relaton_bib/renderer/bibtex_builder.rb +0 -312
  113. data/lib/relaton_bib/renderer/bibxml.rb +0 -296
  114. data/lib/relaton_bib/series.rb +0 -119
  115. data/lib/relaton_bib/structured_identifier.rb +0 -173
  116. data/lib/relaton_bib/technical_committee.rb +0 -34
  117. data/lib/relaton_bib/typed_title_string.rb +0 -191
  118. data/lib/relaton_bib/typed_uri.rb +0 -57
  119. data/lib/relaton_bib/util.rb +0 -16
  120. data/lib/relaton_bib/validity.rb +0 -52
  121. data/lib/relaton_bib/version.rb +0 -3
  122. data/lib/relaton_bib/workgroup.rb +0 -58
  123. /data/lib/{relaton_bib → relaton}/deep_dup.rb +0 -0
@@ -0,0 +1,168 @@
1
+ module Relaton
2
+ module Bib
3
+ # This class represents the data of a bibliographic item.
4
+ # It needed to keep data fot different types of representations (bibitem, bibdata ...).
5
+ # @TODO: remove this class when Lutaml Model will support transformation between different types of models.
6
+ class ItemData
7
+ attr_accessor :id, :type, :schema_version, :fetched, :formattedref,
8
+ :docidentifier, :docnumber, :date, :contributor, :edition,
9
+ :version, :note, :language, :locale, :script, :status,
10
+ :copyright, :series, :medium, :place, :price, :extent,
11
+ :size, :accesslocation, :license, :classification,
12
+ :keyword, :validity, :depiction, :ext # , :all_parts
13
+
14
+ attr_writer :title, :abstract, :source, :relation
15
+
16
+ def initialize(**args)
17
+ args.each do |k, v|
18
+ instance_variable_set("@#{k}", v) if respond_to?("#{k}=")
19
+ end
20
+ self.schema_version = schema
21
+ end
22
+
23
+ #
24
+ # Fetch schema version
25
+ #
26
+ # @return [String] schema version
27
+ #
28
+ def schema
29
+ @schema ||= Relaton.schema_versions["relaton-models"]
30
+ end
31
+
32
+ def to_relation_item
33
+ self.id = nil
34
+ self.schema_version = nil
35
+ self.fetched = nil
36
+ ext&.schema_version = nil
37
+ end
38
+
39
+ # remove title part components and abstract
40
+ def to_all_parts # rubocop:disable Metrics/MethodLength
41
+ me = deep_clone
42
+ me.relation ||= []
43
+ to_relation_item
44
+ me.relation << create_relation(type: "instanceOf", bibitem: self)
45
+ me.delete_title_part!
46
+ me.title_update_main
47
+ me.abstract = []
48
+ me.docidentifier.each(&:to_all_parts!)
49
+ me.ext_to_all_parts!
50
+ # me.all_parts = true
51
+ me
52
+ end
53
+
54
+ def to_most_recent_reference
55
+ me = deep_clone
56
+ to_relation_item
57
+ me.relation ||= []
58
+ me.relation << create_relation(type: "instanceOf", bibitem: self)
59
+ me.abstract = []
60
+ me.date = []
61
+ me.docidentifier.each(&:remove_date!)
62
+ me.ext_remove_date
63
+ me.create_id without_date: true
64
+ me
65
+ end
66
+
67
+ def create_id(without_date: false)
68
+ raise NotImplementedError, "`create_id` method not implemented in #{self.class}"
69
+ end
70
+
71
+ def title(lang = nil)
72
+ return @title if lang.nil?
73
+
74
+ @title.select { |t| t.language == lang.to_s }
75
+ end
76
+
77
+ def abstract(lang = nil)
78
+ return @abstract if lang.nil?
79
+
80
+ @abstract.select { |a| a.language == lang.to_s }
81
+ end
82
+
83
+ def source(src = nil)
84
+ return @source if src.nil?
85
+
86
+ @source.find { |s| s.type == src.to_s }&.content
87
+ end
88
+
89
+ def relation(type = nil)
90
+ return @relation if type.nil?
91
+
92
+ @relation&.select { |r| r.type == type.to_s }
93
+ end
94
+
95
+ def to_xml(bibdata: false, **opts)
96
+ add_notes opts[:note] do
97
+ bibdata ? Bibdata.to_xml(self) : Bibitem.to_xml(self)
98
+ end
99
+ end
100
+
101
+ def to_yaml(**opts)
102
+ add_notes opts[:note] do
103
+ Item.to_yaml(self)
104
+ end
105
+ end
106
+
107
+ def to_json(**opts)
108
+ add_notes opts[:note] do
109
+ Item.to_json(self)
110
+ end
111
+ end
112
+
113
+ def to_bibtex
114
+ Renderer::BibtexBuilder.build(self).to_s
115
+ end
116
+
117
+ def to_rfcxml
118
+ Renderer::Rfc.transform(self).to_xml
119
+ end
120
+
121
+ def deep_clone
122
+ Item.from_yaml Item.to_yaml(self)
123
+ end
124
+
125
+ def create_relation(**args)
126
+ Relation.new(**args)
127
+ end
128
+
129
+ def delete_title_part!
130
+ title&.delete_if { |t| t.type == "title-part" }
131
+ end
132
+
133
+ def title_update_main # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
134
+ language&.each do |lang|
135
+ ttl = title.select { |t| t.type != "main" && t.language == lang }
136
+ next if ttl.empty?
137
+
138
+ tm_lang = ttl.map(&:content).join " - "
139
+ title.detect { |t| t.type == "main" && t.language == lang }&.content = tm_lang
140
+ end
141
+ end
142
+
143
+ def ext_to_all_parts!
144
+ return unless ext
145
+
146
+ # some flavor modles have structuredidentifier as not an array
147
+ # so we need to make it an array use common method
148
+ Relaton.array(ext.structuredidentifier).each(&:to_all_parts!)
149
+ end
150
+
151
+ def ext_remove_date
152
+ return unless ext
153
+
154
+ Relaton.array(ext.structuredidentifier).each(&:remove_date!)
155
+ end
156
+
157
+ private
158
+
159
+ def add_notes(notes)
160
+ self.note ||= []
161
+ Relaton.array(notes).each { |nt| note << Bib::Note.new(**nt) }
162
+ result = yield
163
+ Relaton.array(notes).each { note.pop }
164
+ result
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,22 @@
1
+ module Relaton
2
+ module Bib
3
+ class Address < Lutaml::Model::Serializable
4
+ attribute :street, :string, collection: true, initialize_empty: true
5
+ attribute :city, :string
6
+ attribute :state, :string
7
+ attribute :country, :string
8
+ attribute :postcode, :string
9
+ attribute :formatted_address, :string, raw: true
10
+
11
+ xml do
12
+ root "address"
13
+ map_element "street", to: :street
14
+ map_element "city", to: :city
15
+ map_element "state", to: :state
16
+ map_element "country", to: :country
17
+ map_element "postcode", to: :postcode
18
+ map_element "formattedAddress", to: :formatted_address
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ module Relaton
2
+ module Bib
3
+ class Affiliation < Lutaml::Model::Serializable
4
+ attribute :name, LocalizedString
5
+ attribute :description, LocalizedMarkedUpString, collection: true, initialize_empty: true
6
+ attribute :organization, Organization
7
+
8
+ xml do
9
+ root "affiliation"
10
+ map_element "name", to: :name
11
+ map_element "description", to: :description
12
+ map_element "organization", to: :organization
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ module Relaton
2
+ 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.
20
+ class Bibdata < Item
21
+ include BibdataShared
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ module Relaton
2
+ 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
+
19
+ class Bibitem < Item
20
+ include BibitemShared
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ require_relative "address"
2
+ require_relative "phone"
3
+ require_relative "uri"
4
+
5
+ module Relaton
6
+ module Bib
7
+ module Contact
8
+ def self.included(base)
9
+ base.instance_eval do
10
+ attribute :address, Address, collection: true, initialize_empty: true
11
+ attribute :phone, Phone, collection: true, initialize_empty: true
12
+ attribute :email, :string, collection: true, initialize_empty: true
13
+ attribute :uri, Uri, collection: true, initialize_empty: true
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module Relaton
2
+ module Bib
3
+ class ContributionInfo < Lutaml::Model::Serializable
4
+ choice(min: 1, max: 1) do
5
+ attribute :person, Person
6
+ attribute :organization, Organization
7
+ end
8
+
9
+ xml do
10
+ no_root
11
+ map_element "person", to: :person
12
+ map_element "organization", to: :organization
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,71 @@
1
+ module Relaton
2
+ module Bib
3
+ class Contributor < Lutaml::Model::Serializable
4
+ class Role < Lutaml::Model::Serializable
5
+ attribute :type, :string, values: %w[
6
+ author performer publisher editor adapter translator distributor reazer
7
+ owner authorizer enabler subject
8
+ ]
9
+ attribute :description, LocalizedMarkedUpString, collection: true, initialize_empty: true
10
+
11
+ xml do
12
+ root "role"
13
+ map_attribute "type", to: :type
14
+ map_element "description", to: :description
15
+ end
16
+ end
17
+
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
26
+
27
+ xml do
28
+ root "contributor"
29
+
30
+ 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 }
34
+ 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
+ end
70
+ end
71
+ end
@@ -0,0 +1,27 @@
1
+ module Relaton
2
+ module Bib
3
+ class Copyright < Lutaml::Model::Serializable
4
+ attribute :from, :string
5
+ attribute :to, :string
6
+ attribute :owner, ContributionInfo, collection: true, initialize_empty: true
7
+ attribute :scope, :string
8
+
9
+ xml do
10
+ root "copyright"
11
+
12
+ map_element "from", to: :from
13
+ map_element "to", to: :to
14
+ map_element "owner", to: :owner # , with: { from: :owner_from_xml, to: :owner_to_xml }
15
+ map_element "scope", to: :scope
16
+ end
17
+
18
+ # def owner_from_xml(model, node)
19
+ # model.owner = ContributionInfo.from_xml node
20
+ # end
21
+
22
+ # def owner_to_xml(model, parent, _doc)
23
+ # model.owner.to_xml parent
24
+ # end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ module Relaton
2
+ module Bib
3
+ class Date < Lutaml::Model::Serializable
4
+ attribute :type, :string, values: %w[
5
+ published accessed created implemented obsoleted confirmed updated
6
+ corrected issued transmitted copied unchanged circulated adapted
7
+ vote-started vote-ended announced stable-until
8
+ ]
9
+ attribute :text, :string
10
+ choice(min: 1, max: 2) do
11
+ choice(min: 1, max: 2) do
12
+ attribute :from, :string
13
+ attribute :to, :string
14
+ end
15
+ # `on` is reserved word in YAML, so use `at` instead to avoid remapping key-value formats
16
+ attribute :at, :string
17
+ end
18
+
19
+ xml do
20
+ root "date"
21
+ map_attribute "type", to: :type
22
+ map_attribute "text", to: :text
23
+ map_element "from", to: :from
24
+ map_element "to", to: :to
25
+ map_element "on", to: :at
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+ module Relaton
2
+ module Bib
3
+ class Depiction < Lutaml::Model::Serializable
4
+ attribute :scope, :string
5
+ attribute :image, Image, collection: true, initialize_empty: true
6
+
7
+ xml do
8
+ root "depiction"
9
+ map_attribute "scope", to: :scope
10
+ map_element "image", to: :image
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ module Relaton
2
+ module Bib
3
+ class Docidentifier < LocalizedMarkedUpString
4
+ attribute :type, :string
5
+ attribute :scope, :string
6
+ attribute :primary, :boolean
7
+
8
+ xml do
9
+ map_attribute "type", to: :type
10
+ map_attribute "scope", to: :scope
11
+ map_attribute "primary", to: :primary
12
+ end
13
+
14
+ key_value do
15
+ map "type", to: :type
16
+ map "scope", to: :scope
17
+ map "primary", to: :primary
18
+ end
19
+
20
+ def remove_part!
21
+ raise NotImplementedError, "`remove_part!` method not implemented in #{self.class}"
22
+ end
23
+
24
+ def to_all_parts!
25
+ raise NotImplementedError, "`to_all_parts!` method not implemented in #{self.class}"
26
+ end
27
+
28
+ def remove_date!
29
+ raise NotImplementedError, "`remove_date!` method not implemented in #{self.class}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ module Relaton
2
+ module Bib
3
+ class Doctype < Lutaml::Model::Serializable
4
+ attribute :abbreviation, :string
5
+ attribute :content, :string
6
+
7
+ xml do
8
+ root "doctype"
9
+ map_attribute "abbreviation", to: :abbreviation
10
+ map_content to: :content
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Relaton
2
+ module Bib
3
+ class Edition < Lutaml::Model::Serializable
4
+ attribute :number, :string
5
+ attribute :content, :string
6
+
7
+ xml do
8
+ root "edition"
9
+ map_attribute "number", to: :number
10
+ map_content to: :content
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require_relative "workgroup"
2
+
3
+ module Relaton
4
+ module Bib
5
+ class EditorialGroup < Lutaml::Model::Serializable
6
+ attribute :technical_committee, WorkGroup, collection: true, initialize_empty: true
7
+
8
+ xml do
9
+ root "editorialgroup"
10
+ map_element "technical-committee", to: :technical_committee
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ require_relative "doctype"
2
+ require_relative "editorial_group"
3
+ require_relative "ics"
4
+ require_relative "structured_identifier"
5
+
6
+ module Relaton
7
+ module Bib
8
+ class Ext < Lutaml::Model::Serializable
9
+ attribute :schema_version, :string
10
+ attribute :doctype, Doctype
11
+ attribute :subdoctype, :string
12
+ attribute :flavor, :string
13
+ attribute :editorialgroup, EditorialGroup
14
+ attribute :ics, ICS, collection: true, initialize_empty: true
15
+ attribute :structuredidentifier, StructuredIdentifier, collection: true, initialize_empty: true
16
+
17
+ xml do
18
+ root "ext"
19
+ map_attribute "schema-version", to: :schema_version
20
+ map_element "doctype", to: :doctype
21
+ map_element "subdoctype", to: :subdoctype
22
+ map_element "flavor", to: :flavor
23
+ map_element "editorialgroup", to: :editorialgroup
24
+ map_element "ics", to: :ics
25
+ map_element "structuredidentifier", to: :structuredidentifier
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ module Relaton
2
+ module Bib
3
+ class Extent < Lutaml::Model::Serializable
4
+ choice(min: 1, max: 1) do
5
+ attribute :locality, Locality, collection: true, initialize_empty: true
6
+ attribute :locality_stack, LocalityStack, collection: true, initialize_empty: true
7
+ end
8
+
9
+ xml do
10
+ root "extent"
11
+ map_element "locality", to: :locality
12
+ map_element "localityStack", to: :locality_stack
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,64 @@
1
+ module Relaton
2
+ module Bib
3
+ module FullNameType
4
+ class Forename < LocalizedString
5
+ attribute :initial, :string
6
+
7
+ xml do
8
+ map_attribute "initial", to: :initial
9
+ end
10
+
11
+ key_value do
12
+ map "initial", to: :initial
13
+ end
14
+ end
15
+
16
+ def self.included(base) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
17
+ base.instance_eval do
18
+ attribute :abbreviation, LocalizedString
19
+ attribute :prefix, LocalizedString, collection: true, initialize_empty: true
20
+ attribute :forename, Forename, collection: true, initialize_empty: true
21
+ attribute :formatted_initials, LocalizedString
22
+ attribute :surname, LocalizedString
23
+ attribute :addition, LocalizedString, collection: true, initialize_empty: true
24
+ attribute :completename, LocalizedString
25
+ attribute :note, Note, collection: true, initialize_empty: true
26
+ attribute :variant, Variant, collection: true, initialize_empty: true
27
+
28
+ xml do
29
+ map_element "abbreviation", to: :abbreviation
30
+ map_element "prefix", to: :prefix
31
+ map_element "forename", to: :forename
32
+ map_element "formatted-initials", to: :formatted_initials
33
+ map_element "surname", to: :surname
34
+ map_element "addition", to: :addition
35
+ map_element "completename", to: :completename
36
+ map_element "note", to: :note
37
+ map_element "variant", to: :variant
38
+ end
39
+ end
40
+ end
41
+
42
+ # def content_from_xml(model, node)
43
+ # model.content = Content.of_xml node.instance_variable_get(:@node) || node
44
+ # end
45
+
46
+ # def content_to_xml(model, parent, _doc)
47
+ # model.content.add_to_xml parent
48
+ # end
49
+ end
50
+
51
+ module FullNameType
52
+ class Variant < Lutaml::Model::Serializable
53
+ include FullNameType
54
+
55
+ attribute :type, :string
56
+
57
+ xml do
58
+ root "variant"
59
+ map_attribute "type", to: :type
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,11 @@
1
+ module Relaton
2
+ module Bib
3
+ class FullName < Lutaml::Model::Serializable
4
+ include FullNameType
5
+
6
+ xml do
7
+ root "name"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Relaton
2
+ module Bib
3
+ class ICS < Lutaml::Model::Serializable
4
+ attribute :code, :string
5
+ attribute :text, :string
6
+
7
+ xml do
8
+ root "ics"
9
+ map_element "code", to: :code
10
+ map_element "text", to: :text
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ module Relaton
2
+ module Bib
3
+ class Image < Lutaml::Model::Serializable
4
+ attribute :id, :string
5
+ attribute :src, :string # anyURI
6
+ attribute :mimetype, :string
7
+ attribute :filename, :string
8
+ attribute :width, :string
9
+ attribute :height, :string
10
+ attribute :alt, :string
11
+ attribute :title, :string
12
+ attribute :longdesc, :string # anyURI
13
+
14
+ xml do
15
+ root "image"
16
+ map_attribute "id", to: :id
17
+ map_attribute "src", to: :src
18
+ map_attribute "mimetype", to: :mimetype
19
+ map_attribute "filename", to: :filename
20
+ map_attribute "width", to: :width
21
+ map_attribute "height", to: :height
22
+ map_attribute "alt", to: :alt
23
+ map_attribute "title", to: :title
24
+ map_attribute "longdesc", to: :longdesc
25
+ end
26
+ end
27
+ end
28
+ end