relaton-bib 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.adoc +5 -5
- data/lib/relaton_bib/bibliographic_date.rb +5 -5
- data/lib/relaton_bib/bibliographic_item.rb +34 -30
- data/lib/relaton_bib/contribution_info.rb +7 -7
- data/lib/relaton_bib/contributor.rb +7 -7
- data/lib/relaton_bib/document_relation.rb +6 -6
- data/lib/relaton_bib/document_relation_collection.rb +9 -9
- data/lib/relaton_bib/organization.rb +7 -7
- data/lib/relaton_bib/person.rb +26 -26
- data/lib/relaton_bib/typed_uri.rb +1 -1
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +19 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae823658c869e7c4d00aef9221fdf350c392983d
|
4
|
+
data.tar.gz: 825dc45f0be774a8ab5223cee4228756f0980d43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24d8041638369f3e86da7e3dbb28f6aae1f399377f301a69d26bfadf0d3099c428517f6910e8563efa470aa5756a29ca4952fe613a4956d5097531930890c9c9
|
7
|
+
data.tar.gz: 2ca098df8c11661cc0c7a34830528b667e47da674c9afa0a14e0f1e55737adace2533a5a99be67630be7e3269c28bc5c35a789a71c0d3bd9ba9722a7047ec32d
|
data/Gemfile.lock
CHANGED
data/README.adoc
CHANGED
@@ -33,7 +33,7 @@ item = RelatonBib::BibliographicItem.new(
|
|
33
33
|
id: "ISO/TC211",
|
34
34
|
fetched: Date.today.to_s,
|
35
35
|
type: "standard",
|
36
|
-
|
36
|
+
title: [
|
37
37
|
{ type: "main", content: "Geographic information", language: "en", script: "Latn" },
|
38
38
|
{
|
39
39
|
content: "Information géographique", language: "fr", script: "Latn"
|
@@ -50,16 +50,16 @@ item = RelatonBib::BibliographicItem.new(
|
|
50
50
|
RelatonBib::DocumentIdentifier.new(id: "TC211", type: "ISO")
|
51
51
|
],
|
52
52
|
docnumber: "123456",
|
53
|
-
|
53
|
+
date: [
|
54
54
|
{ type: "issued", on: "2014" },
|
55
55
|
{ type: "published", on: "2014-04" },
|
56
56
|
{ type: "accessed", on: "2015-05-20" }
|
57
57
|
],
|
58
|
-
|
58
|
+
contributor: [
|
59
59
|
{ entity: {
|
60
60
|
name: "International Organization for Standardization",
|
61
61
|
url: "www.iso.org", abbreviation: "ISO", subdivision: "division" },
|
62
|
-
|
62
|
+
role: [["publisher", ["Publisher role"]]], }
|
63
63
|
],
|
64
64
|
edition: "1",
|
65
65
|
version: RelatonBib::BibliographicItem::Version.new("2019-04-01", ["draft"]),
|
@@ -79,7 +79,7 @@ item = RelatonBib::BibliographicItem.new(
|
|
79
79
|
abbreviation: "ISO", url: "www.iso.org"
|
80
80
|
},
|
81
81
|
from: "2014", to: "2020" },
|
82
|
-
|
82
|
+
relation: [
|
83
83
|
{ type: "updates",
|
84
84
|
bibitem: RelatonBib::BibliographicItem.new(
|
85
85
|
formattedref: RelatonBib::FormattedRef.new(content: "ISO 19115:2003"),
|
@@ -5,13 +5,13 @@ require "time"
|
|
5
5
|
module RelatonBib
|
6
6
|
class << self
|
7
7
|
def dates_hash_to_bib(ret)
|
8
|
-
return unless ret[:
|
9
|
-
ret[:
|
10
|
-
ret[:
|
8
|
+
return unless ret[:date]
|
9
|
+
ret[:date] = array(ret[:date])
|
10
|
+
ret[:date].each_with_index do |d, i|
|
11
11
|
# value is synonym of on: it is reserved word in YAML
|
12
12
|
if d[:value]
|
13
|
-
ret[:
|
14
|
-
ret[:
|
13
|
+
ret[:date][i][:on] ||= d[:value]
|
14
|
+
ret[:date][i].delete(:value)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -35,9 +35,9 @@ module RelatonBib
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def title_hash_to_bib(ret)
|
38
|
-
return unless ret[:
|
39
|
-
ret[:
|
40
|
-
ret[:
|
38
|
+
return unless ret[:title]
|
39
|
+
ret[:title] = array(ret[:title])
|
40
|
+
ret[:title] = ret[:title].map do |t|
|
41
41
|
t.is_a?(Hash) ? t : { content: t, language: "en", script: "Latn",
|
42
42
|
format: "text/plain", type: "main" }
|
43
43
|
end
|
@@ -101,10 +101,10 @@ module RelatonBib
|
|
101
101
|
attr_reader :docnumber
|
102
102
|
|
103
103
|
# @return [Array<RelatonBib::BibliographicDate>]
|
104
|
-
attr_reader :
|
104
|
+
attr_reader :date
|
105
105
|
|
106
106
|
# @return [Array<RelatonBib::ContributionInfo>]
|
107
|
-
attr_reader :
|
107
|
+
attr_reader :contributor
|
108
108
|
|
109
109
|
# @return [String, NillClass]
|
110
110
|
attr_reader :edition
|
@@ -134,7 +134,7 @@ module RelatonBib
|
|
134
134
|
attr_reader :copyright
|
135
135
|
|
136
136
|
# @return [RelatonBib::DocRelationCollection]
|
137
|
-
attr_reader :
|
137
|
+
attr_reader :relation
|
138
138
|
|
139
139
|
# @return [Array<RelatonBib::Series>]
|
140
140
|
attr_reader :series
|
@@ -184,18 +184,18 @@ module RelatonBib
|
|
184
184
|
# @param validity [RelatonBib:Validity, NilClass]
|
185
185
|
# @param fetched [Date, NilClass] default nil
|
186
186
|
#
|
187
|
-
# @param
|
188
|
-
# @option
|
189
|
-
# @option
|
190
|
-
# @option
|
187
|
+
# @param date [Array<Hash>]
|
188
|
+
# @option date [String] :type
|
189
|
+
# @option date [String] :from
|
190
|
+
# @option date [String] :to
|
191
191
|
#
|
192
|
-
# @param
|
193
|
-
# @option
|
194
|
-
# @option
|
195
|
-
# @option
|
196
|
-
# @option
|
197
|
-
# @option
|
198
|
-
# @option
|
192
|
+
# @param contributor [Array<Hash>]
|
193
|
+
# @option contributor [RealtonBib::Organization, RelatonBib::Person]
|
194
|
+
# @option contributor [String] :type
|
195
|
+
# @option contributor [String] :from
|
196
|
+
# @option contributor [String] :to
|
197
|
+
# @option contributor [String] :abbreviation
|
198
|
+
# @option contributor [Array<Array<String,Array<String>>>] :role
|
199
199
|
#
|
200
200
|
# @param abstract [Array<Hash, RelatonBib::FormattedString>]
|
201
201
|
# @option abstract [String] :content
|
@@ -203,27 +203,31 @@ module RelatonBib
|
|
203
203
|
# @option abstract [String] :script
|
204
204
|
# @option abstract [String] :type
|
205
205
|
#
|
206
|
-
# @param
|
207
|
-
# @option
|
208
|
-
# @option
|
209
|
-
# @option
|
206
|
+
# @param relation [Array<Hash>]
|
207
|
+
# @option relation [String] :type
|
208
|
+
# @option relation [RelatonBib::BibliographicItem, RelatonIso::IsoBibliographicItem] :bibitem
|
209
|
+
# @option relation [Array<RelatonBib::BibItemLocality>] :bib_locality
|
210
|
+
#
|
211
|
+
# @param link [Array<Hash, RelatonBib::TypedUri>]
|
212
|
+
# @option link [String] :type
|
213
|
+
# @option link [String] :content
|
210
214
|
def initialize(**args)
|
211
215
|
if args[:type] && !TYPES.include?(args[:type])
|
212
216
|
raise ArgumentError, %{Type "#{args[:type]}" is invalid.}
|
213
217
|
end
|
214
218
|
|
215
|
-
@title = (args[:
|
219
|
+
@title = (args[:title] || []).map do |t|
|
216
220
|
t.is_a?(Hash) ? TypedTitleString.new(t) : t
|
217
221
|
end
|
218
222
|
|
219
|
-
@
|
223
|
+
@date = (args[:date] || []).map do |d|
|
220
224
|
d.is_a?(Hash) ? BibliographicDate.new(d) : d
|
221
225
|
end
|
222
226
|
|
223
|
-
@
|
227
|
+
@contributor = (args[:contributor] || []).map do |c|
|
224
228
|
if c.is_a? Hash
|
225
229
|
e = c[:entity].is_a?(Hash) ? Organization.new(c[:entity]) : c[:entity]
|
226
|
-
ContributionInfo.new(entity: e, role: c[:
|
230
|
+
ContributionInfo.new(entity: e, role: c[:role])
|
227
231
|
else c
|
228
232
|
end
|
229
233
|
end
|
@@ -250,7 +254,7 @@ module RelatonBib
|
|
250
254
|
@language = args.fetch :language, []
|
251
255
|
@script = args.fetch :script, []
|
252
256
|
@status = args[:docstatus]
|
253
|
-
@
|
257
|
+
@relation = DocRelationCollection.new(args[:relation] || [])
|
254
258
|
@link = args.fetch(:link, []).map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s }
|
255
259
|
@series = args.fetch :series, []
|
256
260
|
@medium = args[:medium]
|
@@ -290,7 +294,7 @@ module RelatonBib
|
|
290
294
|
|
291
295
|
# @return [String]
|
292
296
|
def shortref(identifier, **opts)
|
293
|
-
pubdate =
|
297
|
+
pubdate = date.select { |d| d.type == "published" }
|
294
298
|
year = if opts[:no_year] || pubdate.empty? then ""
|
295
299
|
else ":" + pubdate&.first&.on&.year.to_s
|
296
300
|
end
|
@@ -328,8 +332,8 @@ module RelatonBib
|
|
328
332
|
link.each { |s| s.to_xml builder }
|
329
333
|
docidentifier.each { |di| di.to_xml builder }
|
330
334
|
builder.docnumber docnumber if docnumber
|
331
|
-
|
332
|
-
|
335
|
+
date.each { |d| d.to_xml builder, **opts }
|
336
|
+
contributor.each do |c|
|
333
337
|
builder.contributor do
|
334
338
|
c.role.each { |r| r.to_xml builder }
|
335
339
|
c.to_xml builder
|
@@ -343,7 +347,7 @@ module RelatonBib
|
|
343
347
|
abstract.each { |a| builder.abstract { a.to_xml(builder) } }
|
344
348
|
status&.to_xml builder
|
345
349
|
copyright&.to_xml builder
|
346
|
-
|
350
|
+
relation.each { |r| r.to_xml builder, **opts }
|
347
351
|
series.each { |s| s.to_xml builder }
|
348
352
|
medium&.to_xml builder
|
349
353
|
place.each { |pl| builder.place pl }
|
@@ -6,14 +6,14 @@ require "relaton_bib/person"
|
|
6
6
|
module RelatonBib
|
7
7
|
class << self
|
8
8
|
def contributors_hash_to_bib(ret)
|
9
|
-
return unless ret[:
|
10
|
-
ret[:
|
11
|
-
ret[:
|
12
|
-
ret[:
|
13
|
-
ret[:
|
9
|
+
return unless ret[:contributor]
|
10
|
+
ret[:contributor] = array(ret[:contributor])
|
11
|
+
ret[:contributor]&.each_with_index do |c, i|
|
12
|
+
ret[:contributor][i][:role] = array(ret[:contributor][i][:role])
|
13
|
+
ret[:contributor][i][:entity] = c[:person] ?
|
14
14
|
person_hash_to_bib(c[:person]) : org_hash_to_bib(c[:organization])
|
15
|
-
ret[:
|
16
|
-
ret[:
|
15
|
+
ret[:contributor][i].delete(:person)
|
16
|
+
ret[:contributor][i].delete(:organization)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -18,8 +18,8 @@ module RelatonBib
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def contacts_hash_to_bib(c)
|
21
|
-
return [] unless c[:
|
22
|
-
array(c[:
|
21
|
+
return [] unless c[:contact]
|
22
|
+
array(c[:contact]).map do |a|
|
23
23
|
(a[:city] || a[:country]) ?
|
24
24
|
RelatonBib::Address.new(
|
25
25
|
street: Array(a[:street]), city: a[:city], postcode: a[:postcode],
|
@@ -125,13 +125,13 @@ module RelatonBib
|
|
125
125
|
attr_reader :uri
|
126
126
|
|
127
127
|
# @return [Array<RelatonBib::Address, RelatonBib::Phone>]
|
128
|
-
attr_reader :
|
128
|
+
attr_reader :contact
|
129
129
|
|
130
130
|
# @param url [String]
|
131
|
-
# @param
|
132
|
-
def initialize(url: nil,
|
131
|
+
# @param contact [Array<RelatonBib::Address, RelatonBib::Phone>]
|
132
|
+
def initialize(url: nil, contact: [])
|
133
133
|
@uri = URI url if url
|
134
|
-
@
|
134
|
+
@contact = contact
|
135
135
|
end
|
136
136
|
|
137
137
|
# Returns url.
|
@@ -142,7 +142,7 @@ module RelatonBib
|
|
142
142
|
|
143
143
|
# @params builder [Nokogiri::XML::Builder]
|
144
144
|
def to_xml(builder)
|
145
|
-
|
145
|
+
contact.each { |contact| contact.to_xml builder }
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
@@ -13,25 +13,25 @@ module RelatonBib
|
|
13
13
|
# end
|
14
14
|
class << self
|
15
15
|
def relations_hash_to_bib(ret)
|
16
|
-
return unless ret[:
|
17
|
-
ret[:
|
18
|
-
ret[:
|
16
|
+
return unless ret[:relation]
|
17
|
+
ret[:relation] = array(ret[:relation])
|
18
|
+
ret[:relation]&.each_with_index do |r, i|
|
19
19
|
relation_bibitem_hash_to_bib(ret, r, i)
|
20
20
|
relation_biblocality_hash_to_bib(ret, r, i)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def relation_bibitem_hash_to_bib(ret, r, i)
|
25
|
-
if r[:bibitem] then ret[:
|
25
|
+
if r[:bibitem] then ret[:relation][i][:bibitem] =
|
26
26
|
BibliographicItem.new(hash_to_bib(r[:bibitem], true))
|
27
27
|
else
|
28
28
|
warn "bibitem missing: #{r}"
|
29
|
-
ret[:
|
29
|
+
ret[:relation][i][:bibitem] = nil
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
def relation_biblocality_hash_to_bib(ret, r, i)
|
34
|
-
ret[:
|
34
|
+
ret[:relation][i][:bib_locality] =
|
35
35
|
array(r[:bib_locality])&.map do |bl|
|
36
36
|
BibItemLocality.new(bl[:type], bl[:reference_from],
|
37
37
|
bl[:reference_to])
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RelatonBib
|
4
|
-
# Document
|
4
|
+
# Document relation collection
|
5
5
|
class DocRelationCollection < Array
|
6
|
-
# @param
|
7
|
-
# @option
|
8
|
-
# @option
|
9
|
-
# @option
|
10
|
-
# @option
|
11
|
-
# @option
|
12
|
-
def initialize(
|
13
|
-
super
|
6
|
+
# @param relation [Array<RelatonBib::DocumentRelation, Hash>]
|
7
|
+
# @option relation [String] :type
|
8
|
+
# @option relation [String] :identifier
|
9
|
+
# @option relation [String, NIllClass] :url (nil)
|
10
|
+
# @option relation [Array<RelatonBib::BibItemLocality>] :bib_locality
|
11
|
+
# @option relation [RelatonBib::BibliographicItem, NillClass] :bibitem (nil)
|
12
|
+
def initialize(relation)
|
13
|
+
super relation.map { |r| r.is_a?(Hash) ? DocumentRelation.new(r) : r }
|
14
14
|
end
|
15
15
|
|
16
16
|
# @return [Array<RelatonBib::DocumentRelation>]
|
@@ -6,7 +6,7 @@ module RelatonBib
|
|
6
6
|
class << self
|
7
7
|
def org_hash_to_bib(c)
|
8
8
|
return nil if c.nil?
|
9
|
-
c[:
|
9
|
+
c[:identifier] = array(c[:identifier])&.map do |a|
|
10
10
|
OrgIdentifier.new(a[:type], a[:id])
|
11
11
|
end
|
12
12
|
c
|
@@ -58,7 +58,7 @@ module RelatonBib
|
|
58
58
|
attr_reader :subdivision
|
59
59
|
|
60
60
|
# @return [Array<RelatonBib::OrgIdentifier>]
|
61
|
-
attr_reader :
|
61
|
+
attr_reader :identifier
|
62
62
|
|
63
63
|
def hash2locstr(name)
|
64
64
|
name.is_a?(Hash) ?
|
@@ -70,12 +70,12 @@ module RelatonBib
|
|
70
70
|
# @param abbreviation [RelatoBib::LocalizedStrig, String]
|
71
71
|
# @param subdivision [RelatoBib::LocalizedStrig, String]
|
72
72
|
# @param url [String]
|
73
|
-
# @param
|
74
|
-
# @param
|
73
|
+
# @param identifier [Array<RelatonBib::OrgIdentifier>]
|
74
|
+
# @param contact [Array<RelatonBib::Address, RelatonBib::Phone>]
|
75
75
|
def initialize(**args)
|
76
76
|
raise ArgumentError, "missing keyword: name" unless args[:name]
|
77
77
|
|
78
|
-
super(url: args[:url],
|
78
|
+
super(url: args[:url], contact: args.fetch(:contact, []))
|
79
79
|
|
80
80
|
@name = if args[:name].is_a?(Array)
|
81
81
|
args[:name].map { |n| hash2locstr(n) }
|
@@ -95,7 +95,7 @@ module RelatonBib
|
|
95
95
|
args[:subdivision]
|
96
96
|
end
|
97
97
|
|
98
|
-
@
|
98
|
+
@identifier = args.fetch(:identifier, [])
|
99
99
|
end
|
100
100
|
|
101
101
|
# @param builder [Nokogiri::XML::Builder]
|
@@ -107,7 +107,7 @@ module RelatonBib
|
|
107
107
|
builder.subdivision { |s| subdivision.to_xml s } if subdivision
|
108
108
|
builder.abbreviation { |a| abbreviation.to_xml a } if abbreviation
|
109
109
|
builder.uri url if uri
|
110
|
-
|
110
|
+
identifier.each { |identifier| identifier.to_xml builder }
|
111
111
|
super
|
112
112
|
end
|
113
113
|
end
|
data/lib/relaton_bib/person.rb
CHANGED
@@ -8,17 +8,17 @@ module RelatonBib
|
|
8
8
|
Person.new(
|
9
9
|
name: fullname_hash_to_bib(c),
|
10
10
|
affiliation: affiliation_hash_to_bib(c),
|
11
|
-
|
12
|
-
|
11
|
+
contact: contacts_hash_to_bib(c),
|
12
|
+
identifier: person_identifiers_hash_to_bib(c),
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
16
|
def fullname_hash_to_bib(c)
|
17
17
|
n = c[:name]
|
18
18
|
FullName.new(
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
forename: array(n[:forename])&.map { |f| localname(f, c) },
|
20
|
+
initial: array(n[:initial])&.map { |f| localname(f, c) },
|
21
|
+
addition: array(n[:addition])&.map { |f| localname(f, c) },
|
22
22
|
prefix: array(n[:prefix])&.map { |f| localname(f, c) },
|
23
23
|
surname: localname(n[:surname], c),
|
24
24
|
completename: localname(n[:completename], c),
|
@@ -26,7 +26,7 @@ module RelatonBib
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def person_identifiers_hash_to_bib(c)
|
29
|
-
array(c[:
|
29
|
+
array(c[:identifier])&.map do |a|
|
30
30
|
PersonIdentifier.new(a[:type], a[:id])
|
31
31
|
end
|
32
32
|
end
|
@@ -35,16 +35,16 @@ module RelatonBib
|
|
35
35
|
# Person's full name
|
36
36
|
class FullName
|
37
37
|
# @return [Array<RelatonBib::LocalizedString>]
|
38
|
-
attr_accessor :
|
38
|
+
attr_accessor :forename
|
39
39
|
|
40
40
|
# @return [Array<RelatonBib::LocalizedString>]
|
41
|
-
attr_accessor :
|
41
|
+
attr_accessor :initial
|
42
42
|
|
43
43
|
# @return [RelatonBib::LocalizedString]
|
44
44
|
attr_accessor :surname
|
45
45
|
|
46
46
|
# @return [Array<RelatonBib::LocalizedString>]
|
47
|
-
attr_accessor :
|
47
|
+
attr_accessor :addition
|
48
48
|
|
49
49
|
# @return [Array<RelatonBib::LocalizedString>]
|
50
50
|
attr_accessor :prefix
|
@@ -53,9 +53,9 @@ module RelatonBib
|
|
53
53
|
attr_reader :completename
|
54
54
|
|
55
55
|
# @param surname [RelatonBib::LocalizedString]
|
56
|
-
# @param
|
57
|
-
# @param
|
58
|
-
# @param
|
56
|
+
# @param forename [Array<RelatonBib::LocalizedString>]
|
57
|
+
# @param initial [Array<RelatonBib::LocalizedString>]
|
58
|
+
# @param addition [Array<RelatonBib::LocalizedString>]
|
59
59
|
# @param prefix [Array<RelatonBib::LocalizedString>]
|
60
60
|
# @param completename [RelatonBib::LocalizedString]
|
61
61
|
def initialize(**args)
|
@@ -64,9 +64,9 @@ module RelatonBib
|
|
64
64
|
end
|
65
65
|
|
66
66
|
@surname = args[:surname]
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
67
|
+
@forename = args.fetch :forename, []
|
68
|
+
@initial = args.fetch :initial, []
|
69
|
+
@addition = args.fetch :addition, []
|
70
70
|
@prefix = args.fetch :prefix, []
|
71
71
|
@completename = args[:completename]
|
72
72
|
end
|
@@ -78,10 +78,10 @@ module RelatonBib
|
|
78
78
|
builder.completename { completename.to_xml builder }
|
79
79
|
else
|
80
80
|
prefix.each { |p| builder.prefix { p.to_xml builder } }
|
81
|
-
|
82
|
-
|
81
|
+
initial.each { |i| builder.initial { i.to_xml builder } }
|
82
|
+
addition.each { |a| builder.addition { a.to_xml builder } }
|
83
83
|
builder.surname { surname.to_xml builder }
|
84
|
-
|
84
|
+
forename.each { |f| builder.forename { f.to_xml builder } }
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -134,17 +134,17 @@ module RelatonBib
|
|
134
134
|
attr_accessor :affiliation
|
135
135
|
|
136
136
|
# @return [Array<RelatonBib::PersonIdentifier>]
|
137
|
-
attr_accessor :
|
137
|
+
attr_accessor :identifier
|
138
138
|
|
139
139
|
# @param name [RelatonBib::FullName]
|
140
140
|
# @param affiliation [Array<RelatonBib::Affiliation>]
|
141
|
-
# @param
|
142
|
-
# @param
|
143
|
-
def initialize(name:, affiliation: [],
|
144
|
-
super(
|
141
|
+
# @param contact [Array<RelatonBib::Address, RelatonBib::Phone>]
|
142
|
+
# @param identifier [Array<RelatonBib::PersonIdentifier>]
|
143
|
+
def initialize(name:, affiliation: [], contact: [], identifier: [])
|
144
|
+
super(contact: contact)
|
145
145
|
@name = name
|
146
146
|
@affiliation = affiliation
|
147
|
-
@
|
147
|
+
@identifier = identifier
|
148
148
|
end
|
149
149
|
|
150
150
|
# @param builder [Nokogiri::XML::Builder]
|
@@ -152,8 +152,8 @@ module RelatonBib
|
|
152
152
|
builder.person do
|
153
153
|
name.to_xml builder
|
154
154
|
affiliation.each { |a| a.to_xml builder }
|
155
|
-
|
156
|
-
|
155
|
+
identifier.each { |id| id.to_xml builder }
|
156
|
+
contact.each { |contact| contact.to_xml builder }
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -19,13 +19,13 @@ module RelatonBib
|
|
19
19
|
id: bibitem[:id]&.empty? ? nil : bibitem[:id],
|
20
20
|
type: bibitem[:type]&.empty? ? nil : bibitem[:type],
|
21
21
|
fetched: bibitem.at("./fetched")&.text,
|
22
|
-
|
22
|
+
title: fetch_titles(bibitem),
|
23
23
|
formattedref: fref(bibitem),
|
24
24
|
link: fetch_link(bibitem),
|
25
25
|
docid: fetch_docid(bibitem),
|
26
26
|
docnumber: bibitem.at("./docnumber")&.text,
|
27
|
-
|
28
|
-
|
27
|
+
date: fetch_dates(bibitem),
|
28
|
+
contributor: fetch_contributors(bibitem),
|
29
29
|
edition: bibitem.at("./edition")&.text,
|
30
30
|
version: fetch_version(bibitem),
|
31
31
|
biblionote: fetch_note(bibitem),
|
@@ -34,7 +34,7 @@ module RelatonBib
|
|
34
34
|
abstract: fetch_abstract(bibitem),
|
35
35
|
docstatus: fetch_status(bibitem),
|
36
36
|
copyright: fetch_copyright(bibitem),
|
37
|
-
|
37
|
+
relation: fetch_relations(bibitem),
|
38
38
|
series: fetch_series(bibitem),
|
39
39
|
medium: fetch_medium(bibitem),
|
40
40
|
place: bibitem.xpath("./place").map(&:text),
|
@@ -165,14 +165,14 @@ module RelatonBib
|
|
165
165
|
names = org.xpath("name").map do |n|
|
166
166
|
{ content: n.text, language: n[:language], script: n[:script] }
|
167
167
|
end
|
168
|
-
|
168
|
+
identifier = org.xpath("./identifier").map do |i|
|
169
169
|
OrgIdentifier.new(i[:type], i.text)
|
170
170
|
end
|
171
171
|
Organization.new(name: names,
|
172
172
|
abbreviation: org.at("abbreviation")&.text,
|
173
173
|
subdivision: org.at("subdivision")&.text,
|
174
174
|
url: org.at("uri")&.text,
|
175
|
-
|
175
|
+
identifier: identifier)
|
176
176
|
end
|
177
177
|
|
178
178
|
def get_person(person)
|
@@ -181,22 +181,22 @@ module RelatonBib
|
|
181
181
|
Affilation.new get_org(org)
|
182
182
|
end
|
183
183
|
|
184
|
-
|
185
|
-
if
|
186
|
-
streets =
|
184
|
+
contact = person.xpath("./address | ./phone | ./email | ./uri").map do |c|
|
185
|
+
if c.name == "address"
|
186
|
+
streets = c.xpath("./street").map(&:text)
|
187
187
|
Address.new(
|
188
188
|
street: streets,
|
189
|
-
city:
|
190
|
-
state:
|
191
|
-
country:
|
192
|
-
postcode:
|
189
|
+
city: c.at("./city").text,
|
190
|
+
state: c.at("./state").text,
|
191
|
+
country: c.at("./country").text,
|
192
|
+
postcode: c.at("./postcode").text,
|
193
193
|
)
|
194
194
|
else
|
195
|
-
Contact.new(type:
|
195
|
+
Contact.new(type: c.name, value: c.text)
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
|
199
|
+
identifier = person.xpath("./identifier").map do |pi|
|
200
200
|
PersonIdentifier.new pi[:type], pi.text
|
201
201
|
end
|
202
202
|
|
@@ -212,15 +212,15 @@ module RelatonBib
|
|
212
212
|
|
213
213
|
name = FullName.new(
|
214
214
|
completename: cname, surname: sname,
|
215
|
-
|
216
|
-
|
215
|
+
initial: name_part(person, "initial"), forename: name_part(person, "forename"),
|
216
|
+
addition: name_part(person, "addition"), prefix: name_part(person, "prefix")
|
217
217
|
)
|
218
218
|
|
219
219
|
Person.new(
|
220
220
|
name: name,
|
221
221
|
affiliation: affilations,
|
222
|
-
|
223
|
-
|
222
|
+
contact: contact,
|
223
|
+
identifier: identifier,
|
224
224
|
)
|
225
225
|
end
|
226
226
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|