relaton-bib 1.20.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.rubocop.yml +1 -1
- data/CLAUDE.md +96 -0
- data/Gemfile +1 -4
- data/README.adoc +195 -154
- data/bin/console +1 -1
- data/grammars/basicdoc.rng +1572 -671
- data/grammars/biblio-standoc.rng +107 -46
- data/grammars/biblio.rng +1012 -377
- data/grammars/versions.json +26 -26
- 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 +383 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +305 -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 +754 -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 +24 -0
- data/lib/relaton/bib/model/bibitem.rb +23 -0
- data/lib/relaton/bib/model/contact.rb +18 -0
- data/lib/relaton/bib/model/contribution_info.rb +16 -0
- data/lib/relaton/bib/model/contributor.rb +71 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +31 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +33 -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 +26 -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 +23 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +137 -0
- data/lib/relaton/bib/model/item_base.rb +27 -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 +57 -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 +13 -0
- data/lib/relaton/bib/model/organization_type.rb +42 -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 +43 -0
- data/lib/relaton/bib/model/series.rb +34 -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/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 +14 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/version.rb +5 -0
- data/lib/relaton/bib.rb +45 -0
- data/relaton-bib.gemspec +11 -8
- metadata +125 -67
- data/lib/relaton_bib/bib_item_locality.rb +0 -175
- data/lib/relaton_bib/biblio_note.rb +0 -72
- data/lib/relaton_bib/biblio_version.rb +0 -46
- data/lib/relaton_bib/bibliographic_date.rb +0 -119
- data/lib/relaton_bib/bibliographic_item.rb +0 -668
- data/lib/relaton_bib/bibliographic_size.rb +0 -103
- data/lib/relaton_bib/bibtex_parser.rb +0 -246
- data/lib/relaton_bib/bibxml_parser.rb +0 -422
- data/lib/relaton_bib/classification.rb +0 -40
- data/lib/relaton_bib/config.rb +0 -16
- data/lib/relaton_bib/contribution_info.rb +0 -117
- data/lib/relaton_bib/contributor.rb +0 -277
- data/lib/relaton_bib/copyright_association.rb +0 -79
- data/lib/relaton_bib/deep_dup.rb +0 -30
- data/lib/relaton_bib/document_identifier.rb +0 -118
- data/lib/relaton_bib/document_relation.rb +0 -95
- data/lib/relaton_bib/document_relation_collection.rb +0 -57
- data/lib/relaton_bib/document_status.rb +0 -92
- data/lib/relaton_bib/document_type.rb +0 -52
- data/lib/relaton_bib/edition.rb +0 -55
- data/lib/relaton_bib/editorial_group.rb +0 -41
- data/lib/relaton_bib/extent.rb +0 -39
- data/lib/relaton_bib/forename.rb +0 -65
- data/lib/relaton_bib/formatted_ref.rb +0 -17
- data/lib/relaton_bib/formatted_string.rb +0 -133
- data/lib/relaton_bib/full_name.rb +0 -108
- data/lib/relaton_bib/hash_converter.rb +0 -568
- data/lib/relaton_bib/hit.rb +0 -52
- data/lib/relaton_bib/hit_collection.rb +0 -105
- data/lib/relaton_bib/ics.rb +0 -42
- data/lib/relaton_bib/image.rb +0 -95
- data/lib/relaton_bib/localized_string.rb +0 -149
- data/lib/relaton_bib/medium.rb +0 -76
- data/lib/relaton_bib/organization.rb +0 -165
- data/lib/relaton_bib/person.rb +0 -129
- data/lib/relaton_bib/place.rb +0 -203
- data/lib/relaton_bib/renderer/bibtex_builder.rb +0 -312
- data/lib/relaton_bib/renderer/bibxml.rb +0 -296
- data/lib/relaton_bib/series.rb +0 -119
- data/lib/relaton_bib/structured_identifier.rb +0 -173
- data/lib/relaton_bib/technical_committee.rb +0 -34
- data/lib/relaton_bib/typed_title_string.rb +0 -191
- data/lib/relaton_bib/typed_uri.rb +0 -57
- data/lib/relaton_bib/util.rb +0 -16
- 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 -58
- data/lib/relaton_bib/xml_parser.rb +0 -718
- data/lib/relaton_bib.rb +0 -111
|
@@ -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,23 @@
|
|
|
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
|
+
def text
|
|
16
|
+
val = @text
|
|
17
|
+
return val if val && !val.empty?
|
|
18
|
+
|
|
19
|
+
Isoics.fetch(code)&.description if code
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
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,137 @@
|
|
|
1
|
+
require "lutaml/model"
|
|
2
|
+
require "lutaml/model/xml_adapter/nokogiri_adapter"
|
|
3
|
+
require_relative "localized_string_attrs"
|
|
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
|
+
|
|
44
|
+
module Relaton
|
|
45
|
+
module Bib
|
|
46
|
+
class Relation < Lutaml::Model::Serializable
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Item class repesents bibliographic item metadata.
|
|
50
|
+
class Item < Lutaml::Model::Serializable
|
|
51
|
+
attr_accessor :type # in some cases mehod type is unavailable
|
|
52
|
+
|
|
53
|
+
model ItemData
|
|
54
|
+
|
|
55
|
+
attribute :id, :string
|
|
56
|
+
attribute :type, :string, values: %W[
|
|
57
|
+
article book booklet manual proceedings presentation thesis techreport standard
|
|
58
|
+
unpublished map electronic\sresource audiovisual film video boradcast software
|
|
59
|
+
graphic_work music patent inbook incollection inproceedings journal website
|
|
60
|
+
webresource dataset archival social_media alert message convesation misc
|
|
61
|
+
]
|
|
62
|
+
attribute :schema_version, method: :get_schema_version
|
|
63
|
+
attribute :fetched, :date
|
|
64
|
+
attribute :formattedref, Formattedref
|
|
65
|
+
attribute :title, Title, collection: true, initialize_empty: true
|
|
66
|
+
attribute :source, Uri, collection: true, initialize_empty: true
|
|
67
|
+
attribute :docidentifier, Docidentifier, collection: true, initialize_empty: true
|
|
68
|
+
attribute :docnumber, :string
|
|
69
|
+
attribute :date, Date, collection: true, initialize_empty: true
|
|
70
|
+
attribute :contributor, Contributor, collection: true, initialize_empty: true
|
|
71
|
+
attribute :edition, Edition
|
|
72
|
+
attribute :version, Version, collection: true, initialize_empty: true
|
|
73
|
+
attribute :note, Note, collection: true, initialize_empty: true
|
|
74
|
+
attribute :language, :string, collection: true, initialize_empty: true
|
|
75
|
+
attribute :locale, :string, collection: true, initialize_empty: true
|
|
76
|
+
attribute :script, :string, collection: true, initialize_empty: true
|
|
77
|
+
attribute :abstract, Abstract, collection: true, initialize_empty: true
|
|
78
|
+
attribute :status, Status
|
|
79
|
+
attribute :copyright, Copyright, collection: true, initialize_empty: true
|
|
80
|
+
attribute :relation, Relation, collection: true, initialize_empty: true
|
|
81
|
+
attribute :series, Series, collection: true, initialize_empty: true
|
|
82
|
+
attribute :medium, Medium
|
|
83
|
+
attribute :place, Place, collection: true, initialize_empty: true
|
|
84
|
+
attribute :price, Price, collection: true, initialize_empty: true
|
|
85
|
+
attribute :extent, Extent, collection: true, initialize_empty: true
|
|
86
|
+
attribute :size, Size
|
|
87
|
+
attribute :accesslocation, :string, collection: true, initialize_empty: true
|
|
88
|
+
attribute :license, :string, collection: true, initialize_empty: true
|
|
89
|
+
attribute :classification, Docidentifier, collection: true, initialize_empty: true
|
|
90
|
+
attribute :keyword, Keyword, collection: true, initialize_empty: true
|
|
91
|
+
attribute :validity, Validity
|
|
92
|
+
attribute :depiction, Depiction, collection: true, initialize_empty: true
|
|
93
|
+
attribute :ext, Ext
|
|
94
|
+
|
|
95
|
+
xml do # rubocop:disable Metrics/BlockLength
|
|
96
|
+
map_attribute "id", to: :id
|
|
97
|
+
map_attribute "type", to: :type
|
|
98
|
+
map_attribute "schema-version", to: :schema_version
|
|
99
|
+
map_element "fetched", to: :fetched
|
|
100
|
+
map_element "formattedref", to: :formattedref
|
|
101
|
+
map_element "title", to: :title # , with: { from: :title_from_xml, to: :title_to_xml }
|
|
102
|
+
map_element "uri", to: :source
|
|
103
|
+
map_element "docidentifier", to: :docidentifier
|
|
104
|
+
map_element "docnumber", to: :docnumber
|
|
105
|
+
map_element "date", to: :date
|
|
106
|
+
map_element "contributor", to: :contributor
|
|
107
|
+
map_element "edition", to: :edition
|
|
108
|
+
map_element "version", to: :version
|
|
109
|
+
map_element "note", to: :note
|
|
110
|
+
map_element "language", to: :language
|
|
111
|
+
map_element "locale", to: :locale
|
|
112
|
+
map_element "script", to: :script
|
|
113
|
+
map_element "abstract", to: :abstract
|
|
114
|
+
map_element "status", to: :status
|
|
115
|
+
map_element "copyright", to: :copyright
|
|
116
|
+
map_element "relation", to: :relation # , with: { from: :relation_from_xml, to: :relation_to_xml }
|
|
117
|
+
map_element "series", to: :series
|
|
118
|
+
map_element "medium", to: :medium
|
|
119
|
+
map_element "place", to: :place
|
|
120
|
+
map_element "price", to: :price
|
|
121
|
+
map_element "extent", to: :extent
|
|
122
|
+
map_element "size", to: :size
|
|
123
|
+
map_element "accesslocation", to: :accesslocation
|
|
124
|
+
map_element "license", to: :license
|
|
125
|
+
map_element "classification", to: :classification
|
|
126
|
+
map_element "keyword", to: :keyword
|
|
127
|
+
map_element "validity", to: :validity
|
|
128
|
+
map_element "depiction", to: :depiction
|
|
129
|
+
map_element "ext", to: :ext
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def get_schema_version
|
|
133
|
+
Relaton.schema_versions["relaton-models"]
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
# Module to remove id, schema-version, fetched & ext attributes from Item subclasses.
|
|
4
|
+
# Used for bibitem/relation instances that don't need these attributes.
|
|
5
|
+
module ItemBaseAttributes
|
|
6
|
+
def self.included(base)
|
|
7
|
+
# we don't need id, schema-version & fetched attributes in relation/bibitem
|
|
8
|
+
base.mappings[:xml].instance_variable_get(:@attributes).delete("id")
|
|
9
|
+
base.mappings[:xml].instance_variable_get(:@attributes).delete("schema-version")
|
|
10
|
+
base.mappings[:xml].instance_variable_get(:@elements).delete("fetched")
|
|
11
|
+
base.mappings[:xml].instance_variable_get(:@elements).delete("ext")
|
|
12
|
+
base.attributes.delete :id
|
|
13
|
+
base.attributes.delete :schema_version
|
|
14
|
+
base.attributes.delete :fetched
|
|
15
|
+
base.attributes.delete :ext
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
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
|
+
model ItemData
|
|
23
|
+
|
|
24
|
+
include ItemBaseAttributes
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
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,57 @@
|
|
|
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 # , with: { from: :content_from_key_value, to: :content_to_key_value }
|
|
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
|
+
attribute :content, :string
|
|
30
|
+
|
|
31
|
+
xml do
|
|
32
|
+
map_all to: :content, with: { from: :content_from_xml, to: :content_to_xml }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
key_value do
|
|
36
|
+
map "content", to: :content, with: { from: :content_from_key_value, to: :content_to_key_value }
|
|
37
|
+
map "language", to: :language
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def content_from_xml(model, value)
|
|
41
|
+
model.content = value
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def content_to_xml(model, parent, doc)
|
|
45
|
+
doc.add_xml_fragment parent, model.content
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def content_from_key_value(model, value)
|
|
49
|
+
model.content = value
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def content_to_key_value(model, doc)
|
|
53
|
+
doc["content"] = model.content
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
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,42 @@
|
|
|
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
|
+
require_relative "subdivision"
|
|
17
|
+
|
|
18
|
+
base.instance_eval do
|
|
19
|
+
include Contact
|
|
20
|
+
|
|
21
|
+
attribute :name, TypedLocalizedString, collection: true, initialize_empty: true
|
|
22
|
+
attribute :subdivision, Subdivision, collection: true, initialize_empty: true
|
|
23
|
+
attribute :abbreviation, LocalizedString
|
|
24
|
+
attribute :identifier, Identifier, collection: true, initialize_empty: true
|
|
25
|
+
attribute :logo, Logo, collection: true, initialize_empty: true
|
|
26
|
+
|
|
27
|
+
xml do
|
|
28
|
+
map_element "name", to: :name
|
|
29
|
+
map_element "subdivision", to: :subdivision
|
|
30
|
+
map_element "abbreviation", to: :abbreviation
|
|
31
|
+
map_element "identifier", to: :identifier
|
|
32
|
+
map_element "address", to: :address
|
|
33
|
+
map_element "phone", to: :phone
|
|
34
|
+
map_element "email", to: :email
|
|
35
|
+
map_element "uri", to: :uri
|
|
36
|
+
map_element "logo", to: :logo
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
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
|