relaton-bib 1.13.0 → 1.13.1

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
  SHA256:
3
- metadata.gz: 99408aa20e1cd2228d00656949182896e8acaf845e5e223024b262b915636b8f
4
- data.tar.gz: 3fb73b6ee0381499a955f7b9c082c1a49aa9c1944d22c26ca8064ff008608bb0
3
+ metadata.gz: 86a0bd8757736f00d9823a2c7e054061070ca6a092a502f20f5598875db95aa0
4
+ data.tar.gz: c96b9564f71355be85fd8752bf93df410d71d3913e87e8463b070bcbcca7b1b1
5
5
  SHA512:
6
- metadata.gz: 0e04458e0ab8bbe38e464f84a0c3de36e4db43361efeec0246a09b476171eeb8050283b7d8ef18eeb1432505985879c30d6d9202f27f6536cd65195a4e6d9938
7
- data.tar.gz: 25241fe59416e9dad9af8b1c11579cf309194acfcbce167d603105c7264d67a744f452a0f3ee9f8fad9fa23e857d282b2ad79e17e67372f8940e21021594fb44
6
+ metadata.gz: 2c37155924af6e0a88b5c2883f439f16edeb27dbfa4114e7d3bf5fd9c1eb2e54c1c0d67a535ff0e06a9cda0a9810974de0bdecb96408d0adaeaf766fb18ac29d
7
+ data.tar.gz: 38ec500a5144b27b2dce3b6dfab3a7c76c6e936d54f4a2ec2933cb292f6aaf133471fd7b32a1521098c5bee25de789472c5ca6238c85c70310656c5ae00f3d8b
@@ -1017,7 +1017,9 @@ module RelatonBib
1017
1017
  if person.name.completename
1018
1018
  builder.parent[:fullname] = person.name.completename.content
1019
1019
  elsif person.name.forename.any?
1020
- builder.parent[:fullname] = person.name.forename.map(&:content).join
1020
+ builder.parent[:fullname] = person.name.forename.map do |n|
1021
+ n.content || n.initial
1022
+ end.join " "
1021
1023
  end
1022
1024
  if person.name.initials
1023
1025
  builder.parent[:initials] = person.name.initials.content
@@ -1027,7 +1029,7 @@ module RelatonBib
1027
1029
  end.join
1028
1030
  end
1029
1031
  if person.name.surname
1030
- if person.name.forename.any?
1032
+ if !person.name.completename && person.name.forename.any? && person.name.surname
1031
1033
  builder.parent[:fullname] += " #{person.name.surname}"
1032
1034
  end
1033
1035
  builder.parent[:surname] = person.name.surname.content
@@ -267,11 +267,27 @@ module RelatonBib
267
267
  initials = localized_string(author[:initials], lang) if author[:initials]
268
268
  FullName.new(
269
269
  completename: localized_string(author[:fullname], lang),
270
- initials: initials,
271
- surname: localized_string(author[:surname], lang),
270
+ initials: initials, forename: forename(author[:initials], lang),
271
+ surname: localized_string(author[:surname], lang)
272
272
  )
273
273
  end
274
274
 
275
+ #
276
+ # Create forenames with initials
277
+ #
278
+ # @param [String] initials initials
279
+ # @param [String] lang language
280
+ #
281
+ # @return [Array<RelatonBib::Forename>] forenames
282
+ #
283
+ def forename(initials, lang)
284
+ return [] unless initials
285
+
286
+ initials.split(/\.-?\s?|\s/).map do |i|
287
+ Forename.new(initial: i, language: lang)
288
+ end
289
+ end
290
+
275
291
  # @param author [Nokogiri::XML::Element]
276
292
  # @return [Array<RelatonBib::Affiliation>]
277
293
  def affiliation(author)
@@ -132,11 +132,11 @@ module RelatonBib
132
132
 
133
133
  # @return [Hash]
134
134
  def to_hash # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
135
- if content.is_a? String
135
+ if content.nil? || content.is_a?(String)
136
136
  # return content unless language || script
137
137
 
138
138
  hash = {}
139
- hash["content"] = content unless empty?
139
+ hash["content"] = content unless content.nil? || content.empty?
140
140
  hash["language"] = single_element_array(language) if language&.any?
141
141
  hash["script"] = single_element_array(script) if script&.any?
142
142
  hash
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.13.0".freeze
2
+ VERSION = "1.13.1".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: 1.13.0
4
+ version: 1.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-21 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug