relaton-bib 1.9.20 → 1.9.21
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 +4 -4
- data/lib/relaton_bib/bibliographic_date.rb +13 -5
- data/lib/relaton_bib/bibliographic_item.rb +4 -4
- data/lib/relaton_bib/bibxml_parser.rb +13 -8
- data/lib/relaton_bib/contributor.rb +6 -6
- data/lib/relaton_bib/organization.rb +6 -5
- data/lib/relaton_bib/series.rb +4 -4
- data/lib/relaton_bib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcb3b3d66701b4722151be5191a2eabfb1bc1e00453051e1a903e2af8c2b30b2
|
4
|
+
data.tar.gz: eca150d7708507187a93e6cff06eda12cfeef54dc1a6ac93d8244c0db6accdaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f390c1e5e802966bc00002bf54bd1d246b45fc293188dc829940d90c32bc89db6b4e49e2ef4de14c13751c6ac6cff9692d23e558c1fe929815523f99de2a680
|
7
|
+
data.tar.gz: 404f08acad50390f9e63af5a3a30685eb7d50a085e6d98d8730277062b644f38ac5f3ab75c959a25523457bed001ef6a7f8d6dd063b5d227319a0e651936f379
|
@@ -29,14 +29,22 @@ module RelatonBib
|
|
29
29
|
|
30
30
|
# @param part [Symbol] :year, :month, :day, :date
|
31
31
|
# @return [String, Date, nil]
|
32
|
-
def from(part = nil)
|
32
|
+
def from(part = nil) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
33
33
|
d = instance_variable_get "@#{__callee__}".to_sym
|
34
34
|
return d unless part && d
|
35
35
|
|
36
|
-
date = parse_date(d)
|
37
|
-
return date if part == :date
|
36
|
+
# date = parse_date(d)
|
37
|
+
# return date if part == :date
|
38
38
|
|
39
|
-
|
39
|
+
parts = d.split "-"
|
40
|
+
case part
|
41
|
+
when :year then parts[0]&.to_i
|
42
|
+
when :month then parts[1]&.to_i
|
43
|
+
when :day then parts[2]&.to_i
|
44
|
+
else parse_date(d)
|
45
|
+
end
|
46
|
+
|
47
|
+
# date.is_a?(Date) ? date.send(part) : date
|
40
48
|
end
|
41
49
|
|
42
50
|
alias_method :to, :from
|
@@ -71,7 +79,7 @@ module RelatonBib
|
|
71
79
|
# @param count [Integer] number of dates
|
72
80
|
# @return [String]
|
73
81
|
def to_asciibib(prefix = "", count = 1)
|
74
|
-
pref = prefix.empty? ? prefix : prefix
|
82
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
75
83
|
out = count > 1 ? "#{pref}date::\n" : ""
|
76
84
|
out += "#{pref}date.type:: #{type}\n"
|
77
85
|
out += "#{pref}date.on:: #{on}\n" if on
|
@@ -165,8 +165,8 @@ module RelatonBib
|
|
165
165
|
# @option date [String, nil] :to
|
166
166
|
# @option date [String, nil] :on required if :from is nil
|
167
167
|
#
|
168
|
-
# @param contributor [Array<Hash>]
|
169
|
-
# @option contributor [RealtonBib::Organization, RelatonBib::Person]
|
168
|
+
# @param contributor [Array<Hash, RelatonBib::ContributionInfo>]
|
169
|
+
# @option contributor [RealtonBib::Organization, RelatonBib::Person] :entity
|
170
170
|
# @option contributor [String] :type
|
171
171
|
# @option contributor [String] :from
|
172
172
|
# @option contributor [String] :to
|
@@ -860,9 +860,9 @@ module RelatonBib
|
|
860
860
|
builder.seriesInfo(name: di.type, value: di.id)
|
861
861
|
end
|
862
862
|
end
|
863
|
-
di_types = docidentifier.map(&:type)
|
863
|
+
# di_types = docidentifier.map(&:type)
|
864
864
|
series.select do |s|
|
865
|
-
s.title && !di_types.include?(s.title.title.to_s) &&
|
865
|
+
s.title && # !di_types.include?(s.title.title.to_s) &&
|
866
866
|
!BibXMLParser::SERIESINFONAMES.include?(s.title.title.to_s)
|
867
867
|
end.uniq { |s| s.title.title.to_s }.each do |s|
|
868
868
|
si = builder.seriesInfo(name: s.title.title.to_s)
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
module BibXMLParser
|
3
|
+
# SeriesInfo what should be saved as docidentifiers in the Relaton model.
|
3
4
|
SERIESINFONAMES = ["DOI", "Internet-Draft"].freeze
|
5
|
+
|
4
6
|
FLAVOR = nil
|
7
|
+
|
5
8
|
ORGNAMES = {
|
6
9
|
"IEEE" => "Istitute of Electrical and Electronics Engineers",
|
7
10
|
"W3C" => "World Wide Web Consortium",
|
@@ -314,11 +317,13 @@ module RelatonBib
|
|
314
317
|
def dates(reference)
|
315
318
|
return [] unless (date = reference.at "./front/date")
|
316
319
|
|
317
|
-
d =
|
318
|
-
|
319
|
-
[
|
320
|
-
|
321
|
-
[]
|
320
|
+
d = date[:year]
|
321
|
+
d += "-#{month(date[:month])}" if date[:month] && !date[:month].empty?
|
322
|
+
d += "-#{date[:day]}" if date[:day]
|
323
|
+
# date = Time.parse(d).strftime "%Y-%m-%d"
|
324
|
+
[BibliographicDate.new(type: "published", on: d)]
|
325
|
+
# rescue ArgumentError
|
326
|
+
# []
|
322
327
|
end
|
323
328
|
|
324
329
|
# @param reference [Nokogiri::XML::Element]
|
@@ -338,10 +343,10 @@ module RelatonBib
|
|
338
343
|
end
|
339
344
|
|
340
345
|
def month(mon)
|
341
|
-
return 1 if !mon || mon.empty?
|
346
|
+
# return 1 if !mon || mon.empty?
|
342
347
|
return mon if /^\d+$/.match? mon
|
343
348
|
|
344
|
-
Date::MONTHNAMES.index(mon)
|
349
|
+
Date::MONTHNAMES.index(mon).to_s.rjust 2, "0"
|
345
350
|
end
|
346
351
|
|
347
352
|
#
|
@@ -352,7 +357,7 @@ module RelatonBib
|
|
352
357
|
#
|
353
358
|
def series(reference)
|
354
359
|
reference.xpath("./seriesInfo", "./front/seriesInfo").map do |si|
|
355
|
-
next if si[:name]
|
360
|
+
next if SERIESINFONAMES.include?(si[:name]) || si[:stream] || si[:status]
|
356
361
|
|
357
362
|
t = TypedTitleString.new(
|
358
363
|
content: si[:name], language: language(reference), script: "Latn",
|
@@ -25,7 +25,7 @@ module RelatonBib
|
|
25
25
|
# @param state [String]
|
26
26
|
# @param country [String]
|
27
27
|
# @param postcode [String]
|
28
|
-
def initialize(street:, city:, state: nil,
|
28
|
+
def initialize(street:, city:, country:, state: nil, postcode: nil)
|
29
29
|
@street = street
|
30
30
|
@city = city
|
31
31
|
@state = state
|
@@ -45,7 +45,7 @@ module RelatonBib
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# @return [Hash]
|
48
|
-
def to_hash
|
48
|
+
def to_hash # rubocop:disable Metrics/AbcSize
|
49
49
|
hash = {}
|
50
50
|
hash["street"] = street if street&.any?
|
51
51
|
hash["city"] = city
|
@@ -59,7 +59,7 @@ module RelatonBib
|
|
59
59
|
# @param count [Integer] number of addresses
|
60
60
|
# @return [String]
|
61
61
|
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize
|
62
|
-
pref = prefix.empty? ? "address" : prefix
|
62
|
+
pref = prefix.empty? ? "address" : "#{prefix}.address"
|
63
63
|
out = count > 1 ? "#{pref}::\n" : ""
|
64
64
|
street.each { |st| out += "#{pref}.street:: #{st}\n" }
|
65
65
|
out += "#{pref}.city:: #{city}\n"
|
@@ -99,7 +99,7 @@ module RelatonBib
|
|
99
99
|
# @param count [Integer] number of contacts
|
100
100
|
# @return [string]
|
101
101
|
def to_asciibib(prefix = "", count = 1)
|
102
|
-
pref = prefix.empty? ? prefix : prefix
|
102
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
103
103
|
out = count > 1 ? "#{pref}contact::\n" : ""
|
104
104
|
out += "#{pref}contact.type:: #{type}\n"
|
105
105
|
out += "#{pref}contact.value:: #{value}\n"
|
@@ -156,7 +156,7 @@ module RelatonBib
|
|
156
156
|
# @param count [Integer]
|
157
157
|
# @return [String]
|
158
158
|
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize
|
159
|
-
pref = prefix.empty? ? prefix : prefix
|
159
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
160
160
|
out = count > 1 ? "#{pref}affiliation::\n" : ""
|
161
161
|
out += name.to_asciibib "#{pref}affiliation.name" if name
|
162
162
|
description.each do |d|
|
@@ -206,7 +206,7 @@ module RelatonBib
|
|
206
206
|
# @param prefix [String]
|
207
207
|
# @return [String]
|
208
208
|
def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
209
|
-
pref = prefix.empty? ? prefix : prefix
|
209
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
210
210
|
out = ""
|
211
211
|
out += "#{pref}url:: #{uri}\n" if uri
|
212
212
|
addr = contact.select { |c| c.is_a? RelatonBib::Address }
|
@@ -39,7 +39,7 @@ module RelatonBib
|
|
39
39
|
# @param count [Integer]
|
40
40
|
# @return [String]
|
41
41
|
def to_asciibib(prefix = "", count = 1)
|
42
|
-
pref = prefix.empty? ? prefix : prefix
|
42
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
43
43
|
out = count > 1 ? "#{pref}identifier::\n" : ""
|
44
44
|
out += "#{pref}identifier.type:: #{type}\n"
|
45
45
|
out += "#{pref}identifier.value:: #{value}\n"
|
@@ -118,7 +118,7 @@ module RelatonBib
|
|
118
118
|
# @param count [Integer]
|
119
119
|
# @return [String]
|
120
120
|
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
121
|
-
pref = prefix.sub
|
121
|
+
pref = prefix.sub(/\*$/, "organization")
|
122
122
|
out = count > 1 ? "#{pref}::\n" : ""
|
123
123
|
name.each { |n| out += n.to_asciibib "#{pref}.name", name.size }
|
124
124
|
out += abbreviation.to_asciibib "#{pref}.abbreviation" if abbreviation
|
@@ -136,10 +136,11 @@ module RelatonBib
|
|
136
136
|
# @param arg [String, Hash, RelatoBib::LocalizedString]
|
137
137
|
# @return [RelatoBib::LocalizedString]
|
138
138
|
def localized_string(arg)
|
139
|
-
|
140
|
-
|
139
|
+
case arg
|
140
|
+
when String then LocalizedString.new(arg)
|
141
|
+
when Hash
|
141
142
|
LocalizedString.new(arg[:content], arg[:language], arg[:script])
|
142
|
-
|
143
|
+
when LocalizedString then arg
|
143
144
|
end
|
144
145
|
end
|
145
146
|
end
|
data/lib/relaton_bib/series.rb
CHANGED
@@ -13,7 +13,7 @@ module RelatonBib
|
|
13
13
|
# @return [RelatonBib::FormattedRef, NilClass]
|
14
14
|
attr_reader :formattedref
|
15
15
|
|
16
|
-
# @return [RelatonBib::
|
16
|
+
# @return [RelatonBib::TypedTitleString, NilClass] title
|
17
17
|
attr_reader :title
|
18
18
|
|
19
19
|
# @return [String, NilClass]
|
@@ -39,10 +39,10 @@ module RelatonBib
|
|
39
39
|
|
40
40
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
41
41
|
|
42
|
-
# @param type [String, NilClass]
|
43
|
-
# passed
|
42
|
+
# @param type [String, NilClass]
|
44
43
|
# @param formattedref [RelatonBib::FormattedRef, NilClass]
|
45
|
-
# @param title [RelatonBib::TypedTitleString, NilClass]
|
44
|
+
# @param title [RelatonBib::TypedTitleString, NilClass] title or
|
45
|
+
# formattedref argument should be passed
|
46
46
|
# @param place [String, NilClass]
|
47
47
|
# @param orgaization [String, NilClass]
|
48
48
|
# @param abbreviation [RelatonBib::LocalizedString, NilClass]
|
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: 1.9.
|
4
|
+
version: 1.9.21
|
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-01-
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|