relaton-bib 2.0.0 → 2.1.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 +4 -4
- data/.github/workflows/integration-tests.yml +1 -1
- data/.github/workflows/rake.yml +1 -1
- data/CLAUDE.md +12 -0
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +2 -2
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +5 -2
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +7 -4
- data/lib/relaton/bib/hash_parser_v1.rb +17 -4
- data/lib/relaton/bib/model/bibdata.rb +2 -17
- data/lib/relaton/bib/model/bibdata_shared.rb +10 -0
- data/lib/relaton/bib/model/bibitem.rb +2 -16
- data/lib/relaton/bib/model/bibitem_shared.rb +10 -0
- data/lib/relaton/bib/model/contact.rb +0 -4
- data/lib/relaton/bib/model/contributor.rb +2 -44
- data/lib/relaton/bib/model/date.rb +0 -2
- data/lib/relaton/bib/model/docidentifier.rb +1 -0
- data/lib/relaton/bib/model/ext.rb +15 -6
- data/lib/relaton/bib/model/ics.rb +29 -3
- data/lib/relaton/bib/model/item.rb +24 -117
- data/lib/relaton/bib/model/item_base.rb +12 -19
- data/lib/relaton/bib/model/item_shared.rb +88 -0
- data/lib/relaton/bib/model/localized_string.rb +11 -20
- data/lib/relaton/bib/model/organization.rb +0 -2
- data/lib/relaton/bib/model/organization_type.rb +0 -2
- data/lib/relaton/bib/model/relation.rb +1 -3
- data/lib/relaton/bib/model/series.rb +0 -2
- data/lib/relaton/bib/model/type/plain_date.rb +16 -0
- data/lib/relaton/bib/model/version.rb +30 -1
- data/lib/relaton/bib/model_autoload.rb +85 -0
- data/lib/relaton/bib/sanitizer.rb +74 -0
- data/lib/relaton/bib/version.rb +1 -1
- data/{grammars → lib/relaton/bib}/versions.json +1 -1
- data/lib/relaton/bib.rb +5 -9
- data/relaton-bib.gemspec +2 -2
- metadata +17 -12
- data/grammars/basicdoc.rng +0 -2140
- data/grammars/biblio-compile.rng +0 -11
- data/grammars/biblio-standoc.rng +0 -268
- data/grammars/biblio.rng +0 -2129
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15d36c3ed1e4ae0042f96a06a6320dccbe089a87a691b77b8ad14e276217bd22
|
|
4
|
+
data.tar.gz: d6db31f185b72668da0c289bc462a62d1cfd1b9dda542f37b9dee7257d5282b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 304fcb5b02e2c019d532164228acede4ed81c210eafededbbdd9446ac94fcd32d142be5be7689db09bc17b7aa3e6cfb333b892220ba36e64fcccc2bdda2df29c
|
|
7
|
+
data.tar.gz: 390cf8b808ab85b099d573b4bea833d265a2326d81c00936e5cebe6ae79c9243991843d44a46d3d24e403137f1ec27b433acc532c51f99a0d5e91d0ed66d6744
|
data/.github/workflows/rake.yml
CHANGED
data/CLAUDE.md
CHANGED
|
@@ -37,6 +37,18 @@ bin/console
|
|
|
37
37
|
|
|
38
38
|
The codebase uses [lutaml-model](https://github.com/lutaml/lutaml-model) for serialization. Each model class in `lib/relaton/bib/model/` inherits from `Lutaml::Model::Serializable` and declares attributes with XML/YAML/JSON mappings.
|
|
39
39
|
|
|
40
|
+
### Constant loading (autoload)
|
|
41
|
+
|
|
42
|
+
Model and converter constants are wired via Ruby `autoload` from a central manifest,
|
|
43
|
+
[lib/relaton/bib/model_autoload.rb](lib/relaton/bib/model_autoload.rb). This makes load order
|
|
44
|
+
irrelevant and avoids circular requires between mutually-referencing classes (e.g. `OrganizationType`
|
|
45
|
+
↔ `Subdivision`). **When adding a new model class, add an `autoload` entry to the manifest** rather
|
|
46
|
+
than a `require_relative` in a sibling file. The manifest also eagerly loads `lutaml/model`/`lutaml/xml`
|
|
47
|
+
and runs the `Lutaml::Model::Config.configure` block so the XML adapter is set regardless of which
|
|
48
|
+
class is referenced first. Exceptions that keep `require_relative`: files that only *reopen* an
|
|
49
|
+
already-defined module to add methods (the converter method-partials under
|
|
50
|
+
`lib/relaton/bib/converter/*/`), which `autoload` cannot express.
|
|
51
|
+
|
|
40
52
|
### Core Classes
|
|
41
53
|
|
|
42
54
|
**`Relaton::Bib::Item`** ([lib/relaton/bib/model/item.rb](lib/relaton/bib/model/item.rb)) - The main serialization class defining all bibliographic attributes and their XML mappings. Uses `ItemData` as its underlying model.
|
|
@@ -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
|
|
127
|
-
out << "#{pref}version.
|
|
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
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "cgi"
|
|
2
|
+
|
|
1
3
|
module Relaton
|
|
2
4
|
module Bib
|
|
3
5
|
module Converter
|
|
@@ -138,7 +140,8 @@ module Relaton
|
|
|
138
140
|
return [] unless @reference.front.abstract&.t
|
|
139
141
|
|
|
140
142
|
@reference.front.abstract.t.map do |t|
|
|
141
|
-
|
|
143
|
+
text = CGI.escapeHTML(t.content.join.strip)
|
|
144
|
+
Abstract.new(content: "<p>#{text}</p>", language: "en", script: "Latn")
|
|
142
145
|
end
|
|
143
146
|
end
|
|
144
147
|
|
|
@@ -218,7 +221,7 @@ module Relaton
|
|
|
218
221
|
org = author.organization
|
|
219
222
|
return if org.nil? || org.content.empty?
|
|
220
223
|
|
|
221
|
-
name = ORGNAMES[org.content] || org.content
|
|
224
|
+
name = ORGNAMES[org.content.join] || org.content.join
|
|
222
225
|
orgname = TypedLocalizedString.new(content: name, language: "en")
|
|
223
226
|
abbrev = LocalizedString.new(content: org.abbrev, language: "en") if org.abbrev
|
|
224
227
|
Organization.new(
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "cgi"
|
|
2
|
+
|
|
1
3
|
module Relaton
|
|
2
4
|
module Bib
|
|
3
5
|
module Converter
|
|
@@ -120,7 +122,7 @@ module Relaton
|
|
|
120
122
|
abbrev = org.abbreviation&.content
|
|
121
123
|
orgname = resolve_orgname(org, abbrev)
|
|
122
124
|
Rfcxml::V3::Organization.new(
|
|
123
|
-
content: orgname, abbrev: abbrev,
|
|
125
|
+
content: [orgname], abbrev: abbrev,
|
|
124
126
|
)
|
|
125
127
|
end
|
|
126
128
|
|
|
@@ -282,9 +284,10 @@ module Relaton
|
|
|
282
284
|
return unless @item.abstract.any?
|
|
283
285
|
|
|
284
286
|
content = @item.abstract[0].content
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
)
|
|
287
|
+
paragraphs = content.scan(%r{<p>(.*?)</p>}m).flatten
|
|
288
|
+
paragraphs = [content] if paragraphs.empty?
|
|
289
|
+
ts = paragraphs.map { |p| Rfcxml::V3::Text.new(content: CGI.unescapeHTML(p)) }
|
|
290
|
+
Rfcxml::V3::Abstract.new(t: ts)
|
|
288
291
|
end
|
|
289
292
|
|
|
290
293
|
FORMAT_TYPES = %w[TXT HTML PDF XML DOC].freeze
|
|
@@ -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
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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,8 @@
|
|
|
1
1
|
module Relaton
|
|
2
2
|
module Bib
|
|
3
|
-
|
|
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.
|
|
3
|
+
# Bibliographic item serialized as <bibdata>. Has ext, no id.
|
|
20
4
|
class Bibdata < Item
|
|
5
|
+
model ItemData
|
|
21
6
|
include BibdataShared
|
|
22
7
|
end
|
|
23
8
|
end
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
module Relaton
|
|
2
2
|
module Bib
|
|
3
|
-
|
|
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
|
-
|
|
3
|
+
# Bibliographic item serialized as <bibitem>. Has id, no ext.
|
|
19
4
|
class Bibitem < Item
|
|
5
|
+
model ItemData
|
|
20
6
|
include BibitemShared
|
|
21
7
|
end
|
|
22
8
|
end
|
|
@@ -16,56 +16,14 @@ module Relaton
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
attribute :role, Role, collection: true, initialize_empty: true
|
|
19
|
-
|
|
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
|
-
|
|
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
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
require_relative "doctype"
|
|
2
|
-
require_relative "ics"
|
|
3
|
-
require_relative "structured_identifier"
|
|
4
|
-
|
|
5
1
|
module Relaton
|
|
6
2
|
module Bib
|
|
7
3
|
class Ext < Lutaml::Model::Serializable
|
|
8
|
-
attribute :schema_version, :string
|
|
4
|
+
attribute :schema_version, :string, method: :get_schema_version
|
|
9
5
|
attribute :doctype, Doctype
|
|
10
6
|
attribute :subdoctype, :string
|
|
11
7
|
attribute :flavor, :string
|
|
@@ -14,13 +10,26 @@ module Relaton
|
|
|
14
10
|
|
|
15
11
|
xml do
|
|
16
12
|
root "ext"
|
|
17
|
-
map_attribute "schema-version", to: :schema_version
|
|
13
|
+
map_attribute "schema-version", to: :schema_version, render_default: true
|
|
18
14
|
map_element "doctype", to: :doctype
|
|
19
15
|
map_element "subdoctype", to: :subdoctype
|
|
20
16
|
map_element "flavor", to: :flavor
|
|
21
17
|
map_element "ics", to: :ics
|
|
22
18
|
map_element "structuredidentifier", to: :structuredidentifier
|
|
23
19
|
end
|
|
20
|
+
|
|
21
|
+
key_value do
|
|
22
|
+
map_element "schema_version", to: :schema_version, render_default: true
|
|
23
|
+
map_element "doctype", to: :doctype
|
|
24
|
+
map_element "subdoctype", to: :subdoctype
|
|
25
|
+
map_element "flavor", to: :flavor
|
|
26
|
+
map_element "ics", to: :ics
|
|
27
|
+
map_element "structuredidentifier", to: :structuredidentifier
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Base returns nil so direct use omits schema-version. Subclasses in
|
|
31
|
+
# downstream relaton gems override to return their own version.
|
|
32
|
+
def get_schema_version = nil
|
|
24
33
|
end
|
|
25
34
|
end
|
|
26
35
|
end
|
|
@@ -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
|
-
|
|
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,137 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require_relative "localized_string"
|
|
5
|
-
require_relative "formattedref"
|
|
6
|
-
require_relative "abstract"
|
|
7
|
-
require_relative "date"
|
|
8
|
-
require_relative "locality"
|
|
9
|
-
require_relative "locality_stack"
|
|
10
|
-
require_relative "image"
|
|
11
|
-
require_relative "title"
|
|
12
|
-
require_relative "docidentifier"
|
|
13
|
-
require_relative "note"
|
|
14
|
-
require_relative "full_name_type"
|
|
15
|
-
require_relative "fullname"
|
|
16
|
-
require_relative "contact"
|
|
17
|
-
require_relative "logo"
|
|
18
|
-
require_relative "organization"
|
|
19
|
-
require_relative "affiliation"
|
|
20
|
-
require_relative "person"
|
|
21
|
-
require_relative "contribution_info"
|
|
22
|
-
require_relative "contributor"
|
|
23
|
-
require_relative "edition"
|
|
24
|
-
require_relative "version"
|
|
25
|
-
require_relative "status"
|
|
26
|
-
require_relative "copyright"
|
|
27
|
-
require_relative "place"
|
|
28
|
-
require_relative "series"
|
|
29
|
-
require_relative "medium"
|
|
30
|
-
require_relative "uri"
|
|
31
|
-
require_relative "price"
|
|
32
|
-
require_relative "extent"
|
|
33
|
-
require_relative "size"
|
|
34
|
-
require_relative "keyword"
|
|
35
|
-
require_relative "validity"
|
|
36
|
-
require_relative "depiction"
|
|
37
|
-
require_relative "source_locality_stack"
|
|
38
|
-
require_relative "ext"
|
|
39
|
-
|
|
40
|
-
Lutaml::Model::Config.configure do |config|
|
|
41
|
-
config.xml_adapter = Lutaml::Model::Xml::NokogiriAdapter
|
|
42
|
-
end
|
|
43
|
-
|
|
1
|
+
# Model classes are wired via autoload (see model_autoload.rb); the lutaml
|
|
2
|
+
# requires and XML adapter configuration live there so they run eagerly,
|
|
3
|
+
# independent of which model class is referenced first.
|
|
44
4
|
module Relaton
|
|
45
5
|
module Bib
|
|
46
|
-
class Relation < Lutaml::Model::Serializable
|
|
47
|
-
end
|
|
48
|
-
|
|
49
6
|
# Item class repesents bibliographic item metadata.
|
|
7
|
+
# Used for YAML/JSON parsing and as the XML dispatch entry point.
|
|
50
8
|
class Item < Lutaml::Model::Serializable
|
|
9
|
+
include NamespaceHelper
|
|
10
|
+
|
|
51
11
|
attr_accessor :type # in some cases mehod type is unavailable
|
|
52
12
|
|
|
53
13
|
model ItemData
|
|
54
14
|
|
|
15
|
+
def self.from_xml(xml, options = {})
|
|
16
|
+
return super unless self == namespace::Item
|
|
17
|
+
|
|
18
|
+
# lutaml-model has no built-in dispatch on root element name
|
|
19
|
+
# (polymorphic_map only works on attribute discriminators), so we
|
|
20
|
+
# peek at the root tag with Nokogiri and forward to the right class.
|
|
21
|
+
root_name = Nokogiri::XML(xml.to_s).root&.name
|
|
22
|
+
klass = root_name == "bibdata" ? namespace::Bibdata : namespace::Bibitem
|
|
23
|
+
klass.from_xml(xml, options)
|
|
24
|
+
end
|
|
25
|
+
|
|
55
26
|
attribute :id, :string
|
|
56
|
-
attribute :
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
27
|
+
attribute :schema_version, :string, method: :get_schema_version
|
|
28
|
+
attribute :fetched, PlainDate
|
|
29
|
+
instance_exec(&ItemShared::ATTRIBUTES)
|
|
93
30
|
attribute :ext, Ext
|
|
94
31
|
|
|
95
|
-
xml do
|
|
32
|
+
xml do
|
|
96
33
|
map_attribute "id", to: :id
|
|
97
34
|
map_attribute "type", to: :type
|
|
98
|
-
map_attribute "schema-version", to: :schema_version
|
|
35
|
+
map_attribute "schema-version", to: :schema_version, render_default: true
|
|
99
36
|
map_element "fetched", to: :fetched
|
|
100
|
-
|
|
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
|
|
37
|
+
instance_exec(&ItemShared::XML_BODY)
|
|
129
38
|
map_element "ext", to: :ext
|
|
130
39
|
end
|
|
131
40
|
|
|
132
|
-
def get_schema_version
|
|
133
|
-
Relaton.schema_versions["relaton-models"]
|
|
134
|
-
end
|
|
41
|
+
def get_schema_version = Relaton.schema_versions["relaton-models"]
|
|
135
42
|
end
|
|
136
43
|
end
|
|
137
44
|
end
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
module Relaton
|
|
2
2
|
module Bib
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|