relaton-bib 1.13.10 → 1.13.12

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: b689b96d8bc90ca647a1e11528aea5b02ae148d5a2b319a44f5739567312dc61
4
- data.tar.gz: aafa8e3c0c37a5d1719b69bd9fdef15060176408790c9f742d8c48a209781391
3
+ metadata.gz: f6ddb62c2750bc1f862980dfbe3c66e6e97db50b00550c794e1a9366265854e2
4
+ data.tar.gz: b170e48789567d8b97cb8f969a3afa6785e52ff5e0883a34f80ff09e52884cda
5
5
  SHA512:
6
- metadata.gz: 4a39467d46ffcb67009b4c1e048ef6b11fcfec9c45db3c570b4759600bb920da2bb9060dc0e6c32f313c96fb2e66720cc7c7cdb93ad587542547af4da4b9631b
7
- data.tar.gz: c1cfb779ede8f36cb8502fea7a074cbb8e530c41df10b6d827175dec6392810be15ebbd37bfda667250541a5f2571dbb4ab8aea2419af0b99914bf182b887a39
6
+ metadata.gz: 3a6125762169389c71b9c51ebc27e5a180d66281e5e634584167b3d210b129ae4771a4c624e12b4a90e4318da0278a4e6279e2926298a6026d549b69fe5b3497
7
+ data.tar.gz: 2fa41a845a293c0e8cc6ab5bd4720906b59290a700349c03a6af4d705610ddb9d4b115d8726d7de634f8421b569d8091a8e6c05530747f5f0fa79552cc56fe23
@@ -35,12 +35,12 @@ 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
- conversation misc].freeze
43
+ conversation misc internal].freeze
44
44
 
45
45
  # @return [Boolean, nil]
46
46
  attr_accessor :all_parts
@@ -204,7 +204,7 @@ module RelatonBib
204
204
  # @option link [String] :content
205
205
  def initialize(**args)
206
206
  if args[:type] && !TYPES.include?(args[:type])
207
- warn %{[relaton-bib] document type "#{args[:type]}" is invalid.}
207
+ warn %{[relaton-bib] WARNING: type "#{args[:type]}" is invalid.}
208
208
  end
209
209
 
210
210
  @title = if args[:title].is_a?(TypedTitleStringCollection)
@@ -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,63 +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 self::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)] }
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")))
254
235
  end
255
236
 
256
237
  # @param contrib [Nokogiri::XML::Element]
257
- # @return [Array<Hash{Symbol=>RelatonBib::Organization,
258
- # Symbol=>Array<String>}>]
238
+ # @return [RelatonBib::Organization, nil]
259
239
  def organization(contrib)
260
240
  org = contrib.at("./organization")
261
241
  orgname = org.text.strip
262
242
  return if orgname.empty?
263
243
 
264
244
  name = ORGNAMES[orgname] || orgname
265
- { entity: new_org(name, org[:abbrev]), role: [contributor_role(contrib)] }
266
- # end
245
+ new_org name, org[:abbrev]
267
246
  end
268
247
 
269
- # @param author [Nokogiri::XML::Element]
270
- # @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
271
252
  # @return [RelatonBib::FullName]
272
- def full_name(author, reference)
273
- lang = language reference
274
- 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
275
255
  FullName.new(
276
- completename: localized_string(author[:fullname], lang),
277
- initials: initials, forename: forename(author[:initials], lang),
278
- surname: localized_string(author[:surname], lang)
256
+ completename: localized_string(fname, lang), initials: initials,
257
+ forename: forename(inits, lang), surname: localized_string(sname, lang)
279
258
  )
280
259
  end
281
260
 
@@ -287,11 +266,11 @@ module RelatonBib
287
266
  #
288
267
  # @return [Array<RelatonBib::Forename>] forenames
289
268
  #
290
- def forename(initials, lang)
269
+ def forename(initials, lang = nil, script = nil)
291
270
  return [] unless initials
292
271
 
293
272
  initials.split(/\.-?\s?|\s/).map do |i|
294
- Forename.new(initial: i, language: lang)
273
+ Forename.new(initial: i, language: lang, script: script)
295
274
  end
296
275
  end
297
276
 
@@ -314,9 +293,10 @@ module RelatonBib
314
293
 
315
294
  # @param content [String, nil]
316
295
  # @param lang [String, nil]
296
+ # @param script [String, nil]
317
297
  # @return [RelatonBib::LocalizedString, nil]
318
- def localized_string(content, lang)
319
- LocalizedString.new(content, lang) if content
298
+ def localized_string(content, lang, script = nil)
299
+ LocalizedString.new(content, lang, script) if content
320
300
  end
321
301
 
322
302
  # @param postal [Nokogiri::XML::Element]
@@ -46,13 +46,10 @@ module RelatonBib
46
46
 
47
47
  # @return [Hash, String]
48
48
  def to_hash
49
- if description&.any?
50
- hash = { "description" => single_element_array(description) }
51
- hash["type"] = type if type
52
- hash
53
- elsif type
54
- type
55
- end
49
+ hash = {}
50
+ hash["description"] = description.map(&:to_hash) if description&.any?
51
+ hash["type"] = type if type
52
+ hash
56
53
  end
57
54
 
58
55
  # @param prefix [String]
@@ -6,10 +6,10 @@ module RelatonBib
6
6
  # @return [Date]
7
7
  attr_reader :from
8
8
 
9
- # @return [Date, NilClass]
9
+ # @return [Date, nil]
10
10
  attr_reader :to
11
11
 
12
- # @return [String, NilClass]
12
+ # @return [String, nil]
13
13
  attr_reader :scope
14
14
 
15
15
  # @return [Array<RelatonBib::ContributionInfo>]
@@ -22,8 +22,8 @@ module RelatonBib
22
22
  # @option owner [String] :abbreviation
23
23
  # @option owner [String] :url
24
24
  # @param from [String] date
25
- # @param to [String, NilClass] date
26
- # @param scope [String, NilClass]
25
+ # @param to [String, nil] date
26
+ # @param scope [String, nil]
27
27
  def initialize(owner:, from:, to: nil, scope: nil)
28
28
  unless owner.any?
29
29
  raise ArgumentError, "at least one owner should exist."
@@ -67,7 +67,7 @@ module RelatonBib
67
67
  # @param count [Iteger] number of copyright elements
68
68
  # @return [String]
69
69
  def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
70
- pref = prefix.empty? ? "copyright" : prefix + ".copyright"
70
+ pref = prefix.empty? ? "copyright" : "#{prefix}.copyright"
71
71
  out = count > 1 ? "#{pref}::\n" : ""
72
72
  owner.each { |ow| out += ow.to_asciibib "#{pref}.owner", owner.size }
73
73
  out += "#{pref}.from:: #{from.year}\n" if from
@@ -37,13 +37,9 @@ module RelatonBib
37
37
  #
38
38
  def to_hash
39
39
  ls = super
40
- # if initial
41
40
  hash = ls.is_a?(Hash) ? ls : { "content" => ls }
42
41
  hash["initial"] = initial if initial
43
42
  hash
44
- # else
45
- # ls
46
- # end
47
43
  end
48
44
 
49
45
  #
@@ -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
@@ -52,7 +52,7 @@ module RelatonBib
52
52
  # @return [Array<RelatonBib::LocalizedString>]
53
53
  attr_reader :name
54
54
 
55
- # @return [RelatonBib::LocalizedString, NilClass]
55
+ # @return [RelatonBib::LocalizedString, nil]
56
56
  attr_reader :abbreviation
57
57
 
58
58
  # @return [Array<RelatonBib::LocalizedString>]
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.13.10".freeze
2
+ VERSION = "1.13.12".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.10
4
+ version: 1.13.12
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-10-17 00:00:00.000000000 Z
11
+ date: 2022-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug