relaton-bib 1.4.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 +54 -0
- data/.github/workflows/rake.yml +15 -0
- data/.github/workflows/release.yml +24 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +3 -1
- data/CLAUDE.md +108 -0
- data/Gemfile +11 -0
- data/README.adoc +229 -314
- data/bin/console +1 -1
- data/docs/hash.adoc +132 -83
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
- data/lib/relaton/bib/converter/asciibib.rb +13 -0
- data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
- data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
- data/lib/relaton/bib/converter/bibtex.rb +23 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +386 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +308 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
- data/lib/relaton/bib/converter/bibxml.rb +51 -0
- data/lib/relaton/bib/hash_parser_v1.rb +767 -0
- data/lib/relaton/bib/item_data.rb +229 -0
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/address.rb +22 -0
- data/lib/relaton/bib/model/affiliation.rb +16 -0
- data/lib/relaton/bib/model/bibdata.rb +9 -0
- data/lib/relaton/bib/model/bibdata_shared.rb +10 -0
- data/lib/relaton/bib/model/bibitem.rb +9 -0
- data/lib/relaton/bib/model/bibitem_shared.rb +10 -0
- data/lib/relaton/bib/model/contact.rb +14 -0
- data/lib/relaton/bib/model/contribution_info.rb +16 -0
- data/lib/relaton/bib/model/contributor.rb +29 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +29 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +34 -0
- data/lib/relaton/bib/model/doctype.rb +14 -0
- data/lib/relaton/bib/model/edition.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +35 -0
- data/lib/relaton/bib/model/extent.rb +16 -0
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/full_name_type.rb +64 -0
- data/lib/relaton/bib/model/fullname.rb +11 -0
- data/lib/relaton/bib/model/ics.rb +49 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +44 -0
- data/lib/relaton/bib/model/item_base.rb +20 -0
- data/lib/relaton/bib/model/item_shared.rb +88 -0
- data/lib/relaton/bib/model/keyword.rb +30 -0
- data/lib/relaton/bib/model/locality.rb +18 -0
- data/lib/relaton/bib/model/locality_stack.rb +14 -0
- data/lib/relaton/bib/model/localized_string.rb +48 -0
- data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
- data/lib/relaton/bib/model/logo.rb +14 -0
- data/lib/relaton/bib/model/medium.rb +22 -0
- data/lib/relaton/bib/model/note.rb +16 -0
- data/lib/relaton/bib/model/organization.rb +11 -0
- data/lib/relaton/bib/model/organization_type.rb +40 -0
- data/lib/relaton/bib/model/person.rb +36 -0
- data/lib/relaton/bib/model/phone.rb +14 -0
- data/lib/relaton/bib/model/place.rb +33 -0
- data/lib/relaton/bib/model/price.rb +14 -0
- data/lib/relaton/bib/model/relation.rb +41 -0
- data/lib/relaton/bib/model/series.rb +32 -0
- data/lib/relaton/bib/model/size.rb +23 -0
- data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
- data/lib/relaton/bib/model/status.rb +27 -0
- data/lib/relaton/bib/model/structured_identifier.rb +48 -0
- data/lib/relaton/bib/model/subdivision.rb +16 -0
- data/lib/relaton/bib/model/title.rb +56 -0
- data/lib/relaton/bib/model/type/plain_date.rb +16 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/uri.rb +18 -0
- data/lib/relaton/bib/model/validity.rb +16 -0
- data/lib/relaton/bib/model/version.rb +43 -0
- data/lib/relaton/bib/model_autoload.rb +85 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/sanitizer.rb +74 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/version.rb +5 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +41 -0
- data/relaton-bib.gemspec +12 -16
- metadata +118 -129
- data/.github/workflows/macos.yml +0 -38
- data/.github/workflows/ubuntu.yml +0 -39
- data/.github/workflows/windows.yml +0 -41
- data/grammars/basicdoc.rng +0 -986
- data/grammars/biblio.rng +0 -1237
- data/grammars/isodoc.rng +0 -1613
- data/grammars/reqt.rng +0 -165
- data/lib/relaton_bib/bib_item_locality.rb +0 -107
- data/lib/relaton_bib/biblio_note.rb +0 -44
- data/lib/relaton_bib/biblio_version.rb +0 -49
- data/lib/relaton_bib/bibliographic_date.rb +0 -90
- data/lib/relaton_bib/bibliographic_item.rb +0 -726
- data/lib/relaton_bib/bibtex_parser.rb +0 -245
- data/lib/relaton_bib/classification.rb +0 -40
- data/lib/relaton_bib/contribution_info.rb +0 -109
- data/lib/relaton_bib/contributor.rb +0 -215
- data/lib/relaton_bib/copyright_association.rb +0 -77
- data/lib/relaton_bib/deep_dup.rb +0 -30
- data/lib/relaton_bib/document_identifier.rb +0 -95
- data/lib/relaton_bib/document_relation.rb +0 -94
- data/lib/relaton_bib/document_relation_collection.rb +0 -46
- data/lib/relaton_bib/document_status.rb +0 -93
- data/lib/relaton_bib/editorial_group.rb +0 -41
- data/lib/relaton_bib/formatted_ref.rb +0 -17
- data/lib/relaton_bib/formatted_string.rb +0 -55
- data/lib/relaton_bib/hash_converter.rb +0 -497
- data/lib/relaton_bib/hit.rb +0 -46
- data/lib/relaton_bib/hit_collection.rb +0 -73
- data/lib/relaton_bib/ics.rb +0 -37
- data/lib/relaton_bib/localized_string.rb +0 -93
- data/lib/relaton_bib/medium.rb +0 -44
- data/lib/relaton_bib/organization.rb +0 -135
- data/lib/relaton_bib/person.rb +0 -206
- data/lib/relaton_bib/place.rb +0 -49
- data/lib/relaton_bib/series.rb +0 -134
- data/lib/relaton_bib/structured_identifier.rb +0 -171
- data/lib/relaton_bib/technical_committee.rb +0 -36
- data/lib/relaton_bib/typed_title_string.rb +0 -96
- data/lib/relaton_bib/typed_uri.rb +0 -47
- data/lib/relaton_bib/validity.rb +0 -52
- data/lib/relaton_bib/version.rb +0 -3
- data/lib/relaton_bib/workers_pool.rb +0 -43
- data/lib/relaton_bib/workgroup.rb +0 -46
- data/lib/relaton_bib/xml_parser.rb +0 -463
- data/lib/relaton_bib.rb +0 -44
|
@@ -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,49 @@
|
|
|
1
|
+
require "isoics"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Bib
|
|
5
|
+
class ICS < Lutaml::Model::Serializable
|
|
6
|
+
attribute :code, :string
|
|
7
|
+
attribute :text, :string
|
|
8
|
+
|
|
9
|
+
xml do
|
|
10
|
+
root "ics"
|
|
11
|
+
map_element "code", to: :code
|
|
12
|
+
map_element "text", to: :text
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Returns the explicit text if set, else the Isoics description for
|
|
16
|
+
# `code`. Kept for consumers that read `.text` directly.
|
|
17
|
+
def text
|
|
18
|
+
return @text if @text.is_a?(String) && !@text.empty?
|
|
19
|
+
|
|
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
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
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
|
|
@@ -0,0 +1,44 @@
|
|
|
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.
|
|
4
|
+
module Relaton
|
|
5
|
+
module Bib
|
|
6
|
+
# Item class repesents bibliographic item metadata.
|
|
7
|
+
# Used for YAML/JSON parsing and as the XML dispatch entry point.
|
|
8
|
+
class Item < Lutaml::Model::Serializable
|
|
9
|
+
include NamespaceHelper
|
|
10
|
+
|
|
11
|
+
attr_accessor :type # in some cases mehod type is unavailable
|
|
12
|
+
|
|
13
|
+
model ItemData
|
|
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
|
+
|
|
26
|
+
attribute :id, :string
|
|
27
|
+
attribute :schema_version, :string, method: :get_schema_version
|
|
28
|
+
attribute :fetched, PlainDate
|
|
29
|
+
instance_exec(&ItemShared::ATTRIBUTES)
|
|
30
|
+
attribute :ext, Ext
|
|
31
|
+
|
|
32
|
+
xml do
|
|
33
|
+
map_attribute "id", to: :id
|
|
34
|
+
map_attribute "type", to: :type
|
|
35
|
+
map_attribute "schema-version", to: :schema_version, render_default: true
|
|
36
|
+
map_element "fetched", to: :fetched
|
|
37
|
+
instance_exec(&ItemShared::XML_BODY)
|
|
38
|
+
map_element "ext", to: :ext
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def get_schema_version = Relaton.schema_versions["relaton-models"]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
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
|
|
9
|
+
|
|
10
|
+
model ItemData
|
|
11
|
+
|
|
12
|
+
instance_exec(&ItemShared::ATTRIBUTES)
|
|
13
|
+
|
|
14
|
+
xml do
|
|
15
|
+
map_attribute "type", to: :type
|
|
16
|
+
instance_exec(&ItemShared::XML_BODY)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
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
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class Keyword < Lutaml::Model::Serializable
|
|
4
|
+
class Vocabid < Lutaml::Model::Serializable
|
|
5
|
+
attribute :type, :string
|
|
6
|
+
attribute :uri, :string
|
|
7
|
+
attribute :code, :string
|
|
8
|
+
attribute :term, :string
|
|
9
|
+
|
|
10
|
+
xml do
|
|
11
|
+
map_attribute "type", to: :type
|
|
12
|
+
map_attribute "uri", to: :uri
|
|
13
|
+
map_element "code", to: :code
|
|
14
|
+
map_element "term", to: :term
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attribute :vocab, LocalizedString
|
|
19
|
+
attribute :taxon, LocalizedString, collection: true, initialize_empty: true
|
|
20
|
+
attribute :vocabid, Vocabid, collection: true, initialize_empty: true
|
|
21
|
+
|
|
22
|
+
xml do
|
|
23
|
+
root "keyword"
|
|
24
|
+
map_element "vocab", to: :vocab
|
|
25
|
+
map_element "taxon", to: :taxon
|
|
26
|
+
map_element "vocabid", to: :vocabid
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class Locality < Lutaml::Model::Serializable
|
|
4
|
+
attribute :type, :string, pattern: %r{
|
|
5
|
+
section|clause|part|paragraph|chapter|page|title|line|whole|table|annex|
|
|
6
|
+
figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+
|
|
7
|
+
}x
|
|
8
|
+
attribute :reference_from, :string
|
|
9
|
+
attribute :reference_to, :string
|
|
10
|
+
|
|
11
|
+
xml do
|
|
12
|
+
map_attribute "type", to: :type
|
|
13
|
+
map_element "referenceFrom", to: :reference_from
|
|
14
|
+
map_element "referenceTo", to: :reference_to
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class LocalityStack < Lutaml::Model::Serializable
|
|
4
|
+
attribute :connective, :string, values: %w[and or from to]
|
|
5
|
+
attribute :locality, Locality, collection: true, initialize_empty: true
|
|
6
|
+
|
|
7
|
+
xml do
|
|
8
|
+
root "localityStack"
|
|
9
|
+
map_attribute "connective", to: :connective
|
|
10
|
+
map_element "locality", to: :locality
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class LocalizedString < LocalizedStringAttrs
|
|
4
|
+
attribute :content, :string
|
|
5
|
+
|
|
6
|
+
xml do
|
|
7
|
+
map_content to: :content
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
key_value do
|
|
11
|
+
map "content", to: :content
|
|
12
|
+
map "language", to: :language
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class TypedLocalizedString < LocalizedString
|
|
17
|
+
attribute :type, :string
|
|
18
|
+
|
|
19
|
+
xml do
|
|
20
|
+
map_attribute "type", to: :type
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
key_value do
|
|
24
|
+
map "type", to: :type
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class LocalizedMarkedUpString < LocalizedStringAttrs
|
|
29
|
+
module ContentSanitization
|
|
30
|
+
def content=(value)
|
|
31
|
+
super(Relaton::Bib::Sanitizer.sanitize(value))
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
attribute :content, :string, raw: true
|
|
36
|
+
prepend ContentSanitization
|
|
37
|
+
|
|
38
|
+
xml do
|
|
39
|
+
map_all to: :content
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
key_value do
|
|
43
|
+
map "content", to: :content
|
|
44
|
+
map "language", to: :language
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class LocalizedStringAttrs < Lutaml::Model::Serializable
|
|
4
|
+
attribute :language, :string
|
|
5
|
+
attribute :locale, :string
|
|
6
|
+
attribute :script, :string
|
|
7
|
+
|
|
8
|
+
# def self.inherited(base)
|
|
9
|
+
# super
|
|
10
|
+
# base.class_eval do
|
|
11
|
+
xml do
|
|
12
|
+
map_attribute "language", to: :language
|
|
13
|
+
map_attribute "locale", to: :locale
|
|
14
|
+
map_attribute "script", to: :script
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
key_value do
|
|
18
|
+
map "language", to: :language
|
|
19
|
+
map "locale", to: :locale
|
|
20
|
+
map "script", to: :script
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class Medium < Lutaml::Model::Serializable
|
|
4
|
+
attribute :content, :string
|
|
5
|
+
attribute :genre, :string
|
|
6
|
+
attribute :form, :string
|
|
7
|
+
attribute :carrier, :string
|
|
8
|
+
attribute :size, :string
|
|
9
|
+
attribute :scale, :string
|
|
10
|
+
|
|
11
|
+
xml do
|
|
12
|
+
root "medium"
|
|
13
|
+
map_element "content", to: :content
|
|
14
|
+
map_element "genre", to: :genre
|
|
15
|
+
map_element "form", to: :form
|
|
16
|
+
map_element "carrier", to: :carrier
|
|
17
|
+
map_element "size", to: :size
|
|
18
|
+
map_element "scale", to: :scale
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
module OrganizationType
|
|
4
|
+
class Identifier < Lutaml::Model::Serializable
|
|
5
|
+
attribute :type, :string
|
|
6
|
+
attribute :content, :string
|
|
7
|
+
|
|
8
|
+
xml do
|
|
9
|
+
root "identifier"
|
|
10
|
+
map_attribute "type", to: :type
|
|
11
|
+
map_content to: :content
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.included(base) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
16
|
+
base.instance_eval do
|
|
17
|
+
include Contact
|
|
18
|
+
|
|
19
|
+
attribute :name, TypedLocalizedString, collection: true, initialize_empty: true
|
|
20
|
+
attribute :subdivision, Subdivision, collection: true, initialize_empty: true
|
|
21
|
+
attribute :abbreviation, LocalizedString
|
|
22
|
+
attribute :identifier, Identifier, collection: true, initialize_empty: true
|
|
23
|
+
attribute :logo, Logo, collection: true, initialize_empty: true
|
|
24
|
+
|
|
25
|
+
xml do
|
|
26
|
+
map_element "name", to: :name
|
|
27
|
+
map_element "subdivision", to: :subdivision
|
|
28
|
+
map_element "abbreviation", to: :abbreviation
|
|
29
|
+
map_element "identifier", to: :identifier
|
|
30
|
+
map_element "address", to: :address
|
|
31
|
+
map_element "phone", to: :phone
|
|
32
|
+
map_element "email", to: :email
|
|
33
|
+
map_element "uri", to: :uri
|
|
34
|
+
map_element "logo", to: :logo
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class Person < Lutaml::Model::Serializable
|
|
4
|
+
class Identifier < Lutaml::Model::Serializable
|
|
5
|
+
attribute :type, :string
|
|
6
|
+
attribute :content, :string
|
|
7
|
+
|
|
8
|
+
xml do
|
|
9
|
+
root "identifier"
|
|
10
|
+
map_attribute "type", to: :type
|
|
11
|
+
map_content to: :content
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
include Contact
|
|
16
|
+
|
|
17
|
+
attribute :name, FullName
|
|
18
|
+
attribute :credential, :string, collection: true, initialize_empty: true
|
|
19
|
+
attribute :affiliation, Affiliation, collection: true, initialize_empty: true
|
|
20
|
+
attribute :identifier, Identifier, collection: true, initialize_empty: true
|
|
21
|
+
|
|
22
|
+
xml do
|
|
23
|
+
root "person"
|
|
24
|
+
|
|
25
|
+
map_element "name", to: :name
|
|
26
|
+
map_element "credential", to: :credential
|
|
27
|
+
map_element "affiliation", to: :affiliation
|
|
28
|
+
map_element "identifier", to: :identifier
|
|
29
|
+
map_element "address", to: :address
|
|
30
|
+
map_element "phone", to: :phone
|
|
31
|
+
map_element "email", to: :email
|
|
32
|
+
map_element "uri", to: :uri
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class Place < Lutaml::Model::Serializable
|
|
4
|
+
class RegionType < Lutaml::Model::Serializable
|
|
5
|
+
attribute :iso, :string
|
|
6
|
+
attribute :recommended, :boolean
|
|
7
|
+
attribute :content, :string
|
|
8
|
+
|
|
9
|
+
xml do
|
|
10
|
+
root "region"
|
|
11
|
+
map_attribute "iso", to: :iso
|
|
12
|
+
map_attribute "recommended", to: :recommended
|
|
13
|
+
map_content to: :content
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
attribute :city, :string
|
|
18
|
+
attribute :region, RegionType, collection: true, initialize_empty: true
|
|
19
|
+
attribute :country, RegionType, collection: true, initialize_empty: true
|
|
20
|
+
attribute :formatted_place, :string
|
|
21
|
+
attribute :uri, Uri
|
|
22
|
+
|
|
23
|
+
xml do
|
|
24
|
+
root "place"
|
|
25
|
+
map_element "city", to: :city
|
|
26
|
+
map_element "region", to: :region
|
|
27
|
+
map_element "country", to: :country
|
|
28
|
+
map_element "formattedPlace", to: :formatted_place
|
|
29
|
+
map_element "uri", to: :uri
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
class Price < Lutaml::Model::Serializable
|
|
4
|
+
attribute :currency, :string
|
|
5
|
+
attribute :content, :string
|
|
6
|
+
|
|
7
|
+
xml do
|
|
8
|
+
root "price"
|
|
9
|
+
map_attribute "currency", to: :currency
|
|
10
|
+
map_content to: :content
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|