relaton-bib 0.3.4 → 0.3.5
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/lib/relaton_bib.rb +13 -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 +4 -2
- data/lib/relaton_bib/bibliographic_date.rb +4 -4
- data/lib/relaton_bib/bibliographic_item.rb +29 -28
- 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 +4 -1
- data/lib/relaton_bib/hash_converter.rb +5 -5
- 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 +1 -1
- data/lib/relaton_bib/typed_uri.rb +1 -1
- data/lib/relaton_bib/validity.rb +3 -3
- data/lib/relaton_bib/version.rb +1 -1
- 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: 5c724b4c6147f9e16ec7af1ec4097134731a812a
|
4
|
+
data.tar.gz: 22c2e36e0b2f775f1e467f687b5145ab6780b915
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca64daeace4b61699af94a1447395fa8824f093e676587a81f7e36437dc22c9684b9fdfa2aa19f500932859ebf888f8a37f3228054a1274fab886fdcc86cfdc3
|
7
|
+
data.tar.gz: e2818b0ffce974cbac83e445d7665902696cecbe3b068727caa85065459b710a377b17156a9809150dcdf0574325ae57a7cccd1744458e60a7507907de723308
|
data/Gemfile.lock
CHANGED
data/lib/relaton_bib.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
require "relaton_bib/version"
|
2
|
-
require "relaton_bib/bibliographic_item
|
2
|
+
require "relaton_bib/bibliographic_item"
|
3
3
|
|
4
4
|
module RelatonBib
|
5
5
|
class Error < StandardError; end
|
6
6
|
|
7
7
|
class RequestError < StandardError; end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# @param array [Array]
|
12
|
+
# @return [Array<String>, String]
|
13
|
+
def single_element_array(array)
|
14
|
+
if array.size > 1
|
15
|
+
array.map { |e| e.is_a?(String) ? e : e.to_hash }
|
16
|
+
else
|
17
|
+
array[0].is_a?(String) ? array[0] : array[0].to_hash
|
18
|
+
end
|
19
|
+
end
|
8
20
|
end
|
@@ -45,9 +45,9 @@ module RelatonBib
|
|
45
45
|
|
46
46
|
# @return [Hash]
|
47
47
|
def to_hash
|
48
|
-
hash = { type
|
49
|
-
hash[
|
48
|
+
hash = { "type" => type, "reference_from" => reference_from }
|
49
|
+
hash["reference_to"] = reference_to if reference_to
|
50
50
|
hash
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
@@ -2,6 +2,8 @@ module RelatonBib
|
|
2
2
|
# Version
|
3
3
|
class BibliographicItem
|
4
4
|
class Version
|
5
|
+
include RelatonBib
|
6
|
+
|
5
7
|
# @return [String, NilClass]
|
6
8
|
attr_reader :revision_date
|
7
9
|
|
@@ -26,8 +28,8 @@ module RelatonBib
|
|
26
28
|
# @return [Hash]
|
27
29
|
def to_hash
|
28
30
|
hash = {}
|
29
|
-
hash[
|
30
|
-
hash[
|
31
|
+
hash["revision_date"] = revision_date if revision_date
|
32
|
+
hash["draft"] = single_element_array(draft) if draft&.any?
|
31
33
|
hash
|
32
34
|
end
|
33
35
|
end
|
@@ -54,10 +54,10 @@ module RelatonBib
|
|
54
54
|
|
55
55
|
# @return [Hash]
|
56
56
|
def to_hash
|
57
|
-
hash = { type
|
58
|
-
hash[
|
59
|
-
hash[
|
60
|
-
hash[
|
57
|
+
hash = { "type" => type }
|
58
|
+
hash["value"] = on.to_s if on
|
59
|
+
hash["from"] = from.to_s if from
|
60
|
+
hash["to"] = to.to_s if to
|
61
61
|
hash
|
62
62
|
end
|
63
63
|
|
@@ -26,11 +26,12 @@ require "relaton_bib/hash_converter"
|
|
26
26
|
module RelatonBib
|
27
27
|
# Bibliographic item
|
28
28
|
class BibliographicItem
|
29
|
+
include RelatonBib
|
30
|
+
|
29
31
|
TYPES = %W[article book booklet conference manual proceedings presentation
|
30
32
|
thesis techreport standard unpublished map electronic\sresource
|
31
33
|
audiovisual film video broadcast graphic_work music patent
|
32
|
-
inbook incollection inproceedings journal
|
33
|
-
].freeze
|
34
|
+
inbook incollection inproceedings journal].freeze
|
34
35
|
|
35
36
|
# @return [String, NilClass]
|
36
37
|
attr_reader :id
|
@@ -273,32 +274,32 @@ module RelatonBib
|
|
273
274
|
# @return [Hash]
|
274
275
|
def to_hash
|
275
276
|
hash = {}
|
276
|
-
hash[
|
277
|
-
hash[
|
278
|
-
hash[
|
279
|
-
hash[
|
280
|
-
hash[
|
281
|
-
hash[
|
282
|
-
hash[
|
283
|
-
hash[
|
284
|
-
hash[
|
285
|
-
hash[
|
286
|
-
hash[
|
287
|
-
hash[
|
288
|
-
hash[
|
289
|
-
hash[
|
290
|
-
hash[
|
291
|
-
hash[
|
292
|
-
hash[
|
293
|
-
hash[
|
294
|
-
hash[
|
295
|
-
hash[
|
296
|
-
hash[
|
297
|
-
hash[
|
298
|
-
hash[
|
299
|
-
hash[
|
300
|
-
hash[
|
301
|
-
hash[
|
277
|
+
hash["id"] = id if id
|
278
|
+
hash["title"] = single_element_array(title) if title&.any?
|
279
|
+
hash["link"] = single_element_array(link) if link&.any?
|
280
|
+
hash["type"] = type if type
|
281
|
+
hash["docid"] = single_element_array(docidentifier) if docidentifier&.any?
|
282
|
+
hash["docnumber"] = docnumber if docnumber
|
283
|
+
hash["date"] = single_element_array(date) if date&.any?
|
284
|
+
hash["contributor"] = single_element_array(contributor) if contributor&.any?
|
285
|
+
hash["edition"] = edition if edition
|
286
|
+
hash["version"] = version.to_hash if version
|
287
|
+
hash["biblionote"] = single_element_array(biblionote) if biblionote&.any?
|
288
|
+
hash["language"] = single_element_array(language) if language&.any?
|
289
|
+
hash["script"] = single_element_array(script) if script&.any?
|
290
|
+
hash["formattedref"] = formattedref.to_hash if formattedref
|
291
|
+
hash["abstract"] = single_element_array(abstract) if abstract&.any?
|
292
|
+
hash["docstatus"] = status.to_hash if status
|
293
|
+
hash["copyright"] = copyright.to_hash if copyright
|
294
|
+
hash["relation"] = single_element_array(relation) if relation&.any?
|
295
|
+
hash["series"] = single_element_array(series) if series&.any?
|
296
|
+
hash["medium"] = medium.to_hash if medium
|
297
|
+
hash["place"] = single_element_array(place) if place&.any?
|
298
|
+
hash["extent"] = single_element_array(extent) if extent&.any?
|
299
|
+
hash["accesslocation"] = single_element_array(accesslocation) if accesslocation&.any?
|
300
|
+
hash["classification"] = classification.to_hash if classification
|
301
|
+
hash["validity"] = validity.to_hash if validity
|
302
|
+
hash["fetched"] = fetched.to_s if fetched
|
302
303
|
hash
|
303
304
|
end
|
304
305
|
|
@@ -4,17 +4,17 @@ require "relaton_bib/person"
|
|
4
4
|
|
5
5
|
# RelatonBib module
|
6
6
|
module RelatonBib
|
7
|
-
|
8
7
|
# Contributor's role.
|
9
8
|
class ContributorRole
|
9
|
+
include RelatonBib
|
10
|
+
|
10
11
|
TYPES = %w[author performer publisher editor adapter translator
|
11
|
-
distributor
|
12
|
-
].freeze
|
12
|
+
distributor].freeze
|
13
13
|
|
14
14
|
# @return [Array<RelatonBib::FormattedString>]
|
15
15
|
attr_reader :description
|
16
16
|
|
17
|
-
# @return [
|
17
|
+
# @return [Strig]
|
18
18
|
attr_reader :type
|
19
19
|
|
20
20
|
# @param type [String] allowed types "author", "editor",
|
@@ -29,6 +29,7 @@ module RelatonBib
|
|
29
29
|
@description = args.fetch(:description, []).map { |d| FormattedString.new content: d, format: nil }
|
30
30
|
end
|
31
31
|
|
32
|
+
# @param builder [Nokogiri::XML::Builder]
|
32
33
|
def to_xml(builder)
|
33
34
|
builder.role(type: type) do
|
34
35
|
description.each do |d|
|
@@ -37,18 +38,22 @@ module RelatonBib
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
# @return [
|
41
|
+
# @return [Hash, String]
|
41
42
|
def to_hash
|
42
43
|
if description&.any?
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
hash = { "description" => single_element_array(description) }
|
45
|
+
hash["type"] = type if type
|
46
|
+
hash
|
47
|
+
elsif type
|
48
|
+
type
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
53
|
# Contribution info.
|
51
54
|
class ContributionInfo
|
55
|
+
include RelatonBib
|
56
|
+
|
52
57
|
# @return [Array<RelatonBib::ContributorRole>]
|
53
58
|
attr_reader :role
|
54
59
|
|
@@ -71,7 +76,7 @@ module RelatonBib
|
|
71
76
|
# @return [Hash]
|
72
77
|
def to_hash
|
73
78
|
hash = entity.to_hash
|
74
|
-
hash[
|
79
|
+
hash["role"] = single_element_array(role) if role&.any?
|
75
80
|
hash
|
76
81
|
end
|
77
82
|
end
|
@@ -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 : "copyright 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
|
@@ -133,6 +133,7 @@ module RelatonBib
|
|
133
133
|
|
134
134
|
def contributors_hash_to_bib(ret)
|
135
135
|
return unless ret[:contributor]
|
136
|
+
|
136
137
|
ret[:contributor] = array(ret[:contributor])
|
137
138
|
ret[:contributor]&.each_with_index do |c, i|
|
138
139
|
roles = array(ret[:contributor][i][:role]).map do |r|
|
@@ -252,15 +253,14 @@ module RelatonBib
|
|
252
253
|
end
|
253
254
|
|
254
255
|
def series_hash_to_bib(ret)
|
255
|
-
array(ret[:series])&.
|
256
|
-
s[:formattedref]
|
256
|
+
ret[:series] = array(ret[:series])&.map do |s|
|
257
|
+
s[:formattedref] && s[:formattedref] = formattedref(s[:formattedref])
|
257
258
|
if s[:title]
|
258
259
|
s[:title] = { content: s[:title] } unless s.is_a?(Hash)
|
259
260
|
s[:title] = typed_title_strig(s[:title])
|
260
261
|
end
|
261
|
-
s[:abbreviation]
|
262
|
-
|
263
|
-
ret[:series][i] = Series.new(s)
|
262
|
+
s[:abbreviation] && s[:abbreviation] = localizedstring(s[:abbreviation])
|
263
|
+
Series.new(s)
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module RelatonBib
|
4
4
|
# Localized string.
|
5
5
|
class LocalizedString
|
6
|
+
include RelatonBib
|
7
|
+
|
6
8
|
# @return [Array<String>] language Iso639 code
|
7
9
|
attr_reader :language
|
8
10
|
|
@@ -42,9 +44,11 @@ module RelatonBib
|
|
42
44
|
|
43
45
|
# @return [Hash]
|
44
46
|
def to_hash
|
45
|
-
|
46
|
-
|
47
|
-
hash
|
47
|
+
return content unless language || script
|
48
|
+
|
49
|
+
hash = { "content" => content }
|
50
|
+
hash["language"] = single_element_array(language) if language&.any?
|
51
|
+
hash["script"] = single_element_array(script) if script&.any?
|
48
52
|
hash
|
49
53
|
end
|
50
54
|
end
|
data/lib/relaton_bib/medium.rb
CHANGED
@@ -24,9 +24,9 @@ module RelatonBib
|
|
24
24
|
# @return [Hash]
|
25
25
|
def to_hash
|
26
26
|
hash = {}
|
27
|
-
hash[
|
28
|
-
hash[
|
29
|
-
hash[
|
27
|
+
hash["form"] = form if form
|
28
|
+
hash["size"] = size if size
|
29
|
+
hash["scale"] = scale if scale
|
30
30
|
hash
|
31
31
|
end
|
32
32
|
end
|
@@ -37,7 +37,7 @@ module RelatonBib
|
|
37
37
|
|
38
38
|
# @return [Hash]
|
39
39
|
def to_hash
|
40
|
-
{ type
|
40
|
+
{ "type" => type, "id" => value }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -55,15 +55,9 @@ module RelatonBib
|
|
55
55
|
# @return [Array<RelatonBib::OrgIdentifier>]
|
56
56
|
attr_reader :identifier
|
57
57
|
|
58
|
-
def hash2locstr(name)
|
59
|
-
name.is_a?(Hash) ?
|
60
|
-
LocalizedString.new(name[:content], name[:language], name[:script]) :
|
61
|
-
LocalizedString.new(name)
|
62
|
-
end
|
63
|
-
|
64
58
|
# @param name [String, Hash, Array<String, Hash>]
|
65
|
-
# @param abbreviation [RelatoBib::
|
66
|
-
# @param subdivision [RelatoBib::
|
59
|
+
# @param abbreviation [RelatoBib::LocalizedString, String]
|
60
|
+
# @param subdivision [RelatoBib::LocalizedString, String]
|
67
61
|
# @param url [String]
|
68
62
|
# @param identifier [Array<RelatonBib::OrgIdentifier>]
|
69
63
|
# @param contact [Array<RelatonBib::Address, RelatonBib::Contact>]
|
@@ -73,24 +67,14 @@ module RelatonBib
|
|
73
67
|
super(url: args[:url], contact: args.fetch(:contact, []))
|
74
68
|
|
75
69
|
@name = if args[:name].is_a?(Array)
|
76
|
-
args[:name].map { |n|
|
70
|
+
args[:name].map { |n| localized_string(n) }
|
77
71
|
else
|
78
|
-
[
|
72
|
+
[localized_string(args[:name])]
|
79
73
|
end
|
80
74
|
|
81
|
-
@abbreviation =
|
82
|
-
|
83
|
-
|
84
|
-
args[:abbreviation]
|
85
|
-
end
|
86
|
-
|
87
|
-
@subdivision = if args[:subdivision].is_a?(String)
|
88
|
-
LocalizedString.new(args[:subdivision])
|
89
|
-
else
|
90
|
-
args[:subdivision]
|
91
|
-
end
|
92
|
-
|
93
|
-
@identifier = args.fetch(:identifier, [])
|
75
|
+
@abbreviation = localized_string args[:abbreviation]
|
76
|
+
@subdivision = localized_string args[:subdivision]
|
77
|
+
@identifier = args.fetch(:identifier, [])
|
94
78
|
end
|
95
79
|
|
96
80
|
# @param builder [Nokogiri::XML::Builder]
|
@@ -109,11 +93,23 @@ module RelatonBib
|
|
109
93
|
|
110
94
|
# @return [Hash]
|
111
95
|
def to_hash
|
112
|
-
hash = { name
|
113
|
-
hash[
|
114
|
-
hash[
|
115
|
-
hash[
|
116
|
-
{ organization
|
96
|
+
hash = { "name" => single_element_array(name) }
|
97
|
+
hash["abbreviation"] = abbreviation.to_hash if abbreviation
|
98
|
+
hash["identifier"] = single_element_array(identifier) if identifier&.any?
|
99
|
+
hash["subdivision"] = subdivision.to_hash if subdivision
|
100
|
+
{ "organization" => hash.merge(super) }
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
# @param arg [String, Hash, RelatoBib::LocalizedString]
|
106
|
+
# @return [RelatoBib::LocalizedString]
|
107
|
+
def localized_string(arg)
|
108
|
+
if arg.is_a?(String) then LocalizedString.new(arg)
|
109
|
+
elsif arg.is_a?(Hash)
|
110
|
+
LocalizedString.new(arg[:content], arg[:language], arg[:script])
|
111
|
+
elsif arg.is_a? LocalizedString then arg
|
112
|
+
end
|
117
113
|
end
|
118
114
|
end
|
119
115
|
end
|
data/lib/relaton_bib/person.rb
CHANGED
@@ -5,6 +5,8 @@ require "relaton_bib/contributor"
|
|
5
5
|
module RelatonBib
|
6
6
|
# Person's full name
|
7
7
|
class FullName
|
8
|
+
include RelatonBib
|
9
|
+
|
8
10
|
# @return [Array<RelatonBib::LocalizedString>]
|
9
11
|
attr_accessor :forename
|
10
12
|
|
@@ -60,22 +62,13 @@ module RelatonBib
|
|
60
62
|
# @return [Hash]
|
61
63
|
def to_hash
|
62
64
|
hash = {}
|
63
|
-
hash[
|
64
|
-
hash[
|
65
|
-
hash[
|
66
|
-
hash[
|
67
|
-
hash[
|
68
|
-
hash[
|
65
|
+
hash["forename"] = single_element_array(forename) if forename&.any?
|
66
|
+
hash["initial"] = single_element_array(initial) if initial&.any?
|
67
|
+
hash["surname"] = surname.to_hash if surname
|
68
|
+
hash["addition"] = single_element_array(addition) if addition&.any?
|
69
|
+
hash["prefix"] = single_element_array(prefix) if prefix&.any?
|
70
|
+
hash["completename"] = completename.to_hash if completename
|
69
71
|
hash
|
70
|
-
# instance_variables.reduce({}) do |hash, var|
|
71
|
-
# val = instance_variable_get var
|
72
|
-
# if val || val.is_a?(Array) && val.any?
|
73
|
-
# key = var.to_s.sub("@", "").to_sym
|
74
|
-
# hash.merge key => val
|
75
|
-
# else
|
76
|
-
# hash
|
77
|
-
# end
|
78
|
-
# end
|
79
72
|
end
|
80
73
|
end
|
81
74
|
|
@@ -118,7 +111,7 @@ module RelatonBib
|
|
118
111
|
|
119
112
|
# @return [Hash]
|
120
113
|
def to_hash
|
121
|
-
{ type
|
114
|
+
{ "type" => type, "id" => value }
|
122
115
|
end
|
123
116
|
end
|
124
117
|
|
@@ -156,10 +149,10 @@ module RelatonBib
|
|
156
149
|
|
157
150
|
# @return [Hash]
|
158
151
|
def to_hash
|
159
|
-
hash = { name
|
160
|
-
hash[
|
161
|
-
hash[
|
162
|
-
{ person
|
152
|
+
hash = { "name" => name.to_hash }
|
153
|
+
hash["affiliation"] = single_element_array(affiliation) if affiliation&.any?
|
154
|
+
hash["identifier"] = single_element_array(identifier) if identifier&.any?
|
155
|
+
{ "person" => hash.merge(super) }
|
163
156
|
end
|
164
157
|
end
|
165
158
|
end
|
data/lib/relaton_bib/series.rb
CHANGED
@@ -97,16 +97,16 @@ module RelatonBib
|
|
97
97
|
# @return [Hash]
|
98
98
|
def to_hash
|
99
99
|
hash = {}
|
100
|
-
hash[
|
101
|
-
hash[
|
102
|
-
hash[
|
103
|
-
hash[
|
104
|
-
hash[
|
105
|
-
hash[
|
106
|
-
hash[
|
107
|
-
hash[
|
108
|
-
hash[
|
109
|
-
hash[
|
100
|
+
hash["type"] = type if type
|
101
|
+
hash["formattedref"] = formattedref.to_hash if formattedref
|
102
|
+
hash["title"] = title.to_hash if title
|
103
|
+
hash["place"] = place if place
|
104
|
+
hash["organization"] = organization if organization
|
105
|
+
hash["abbreviation"] = abbreviation.to_hash if abbreviation
|
106
|
+
hash["from"] = from if from
|
107
|
+
hash["to"] = to if to
|
108
|
+
hash["number"] = number if number
|
109
|
+
hash["partnumber"] = partnumber if partnumber
|
110
110
|
hash
|
111
111
|
end
|
112
112
|
end
|
data/lib/relaton_bib/validity.rb
CHANGED
@@ -32,9 +32,9 @@ module RelatonBib
|
|
32
32
|
# @return [Hash]
|
33
33
|
def to_hash
|
34
34
|
hash = {}
|
35
|
-
hash[
|
36
|
-
hash[
|
37
|
-
hash[
|
35
|
+
hash["begins"] = begins.strftime(FORMAT) if begins
|
36
|
+
hash["ends"] = ends.strftime(FORMAT) if ends
|
37
|
+
hash["revision"] = revision.strftime(FORMAT) if revision
|
38
38
|
hash
|
39
39
|
end
|
40
40
|
end
|
data/lib/relaton_bib/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.5
|
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-08-
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|