relaton-bib 0.3.4 → 0.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee06437cee7f0efbacf8d04554136258ad4544f4
4
- data.tar.gz: 3608ad874a15aa0a7c1d2d03270dc02a2a308dfd
3
+ metadata.gz: 5c724b4c6147f9e16ec7af1ec4097134731a812a
4
+ data.tar.gz: 22c2e36e0b2f775f1e467f687b5145ab6780b915
5
5
  SHA512:
6
- metadata.gz: 45f05d3a1362dcb45a09c7a04696eb87a48094eaba7314271a519c13c85e83ddbeb85e2c6ccbad8e3f7a064a70c471dc6270684efabce3f2e09374c151fd38ad
7
- data.tar.gz: 78315011778a04275ff534780f3138bb3f6e2c2476a6f7e7f1ea3287856664dffa80fe678ed0294494a5bed0d1d331c8c1f700d939ba4a7dad813fd435de3a53
6
+ metadata.gz: ca64daeace4b61699af94a1447395fa8824f093e676587a81f7e36437dc22c9684b9fdfa2aa19f500932859ebf888f8a37f3228054a1274fab886fdcc86cfdc3
7
+ data.tar.gz: e2818b0ffce974cbac83e445d7665902696cecbe3b068727caa85065459b710a377b17156a9809150dcdf0574325ae57a7cccd1744458e60a7507907de723308
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relaton-bib (0.3.4)
4
+ relaton-bib (0.3.5)
5
5
  addressable
6
6
  nokogiri (~> 1.10)
7
7
 
@@ -1,8 +1,20 @@
1
1
  require "relaton_bib/version"
2
- require "relaton_bib/bibliographic_item.rb"
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: type, reference_from: reference_from }
49
- hash[:reference_to] = reference_to if reference_to
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
@@ -23,7 +23,10 @@ module RelatonBib
23
23
  # @return [Hash]
24
24
  def to_hash
25
25
  hash = super
26
- hash[:type] = type if type
26
+ return hash unless type
27
+
28
+ hash = { "content" => hash } if hash.is_a? String
29
+ hash["type"] = type
27
30
  hash
28
31
  end
29
32
  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[:revision_date] = revision_date if revision_date
30
- hash[:draft] = draft if draft&.any?
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: 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
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[:id] = id if id
277
- hash[:title] = title.map(&:to_hash) if title&.any?
278
- hash[:link] = link.map(&:to_hash) if link&.any?
279
- hash[:type] = type if type
280
- hash[:docid] = docidentifier.map(&:to_hash) if docidentifier&.any?
281
- hash[:docnumber] = docnumber if docnumber
282
- hash[:date] = date.map(&:to_hash) if date&.any?
283
- hash[:contributor] = contributor.map(&:to_hash) if contributor&.any?
284
- hash[:edition] = edition if edition
285
- hash[:version] = version.to_hash if version
286
- hash[:biblionote] = biblionote.map(&:to_hash) if biblionote&.any?
287
- hash[:language] = language if language&.any?
288
- hash[:script] = script if script&.any?
289
- hash[:formattedref] = formattedref.to_hash if formattedref
290
- hash[:abstract] = abstract.map(&:to_hash) if abstract&.any?
291
- hash[:docstatus] = status.to_hash if status
292
- hash[:copyright] = copyright.to_hash if copyright
293
- hash[:relation] = relation.map(&:to_hash) if relation&.any?
294
- hash[:series] = series.map(&:to_hash) if series&.any?
295
- hash[:medium] = medium.to_hash if medium
296
- hash[:place] = place if place&.any?
297
- hash[:extent] = extent.map(&:to_hash) if extent&.any?
298
- hash[:accesslocation] = accesslocation if accesslocation&.any?
299
- hash[:classification] = classification.to_hash if classification
300
- hash[:validity] = validity.to_hash if validity
301
- hash[:fetched] = fetched.to_s if fetched
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
 
@@ -21,8 +21,8 @@ module RelatonBib
21
21
 
22
22
  # @return [Hash]
23
23
  def to_hash
24
- hash = { value: value }
25
- hash[:type] = type if type
24
+ hash = { "value" => value }
25
+ hash["type"] = type if type
26
26
  hash
27
27
  end
28
28
  end
@@ -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 [ContributorRoleType]
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 [Array]
41
+ # @return [Hash, String]
41
42
  def to_hash
42
43
  if description&.any?
43
- [type, description.map(&:content)] if type
44
- else
45
- type if type
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[:role] = role.map(&:to_hash) if role&.any?
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[: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
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: type, value: value }
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[:name] = name.to_hash if name
117
- hash[:description] = description.map(&:to_hash) if description&.any?
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[:url] = uri.to_s if uri
152
- hash[:contact] = contact.map(&:to_hash) if contact&.any?
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") unless from.empty?
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: owner.to_hash[:organization], from: from.to_s }
41
- hash[:to] = to.to_s if to
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
@@ -46,8 +46,8 @@ module RelatonBib
46
46
 
47
47
  # @return [Hash]
48
48
  def to_hash
49
- hash = { id: id }
50
- hash[:type] if type
49
+ hash = { "id" => id }
50
+ hash["type"] = type if type
51
51
  hash
52
52
  end
53
53
  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: type, bibitem: bibitem.to_hash }
54
- hash[:bib_locality] = bib_locality.map(&:to_hash) if bib_locality&.any?
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: stage }
39
- hash[:substage] = substage if substage
40
- hash[:iteration] = iteration if iteration
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
@@ -34,7 +34,10 @@ module RelatonBib
34
34
  # @return [Hash]
35
35
  def to_hash
36
36
  hash = super
37
- hash[:format] = format if format
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
@@ -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])&.each_with_index do |s, i|
256
- s[:formattedref] and s[:formattedref] = formattedref(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] and
262
- s[:abbreviation] = localizedstring(s[:abbreviation])
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
- hash = { content: content }
46
- hash[:language] = language if language&.any?
47
- hash[:script] = script if script&.any?
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
@@ -24,9 +24,9 @@ module RelatonBib
24
24
  # @return [Hash]
25
25
  def to_hash
26
26
  hash = {}
27
- hash[:form] = form if form
28
- hash[:size] = size if size
29
- hash[:scale] = scale if scale
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: type, id: value }
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::LocalizedStrig, String]
66
- # @param subdivision [RelatoBib::LocalizedStrig, String]
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| hash2locstr(n) }
70
+ args[:name].map { |n| localized_string(n) }
77
71
  else
78
- [hash2locstr(args[:name])]
72
+ [localized_string(args[:name])]
79
73
  end
80
74
 
81
- @abbreviation = if args[:abbreviation].is_a?(String)
82
- LocalizedString.new(args[:abbreviation])
83
- else
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: name.map(&:to_hash) }
113
- hash[:abbreviation] = abbreviation.to_hash if abbreviation
114
- hash[:identifier] = identifier.map(&:to_hash) if identifier&.any?
115
- hash[:subdivision] = subdivision.to_hash if subdivision
116
- { organization: hash.merge(super) }
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
@@ -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[:forename] = forename.map(&:to_hash) if forename&.any?
64
- hash[:initial] = initial.map(&:to_hash) if initial&.any?
65
- hash[:surname] = surname.to_hash if surname
66
- hash[:addition] = addition.map(&:to_hash) if addition&.any?
67
- hash[:prefix] = prefix.map(&:to_hash) if prefix&.any?
68
- hash[:completename] = completename.to_hash if completename
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: type, id: value }
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: name.to_hash }
160
- hash[:affiliation] = affiliation.map(&:to_hash) if affiliation&.any?
161
- hash[:identifier] = identifier.map(&:to_hash) if identifier&.any?
162
- { person: hash.merge(super) }
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
@@ -97,16 +97,16 @@ module RelatonBib
97
97
  # @return [Hash]
98
98
  def to_hash
99
99
  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
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
@@ -46,7 +46,7 @@ module RelatonBib
46
46
  # @return [Hash]
47
47
  def to_hash
48
48
  hash = {}
49
- hash[:type] = type if type
49
+ hash["type"] = type if type
50
50
  hash.merge title.to_hash
51
51
  end
52
52
  end
@@ -22,7 +22,7 @@ module RelatonBib
22
22
 
23
23
  # @return [Hash]
24
24
  def to_hash
25
- { type: type, content: content.to_s }
25
+ { "type" => type, "content" => content.to_s }
26
26
  end
27
27
  end
28
28
  end
@@ -32,9 +32,9 @@ module RelatonBib
32
32
  # @return [Hash]
33
33
  def to_hash
34
34
  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
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
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "0.3.4".freeze
2
+ VERSION = "0.3.5".freeze
3
3
  end
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
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-13 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler