relaton-bib 1.13.9 → 1.13.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50d370dad5e6a20ef5eaaed6633e0d62d80c0087f8a24d205dcb02723c025b35
4
- data.tar.gz: 7ef8d3f6530096ed1e15bc66f148a3972490e39ba3c51bfc894a31cab8195d4f
3
+ metadata.gz: 73b4305723e6d28afdb0f4dc7b5037abd284b3cf495704c89ee9be2ff16421eb
4
+ data.tar.gz: a7da23375b0d336259e602a24bc807e5f64f9d07a3b6d090d0d9c2e7ca7e28f5
5
5
  SHA512:
6
- metadata.gz: 305a89bc3529accd1087f9e7928172bacf6acb4672fa0215ee1b27406cca08cda484470227625c94928f5be4ac0766cd0b13b43059c0328b3f9d0ba03f6ad0af
7
- data.tar.gz: 44e3711a83e329cba17baabbaacecc03736eef8c20857aac71c760bcfd7289071b1d2a60b70d0d9710d132c02c0607c0ad234522ee280b6867f1bf7fba69bed1
6
+ metadata.gz: c2c7c852ceac5da96237e9de8346269ad7ca3b8a8984915efac66df93507dbb7a16b8652ae84628019195d657a16dfc9c94d472b36c6bb8fd8efc05f1e614cac
7
+ data.tar.gz: cc5f8ba67a8d9c9563674c1e90f662c05feb82453ed939ea1f47a82ee2abc3887958119345f402918ca91f3ac5b6dfe829507f52ad65e955ef038cc3f23d7aff
@@ -35,10 +35,10 @@ module RelatonBib
35
35
  class BibliographicItem
36
36
  include RelatonBib
37
37
 
38
- TYPES = %W[article book booklet conference manual proceedings presentation
38
+ TYPES = %W[article book booklet manual proceedings presentation
39
39
  thesis techreport standard unpublished map electronic\sresource
40
- audiovisual film video broadcast graphic_work music patent
41
- inbook incollection inproceedings journal software website
40
+ audiovisual film video broadcast software graphic_work music
41
+ patent inbook incollection inproceedings journal website
42
42
  webresource dataset archival social_media alert message
43
43
  conversation misc].freeze
44
44
 
@@ -1039,18 +1039,18 @@ module RelatonBib
1039
1039
  # @param [Nokogiri::XML::Builder] builder xml builder
1040
1040
  # @param [RelatonBib::Organization] org organization
1041
1041
  #
1042
- def render_organization(builder, org, role = []) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/AbcSize
1043
- ab = org&.abbreviation&.content
1044
- on = org&.name&.first&.content
1045
- orgname = if BibXMLParser::ORGNAMES.key?(ab) then ab
1046
- else BibXMLParser::ORGNAMES.key(on) || on || ab
1042
+ def render_organization(builder, org, _role = []) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/AbcSize
1043
+ abbrev = org&.abbreviation&.content
1044
+ orgname = org&.name&.first&.content
1045
+ orgname = if BibXMLParser::ORGNAMES.key?(abbrev) then abbrev
1046
+ else BibXMLParser::ORGNAMES.key(orgname) || orgname || abbrev
1047
1047
  end
1048
- if role.detect { |r| r.description.detect { |d| d.content == "BibXML author" } }
1049
- builder.parent[:fullname] = orgname
1050
- else
1051
- o = builder.organization orgname
1052
- o[:abbrev] = ab if ab
1053
- end
1048
+ # if role.detect { |r| r.description.detect { |d| d.content == "BibXML author" } }
1049
+ # builder.parent[:fullname] = orgname
1050
+ # else
1051
+ org = builder.organization orgname
1052
+ org[:abbrev] = abbrev if abbrev
1053
+ # end
1054
1054
  end
1055
1055
  end
1056
1056
  end
@@ -12,11 +12,6 @@ module RelatonBib
12
12
  "3GPP" => "3rd Generation Partnership Project",
13
13
  }.freeze
14
14
 
15
- FULLNAMEORG = [
16
- "IAB", "Internet Architecture Board", "IAB and IESG", "IESG",
17
- "IAB Advisory Committee", "Internet Engineering Steering Group"
18
- ].freeze
19
-
20
15
  #
21
16
  # Parse BibXML content
22
17
  #
@@ -219,64 +214,47 @@ module RelatonBib
219
214
  # @param reference [Nokogiri::XML::Element]
220
215
  # @return [Array<Hash>]
221
216
  def contributors(reference)
217
+ lang = language reference
222
218
  reference.xpath("./front/author").map do |contrib|
223
- full_name_org(contrib) || person(contrib, reference) || organization(contrib)
224
- end.compact
225
- end
219
+ entity = person(contrib, lang) || organization(contrib)
220
+ next unless entity
226
221
 
227
- #
228
- # Parse organization from author element
229
- #
230
- # @param [Nokogiri::XML::Element] contrib author element
231
- #
232
- # @return [Hash] contribution info
233
- #
234
- def full_name_org(contrib)
235
- return unless FULLNAMEORG.include? contrib[:fullname]
236
-
237
- role = contributor_role(contrib)
238
- role[:description] = ["BibXML author"]
239
- { entity: new_org(contrib[:fullname]), role: [role] }
222
+ { entity: entity, role: [contributor_role(contrib)] }
223
+ end.compact
240
224
  end
241
225
 
242
226
  # @param author [Nokogiri::XML::Element]
243
- # @param reference [Nokogiri::XML::Element]
244
- # @return [Array<Hash{Symbol=>RelatonBib::Person,Symbol=>Array<String>}>]
245
- def person(author, reference)
227
+ # @param lang [String]
228
+ # @return [RelatonBib::Person, nil]
229
+ def person(author, lang)
246
230
  return unless author[:fullname] || author[:surname]
247
231
 
248
- entity = Person.new(
249
- name: full_name(author, reference),
250
- affiliation: affiliation(author),
251
- contact: contacts(author.at("./address")),
252
- )
253
- { entity: entity, role: [contributor_role(author)] }
254
- # end
232
+ name = full_name(author[:fullname], author[:surname], author[:initials], lang)
233
+ Person.new(name: name, affiliation: affiliation(author),
234
+ contact: contacts(author.at("./address")))
255
235
  end
256
236
 
257
237
  # @param contrib [Nokogiri::XML::Element]
258
- # @return [Array<Hash{Symbol=>RelatonBib::Organization,
259
- # Symbol=>Array<String>}>]
238
+ # @return [RelatonBib::Organization, nil]
260
239
  def organization(contrib)
261
240
  org = contrib.at("./organization")
262
241
  orgname = org.text.strip
263
242
  return if orgname.empty?
264
243
 
265
244
  name = ORGNAMES[orgname] || orgname
266
- { entity: new_org(name, org[:abbrev]), role: [contributor_role(contrib)] }
267
- # end
245
+ new_org name, org[:abbrev]
268
246
  end
269
247
 
270
- # @param author [Nokogiri::XML::Element]
271
- # @param reference [Nokogiri::XML::Element]
248
+ # @param fname [String] full name
249
+ # @param sname [String] surname
250
+ # @param inits [String] initials
251
+ # @param lang [String] language
272
252
  # @return [RelatonBib::FullName]
273
- def full_name(author, reference)
274
- lang = language reference
275
- initials = localized_string(author[:initials], lang) if author[:initials]
253
+ def full_name(fname, sname, inits, lang)
254
+ initials = localized_string(inits, lang) if inits
276
255
  FullName.new(
277
- completename: localized_string(author[:fullname], lang),
278
- initials: initials, forename: forename(author[:initials], lang),
279
- surname: localized_string(author[:surname], lang)
256
+ completename: localized_string(fname, lang), initials: initials,
257
+ forename: forename(inits, lang), surname: localized_string(sname, lang)
280
258
  )
281
259
  end
282
260
 
@@ -288,11 +266,11 @@ module RelatonBib
288
266
  #
289
267
  # @return [Array<RelatonBib::Forename>] forenames
290
268
  #
291
- def forename(initials, lang)
269
+ def forename(initials, lang = nil, script = nil)
292
270
  return [] unless initials
293
271
 
294
272
  initials.split(/\.-?\s?|\s/).map do |i|
295
- Forename.new(initial: i, language: lang)
273
+ Forename.new(initial: i, language: lang, script: script)
296
274
  end
297
275
  end
298
276
 
@@ -315,9 +293,10 @@ module RelatonBib
315
293
 
316
294
  # @param content [String, nil]
317
295
  # @param lang [String, nil]
296
+ # @param script [String, nil]
318
297
  # @return [RelatonBib::LocalizedString, nil]
319
- def localized_string(content, lang)
320
- LocalizedString.new(content, lang) if content
298
+ def localized_string(content, lang, script = nil)
299
+ LocalizedString.new(content, lang, script) if content
321
300
  end
322
301
 
323
302
  # @param postal [Nokogiri::XML::Element]
@@ -92,7 +92,7 @@ module RelatonBib
92
92
  HTMLEntities.new.encode str.dup.force_encoding("UTF-8")
93
93
  end
94
94
 
95
- # @return [Hash]
95
+ # @return [Hash, Array<Hash>]
96
96
  def to_hash # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
97
97
  if content.nil? || content.is_a?(String)
98
98
  # return content unless language || script
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.13.9".freeze
2
+ VERSION = "1.13.11".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.9
4
+ version: 1.13.11
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-09-24 00:00:00.000000000 Z
11
+ date: 2022-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug