relaton-bib 0.3.4 → 0.3.9
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/macos.yml +27 -0
- data/.github/workflows/ubuntu.yml +27 -0
- data/.github/workflows/windows.yml +30 -0
- data/Gemfile.lock +5 -5
- data/lib/relaton_bib.rb +33 -1
- data/lib/relaton_bib/bib_item_locality.rb +3 -3
- data/lib/relaton_bib/biblio_note.rb +4 -1
- data/lib/relaton_bib/biblio_version.rb +5 -3
- data/lib/relaton_bib/bibliographic_date.rb +10 -25
- data/lib/relaton_bib/bibliographic_item.rb +31 -30
- data/lib/relaton_bib/classification.rb +2 -2
- data/lib/relaton_bib/contribution_info.rb +14 -9
- data/lib/relaton_bib/contributor.rb +14 -10
- data/lib/relaton_bib/copyright_association.rb +5 -5
- data/lib/relaton_bib/document_identifier.rb +2 -2
- data/lib/relaton_bib/document_relation.rb +4 -2
- data/lib/relaton_bib/document_status.rb +3 -3
- data/lib/relaton_bib/formatted_string.rb +6 -3
- data/lib/relaton_bib/hash_converter.rb +143 -98
- data/lib/relaton_bib/hit.rb +32 -0
- data/lib/relaton_bib/hit_collection.rb +34 -0
- data/lib/relaton_bib/localized_string.rb +7 -3
- data/lib/relaton_bib/medium.rb +3 -3
- data/lib/relaton_bib/organization.rb +25 -29
- data/lib/relaton_bib/person.rb +13 -20
- data/lib/relaton_bib/series.rb +10 -10
- data/lib/relaton_bib/typed_title_string.rb +10 -3
- data/lib/relaton_bib/typed_uri.rb +2 -2
- data/lib/relaton_bib/validity.rb +3 -3
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +17 -6
- data/relaton-bib.gemspec +2 -2
- metadata +12 -9
- data/.travis.yml +0 -18
- data/appveyor.yml +0 -37
@@ -47,11 +47,11 @@ module RelatonBib
|
|
47
47
|
# @return [Hash]
|
48
48
|
def to_hash
|
49
49
|
hash = {}
|
50
|
-
hash[
|
51
|
-
hash[
|
52
|
-
hash[
|
53
|
-
hash[
|
54
|
-
hash[
|
50
|
+
hash["street"] = street if street&.any?
|
51
|
+
hash["city"] = city
|
52
|
+
hash["state"] = state if state
|
53
|
+
hash["country"] = country
|
54
|
+
hash["postcode"] = postcode if postcode
|
55
55
|
hash
|
56
56
|
end
|
57
57
|
end
|
@@ -77,12 +77,14 @@ module RelatonBib
|
|
77
77
|
|
78
78
|
# @return [Hash]
|
79
79
|
def to_hash
|
80
|
-
{ type
|
80
|
+
{ "type" => type, "value" => value }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
# Affilation.
|
85
85
|
class Affilation
|
86
|
+
include RelatonBib
|
87
|
+
|
86
88
|
# @return [RelatonBib::LocalizedString, NilClass]
|
87
89
|
attr_reader :name
|
88
90
|
|
@@ -113,14 +115,16 @@ module RelatonBib
|
|
113
115
|
# @return [Hash]
|
114
116
|
def to_hash
|
115
117
|
hash = organization.to_hash
|
116
|
-
hash[
|
117
|
-
hash[
|
118
|
+
hash["name"] = name.to_hash if name
|
119
|
+
hash["description"] = single_element_array(description) if description&.any?
|
118
120
|
hash
|
119
121
|
end
|
120
122
|
end
|
121
123
|
|
122
124
|
# Contributor.
|
123
125
|
class Contributor
|
126
|
+
include RelatonBib
|
127
|
+
|
124
128
|
# @return [URI]
|
125
129
|
attr_reader :uri
|
126
130
|
|
@@ -148,8 +152,8 @@ module RelatonBib
|
|
148
152
|
# @return [Hash]
|
149
153
|
def to_hash
|
150
154
|
hash = {}
|
151
|
-
hash[
|
152
|
-
hash[
|
155
|
+
hash["url"] = uri.to_s if uri
|
156
|
+
hash["contact"] = single_element_array(contact) if contact&.any?
|
153
157
|
hash
|
154
158
|
end
|
155
159
|
end
|
@@ -22,14 +22,14 @@ module RelatonBib
|
|
22
22
|
else owner
|
23
23
|
end
|
24
24
|
|
25
|
-
@from = Date.strptime(from, "%Y")
|
26
|
-
@to = Date.strptime(to, "%Y") unless to.to_s.empty?
|
25
|
+
@from = Date.strptime(from.to_s, "%Y") if from.to_s =~ /\d{4}/
|
26
|
+
@to = Date.strptime(to.to_s, "%Y") unless to.to_s.empty?
|
27
27
|
end
|
28
28
|
|
29
29
|
# @param builder [Nokogiri::XML::Builder]
|
30
30
|
def to_xml(builder)
|
31
31
|
builder.copyright do
|
32
|
-
builder.from from.year
|
32
|
+
builder.from from ? from.year : "unknown"
|
33
33
|
builder.to to.year if to
|
34
34
|
builder.owner { owner.to_xml builder }
|
35
35
|
end
|
@@ -37,8 +37,8 @@ module RelatonBib
|
|
37
37
|
|
38
38
|
# @return [Hash]
|
39
39
|
def to_hash
|
40
|
-
hash = { owner
|
41
|
-
hash[
|
40
|
+
hash = { "owner" => owner.to_hash["organization"], "from" => from.year.to_s }
|
41
|
+
hash["to"] = to.year.to_s if to
|
42
42
|
hash
|
43
43
|
end
|
44
44
|
end
|
@@ -14,6 +14,8 @@ module RelatonBib
|
|
14
14
|
|
15
15
|
# Documett relation
|
16
16
|
class DocumentRelation
|
17
|
+
include RelatonBib
|
18
|
+
|
17
19
|
# @return [String]
|
18
20
|
attr_reader :type
|
19
21
|
|
@@ -50,8 +52,8 @@ module RelatonBib
|
|
50
52
|
|
51
53
|
# @return [Hash]
|
52
54
|
def to_hash
|
53
|
-
hash = { type
|
54
|
-
hash[
|
55
|
+
hash = { "type" => type, "bibitem" => bibitem.to_hash }
|
56
|
+
hash["bib_locality"] = single_element_array(bib_locality) if bib_locality&.any?
|
55
57
|
hash
|
56
58
|
end
|
57
59
|
end
|
@@ -35,9 +35,9 @@ module RelatonBib
|
|
35
35
|
|
36
36
|
# @return [Hash]
|
37
37
|
def to_hash
|
38
|
-
hash = { stage
|
39
|
-
hash[
|
40
|
-
hash[
|
38
|
+
hash = { "stage" => stage }
|
39
|
+
hash["substage"] = substage if substage
|
40
|
+
hash["iteration"] = iteration if iteration
|
41
41
|
hash
|
42
42
|
end
|
43
43
|
end
|
@@ -13,8 +13,8 @@ module RelatonBib
|
|
13
13
|
attr_reader :format
|
14
14
|
|
15
15
|
# @param content [String]
|
16
|
-
# @param language [String] language code Iso639
|
17
|
-
# @param script [String] script code Iso15924
|
16
|
+
# @param language [String, NilClass] language code Iso639
|
17
|
+
# @param script [String, NilClass] script code Iso15924
|
18
18
|
# @param format [String] the content type
|
19
19
|
def initialize(content:, language: nil, script: nil, format: "text/plain")
|
20
20
|
# if format && !FORMATS.include?(format)
|
@@ -34,7 +34,10 @@ module RelatonBib
|
|
34
34
|
# @return [Hash]
|
35
35
|
def to_hash
|
36
36
|
hash = super
|
37
|
-
hash
|
37
|
+
return hash unless format
|
38
|
+
|
39
|
+
hash = { "content" => hash } if hash.is_a? String
|
40
|
+
hash["format"] = format if format
|
38
41
|
hash
|
39
42
|
end
|
40
43
|
end
|
@@ -35,6 +35,7 @@ module RelatonBib
|
|
35
35
|
|
36
36
|
def extent_hash_to_bib(ret)
|
37
37
|
return unless ret[:extent]
|
38
|
+
|
38
39
|
ret[:extent] = array(ret[:extent])
|
39
40
|
ret[:extent]&.each_with_index do |e, i|
|
40
41
|
ret[:extent][i] = BibItemLocality.new(e[:type], e[:reference_from],
|
@@ -44,45 +45,57 @@ module RelatonBib
|
|
44
45
|
|
45
46
|
def title_hash_to_bib(ret)
|
46
47
|
return unless ret[:title]
|
48
|
+
|
47
49
|
ret[:title] = array(ret[:title])
|
48
50
|
ret[:title] = ret[:title].map do |t|
|
49
|
-
t.is_a?(Hash)
|
50
|
-
|
51
|
+
if t.is_a?(Hash) then t
|
52
|
+
else
|
53
|
+
{ content: t, language: "en", script: "Latn", format: "text/plain", type: "main" }
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
58
|
def language_hash_to_bib(ret)
|
55
59
|
return unless ret[:language]
|
60
|
+
|
56
61
|
ret[:language] = array(ret[:language])
|
57
62
|
end
|
58
63
|
|
59
64
|
def script_hash_to_bib(ret)
|
60
65
|
return unless ret[:script]
|
66
|
+
|
61
67
|
ret[:script] = array(ret[:script])
|
62
68
|
end
|
63
69
|
|
64
70
|
def abstract_hash_to_bib(ret)
|
65
71
|
return unless ret[:abstract]
|
66
|
-
|
72
|
+
|
73
|
+
ret[:abstract] = array(ret[:abstract]).map do |a|
|
74
|
+
a.is_a?(String) ? FormattedString.new(content: a) : a
|
75
|
+
end
|
67
76
|
end
|
68
77
|
|
69
78
|
def link_hash_to_bib(ret)
|
70
79
|
return unless ret[:link]
|
80
|
+
|
71
81
|
ret[:link] = array(ret[:link])
|
72
82
|
end
|
73
83
|
|
74
84
|
def place_hash_to_bib(ret)
|
75
85
|
return unless ret[:place]
|
86
|
+
|
76
87
|
ret[:place] = array(ret[:place])
|
77
88
|
end
|
78
89
|
|
79
90
|
def accesslocation_hash_to_bib(ret)
|
80
91
|
return unless ret[:accesslocation]
|
92
|
+
|
81
93
|
ret[:accesslocation] = array(ret[:accesslocation])
|
82
94
|
end
|
83
95
|
|
84
96
|
def dates_hash_to_bib(ret)
|
85
97
|
return unless ret[:date]
|
98
|
+
|
86
99
|
ret[:date] = array(ret[:date])
|
87
100
|
ret[:date].each_with_index do |d, i|
|
88
101
|
# value is synonym of on: it is reserved word in YAML
|
@@ -95,6 +108,7 @@ module RelatonBib
|
|
95
108
|
|
96
109
|
def docid_hash_to_bib(ret)
|
97
110
|
return unless ret[:docid]
|
111
|
+
|
98
112
|
ret[:docid] = array(ret[:docid])
|
99
113
|
ret[:docid]&.each_with_index do |id, i|
|
100
114
|
ret[:docid][i] = DocumentIdentifier.new(id: id[:id], type: id[:type])
|
@@ -103,115 +117,129 @@ module RelatonBib
|
|
103
117
|
|
104
118
|
def version_hash_to_bib(ret)
|
105
119
|
return unless ret[:version]
|
120
|
+
|
106
121
|
ret[:version][:draft] = array(ret[:version][:draft])
|
107
|
-
ret[:version]
|
108
|
-
|
122
|
+
ret[:version] && ret[:version] = BibliographicItem::Version.new(
|
123
|
+
ret[:version][:revision_date], ret[:version][:draft]
|
124
|
+
)
|
109
125
|
end
|
110
126
|
|
111
127
|
def biblionote_hash_to_bib(ret)
|
112
128
|
return unless ret[:biblionote]
|
129
|
+
|
113
130
|
ret[:biblionote] = array(ret[:biblionote])
|
114
131
|
(ret[:biblionote])&.each_with_index do |n, i|
|
115
|
-
ret[:biblionote][i] =
|
116
|
-
|
117
|
-
|
118
|
-
|
132
|
+
ret[:biblionote][i] = BiblioNote.new(
|
133
|
+
content: n[:content], type: n[:type], language: n[:language],
|
134
|
+
script: n[:script], format: n[:format]
|
135
|
+
)
|
119
136
|
end
|
120
137
|
end
|
121
138
|
|
122
139
|
def formattedref_hash_to_bib(ret)
|
123
|
-
ret[:formattedref]
|
124
|
-
formattedref(ret[:formattedref])
|
140
|
+
ret[:formattedref] && ret[:formattedref] = formattedref(ret[:formattedref])
|
125
141
|
end
|
126
142
|
|
127
143
|
def docstatus_hash_to_bib(ret)
|
128
|
-
ret[:docstatus]
|
129
|
-
|
130
|
-
|
131
|
-
|
144
|
+
ret[:docstatus] && ret[:docstatus] = DocumentStatus.new(
|
145
|
+
stage: ret[:docstatus][:stage],
|
146
|
+
substage: ret[:docstatus][:substage],
|
147
|
+
iteration: ret[:docstatus][:iteration],
|
148
|
+
)
|
132
149
|
end
|
133
150
|
|
134
151
|
def contributors_hash_to_bib(ret)
|
135
152
|
return unless ret[:contributor]
|
153
|
+
|
136
154
|
ret[:contributor] = array(ret[:contributor])
|
137
155
|
ret[:contributor]&.each_with_index do |c, i|
|
138
156
|
roles = array(ret[:contributor][i][:role]).map do |r|
|
139
157
|
if r.is_a? Hash
|
140
158
|
{ type: r[:type], description: array(r[:description]) }
|
141
|
-
elsif r.is_a? Array
|
142
|
-
|
159
|
+
# elsif r.is_a? Array
|
160
|
+
# { type: r[0], description: r.fetch(1) }
|
143
161
|
else
|
144
162
|
{ type: r }
|
145
163
|
end
|
146
164
|
end
|
147
165
|
ret[:contributor][i][:role] = roles
|
148
|
-
ret[:contributor][i][:entity] = c[:person]
|
149
|
-
|
166
|
+
ret[:contributor][i][:entity] = if c[:person]
|
167
|
+
person_hash_to_bib(c[:person])
|
168
|
+
else
|
169
|
+
org_hash_to_bib(c[:organization])
|
170
|
+
end
|
150
171
|
ret[:contributor][i].delete(:person)
|
151
172
|
ret[:contributor][i].delete(:organization)
|
152
173
|
end
|
153
174
|
end
|
154
175
|
|
155
|
-
def org_hash_to_bib(
|
156
|
-
return nil if
|
157
|
-
|
176
|
+
def org_hash_to_bib(org)
|
177
|
+
return nil if org.nil?
|
178
|
+
|
179
|
+
org[:identifier] = array(org[:identifier])&.map do |a|
|
158
180
|
OrgIdentifier.new(a[:type], a[:id])
|
159
181
|
end
|
160
|
-
|
182
|
+
org
|
161
183
|
end
|
162
184
|
|
163
|
-
def person_hash_to_bib(
|
185
|
+
def person_hash_to_bib(person)
|
164
186
|
Person.new(
|
165
|
-
name: fullname_hash_to_bib(
|
166
|
-
affiliation: affiliation_hash_to_bib(
|
167
|
-
contact: contacts_hash_to_bib(
|
168
|
-
identifier: person_identifiers_hash_to_bib(
|
187
|
+
name: fullname_hash_to_bib(person),
|
188
|
+
affiliation: affiliation_hash_to_bib(person),
|
189
|
+
contact: contacts_hash_to_bib(person),
|
190
|
+
identifier: person_identifiers_hash_to_bib(person),
|
169
191
|
)
|
170
192
|
end
|
171
193
|
|
172
|
-
def fullname_hash_to_bib(
|
173
|
-
n =
|
194
|
+
def fullname_hash_to_bib(person)
|
195
|
+
n = person[:name]
|
174
196
|
FullName.new(
|
175
|
-
forename: array(n[:forename])&.map { |f| localname(f,
|
176
|
-
initial: array(n[:initial])&.map { |f| localname(f,
|
177
|
-
addition: array(n[:addition])&.map { |f| localname(f,
|
178
|
-
prefix: array(n[:prefix])&.map { |f| localname(f,
|
179
|
-
surname: localname(n[:surname],
|
180
|
-
completename: localname(n[:completename],
|
197
|
+
forename: array(n[:forename])&.map { |f| localname(f, person) },
|
198
|
+
initial: array(n[:initial])&.map { |f| localname(f, person) },
|
199
|
+
addition: array(n[:addition])&.map { |f| localname(f, person) },
|
200
|
+
prefix: array(n[:prefix])&.map { |f| localname(f, person) },
|
201
|
+
surname: localname(n[:surname], person),
|
202
|
+
completename: localname(n[:completename], person),
|
181
203
|
)
|
182
204
|
end
|
183
205
|
|
184
|
-
def person_identifiers_hash_to_bib(
|
185
|
-
array(
|
206
|
+
def person_identifiers_hash_to_bib(person)
|
207
|
+
array(person[:identifier])&.map do |a|
|
186
208
|
PersonIdentifier.new(a[:type], a[:id])
|
187
209
|
end
|
188
210
|
end
|
189
211
|
|
190
|
-
def affiliation_hash_to_bib(
|
191
|
-
return [] unless
|
192
|
-
|
212
|
+
def affiliation_hash_to_bib(person)
|
213
|
+
return [] unless person[:affiliation]
|
214
|
+
|
215
|
+
array(person[:affiliation]).map do |a|
|
193
216
|
a[:description] = array(a[:description])&.map do |d|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
217
|
+
cnt = if d.is_a?(Hash)
|
218
|
+
{ content: d[:content], language: d[:language],
|
219
|
+
script: d[:script], format: d[:format] }
|
220
|
+
else { content: d }
|
221
|
+
end
|
222
|
+
FormattedString.new cnt
|
199
223
|
end
|
200
224
|
Affilation.new(
|
201
225
|
organization: Organization.new(org_hash_to_bib(a[:organization])),
|
202
|
-
description: a[:description]
|
226
|
+
description: a[:description],
|
203
227
|
)
|
204
228
|
end
|
205
229
|
end
|
206
230
|
|
207
|
-
def contacts_hash_to_bib(
|
208
|
-
return [] unless
|
209
|
-
|
210
|
-
|
231
|
+
def contacts_hash_to_bib(person)
|
232
|
+
return [] unless person[:contact]
|
233
|
+
|
234
|
+
array(person[:contact]).map do |a|
|
235
|
+
if a[:city] || a[:country]
|
211
236
|
RelatonBib::Address.new(
|
212
237
|
street: Array(a[:street]), city: a[:city], postcode: a[:postcode],
|
213
|
-
country: a[:country], state: a[:state]
|
214
|
-
|
238
|
+
country: a[:country], state: a[:state]
|
239
|
+
)
|
240
|
+
else
|
241
|
+
RelatonBib::Contact.new(type: a[:type], value: a[:value])
|
242
|
+
end
|
215
243
|
end
|
216
244
|
end
|
217
245
|
|
@@ -226,14 +254,14 @@ module RelatonBib
|
|
226
254
|
end
|
227
255
|
|
228
256
|
# @param ret [Hash]
|
229
|
-
# @param
|
230
|
-
# @param
|
231
|
-
def relation_bibitem_hash_to_bib(ret,
|
232
|
-
if
|
233
|
-
ret[:relation][
|
257
|
+
# @param rel [Hash] relation
|
258
|
+
# @param idx [Integr] index of relation
|
259
|
+
def relation_bibitem_hash_to_bib(ret, rel, idx)
|
260
|
+
if rel[:bibitem]
|
261
|
+
ret[:relation][idx][:bibitem] = bib_item(hash_to_bib(rel[:bibitem], true))
|
234
262
|
else
|
235
|
-
warn "bibitem missing: #{
|
236
|
-
ret[:relation][
|
263
|
+
warn "bibitem missing: #{rel}"
|
264
|
+
ret[:relation][idx][:bibitem] = nil
|
237
265
|
end
|
238
266
|
end
|
239
267
|
|
@@ -243,24 +271,23 @@ module RelatonBib
|
|
243
271
|
BibliographicItem.new(item)
|
244
272
|
end
|
245
273
|
|
246
|
-
def relation_biblocality_hash_to_bib(ret,
|
247
|
-
ret[:relation][
|
248
|
-
array(
|
274
|
+
def relation_biblocality_hash_to_bib(ret, rel, idx)
|
275
|
+
ret[:relation][idx][:bib_locality] =
|
276
|
+
array(rel[:bib_locality])&.map do |bl|
|
249
277
|
BibItemLocality.new(bl[:type], bl[:reference_from],
|
250
278
|
bl[:reference_to])
|
251
279
|
end
|
252
280
|
end
|
253
281
|
|
254
282
|
def series_hash_to_bib(ret)
|
255
|
-
array(ret[:series])&.
|
256
|
-
s[:formattedref]
|
283
|
+
ret[:series] = array(ret[:series])&.map do |s|
|
284
|
+
s[:formattedref] && s[:formattedref] = formattedref(s[:formattedref])
|
257
285
|
if s[:title]
|
258
286
|
s[:title] = { content: s[:title] } unless s.is_a?(Hash)
|
259
287
|
s[:title] = typed_title_strig(s[:title])
|
260
288
|
end
|
261
|
-
s[:abbreviation]
|
262
|
-
|
263
|
-
ret[:series][i] = Series.new(s)
|
289
|
+
s[:abbreviation] && s[:abbreviation] = localizedstring(s[:abbreviation])
|
290
|
+
Series.new(s)
|
264
291
|
end
|
265
292
|
end
|
266
293
|
|
@@ -271,7 +298,7 @@ module RelatonBib
|
|
271
298
|
end
|
272
299
|
|
273
300
|
def medium_hash_to_bib(ret)
|
274
|
-
ret[:medium]
|
301
|
+
ret[:medium] = Medium.new(ret[:medium]) if ret[:medium]
|
275
302
|
end
|
276
303
|
|
277
304
|
def classification_hash_to_bib(ret)
|
@@ -279,52 +306,70 @@ module RelatonBib
|
|
279
306
|
# ret[:classification]&.each_with_index do |c, i|
|
280
307
|
# ret[:classification][i] = RelatonBib::Classification.new(c)
|
281
308
|
# end
|
282
|
-
ret[:classification]
|
309
|
+
if ret[:classification]
|
283
310
|
ret[:classification] = Classification.new(ret[:classification])
|
311
|
+
end
|
284
312
|
end
|
285
313
|
|
286
314
|
def validity_hash_to_bib(ret)
|
287
315
|
return unless ret[:validity]
|
288
|
-
|
289
|
-
ret[:validity][:
|
290
|
-
ret[:validity][:
|
316
|
+
|
317
|
+
ret[:validity][:begins] && b = Time.parse(ret[:validity][:begins])
|
318
|
+
ret[:validity][:ends] && e = Time.parse(ret[:validity][:ends])
|
319
|
+
ret[:validity][:revision] && r = Time.parse(ret[:validity][:revision])
|
291
320
|
ret[:validity] = Validity.new(begins: b, ends: e, revision: r)
|
292
321
|
end
|
293
322
|
|
323
|
+
# @param ogj [Hash, Array, String]
|
324
|
+
# @return [Hash, Array, String]
|
294
325
|
def symbolize(obj)
|
295
|
-
obj.is_a? Hash
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
326
|
+
if obj.is_a? Hash
|
327
|
+
obj.reduce({}) do |memo, (k, v)|
|
328
|
+
memo[k.to_sym] = symbolize(v)
|
329
|
+
memo
|
330
|
+
end
|
331
|
+
elsif obj.is_a? Array
|
332
|
+
obj.reduce([]) { |memo, v| memo << symbolize(v) }
|
333
|
+
else
|
334
|
+
obj
|
335
|
+
end
|
300
336
|
end
|
301
337
|
|
302
|
-
def array(
|
303
|
-
return [] unless
|
304
|
-
return [
|
305
|
-
|
338
|
+
def array(arr)
|
339
|
+
return [] unless arr
|
340
|
+
return [arr] unless arr.is_a?(Array)
|
341
|
+
|
342
|
+
arr
|
306
343
|
end
|
307
344
|
|
308
|
-
def localname(
|
309
|
-
return nil if
|
310
|
-
|
311
|
-
lang
|
312
|
-
|
313
|
-
script
|
314
|
-
|
315
|
-
|
316
|
-
RelatonBib::LocalizedString.new(
|
345
|
+
def localname(name, person)
|
346
|
+
return nil if name.nil?
|
347
|
+
|
348
|
+
lang = name[:language] if name.is_a?(Hash)
|
349
|
+
lang ||= person[:name][:language]
|
350
|
+
script = name[:script] if name.is_a?(Hash)
|
351
|
+
script ||= person[:name][:script]
|
352
|
+
if name.is_a?(Hash)
|
353
|
+
RelatonBib::LocalizedString.new(name[:content], lang, script)
|
354
|
+
else
|
355
|
+
RelatonBib::LocalizedString.new(name, lang, script)
|
356
|
+
end
|
317
357
|
end
|
318
358
|
|
319
|
-
def localizedstring(
|
320
|
-
|
321
|
-
RelatonBib::LocalizedString.new(
|
322
|
-
|
359
|
+
def localizedstring(lst)
|
360
|
+
if lst.is_a?(Hash)
|
361
|
+
RelatonBib::LocalizedString.new(lst[:content], lst[:language], lst[:script])
|
362
|
+
else
|
363
|
+
RelatonBib::LocalizedString.new(lst)
|
364
|
+
end
|
323
365
|
end
|
324
366
|
|
325
|
-
def formattedref(
|
326
|
-
|
327
|
-
RelatonBib::FormattedRef.new(
|
367
|
+
def formattedref(frf)
|
368
|
+
if frf.is_a?(Hash)
|
369
|
+
RelatonBib::FormattedRef.new(frf)
|
370
|
+
else
|
371
|
+
RelatonBib::FormattedRef.new(content: frf)
|
372
|
+
end
|
328
373
|
end
|
329
374
|
end
|
330
375
|
end
|