relaton-3gpp 2.1.2 → 2.1.3
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/3gpp/bibliography.rb +4 -6
- data/lib/relaton/3gpp/data_fetcher.rb +12 -13
- data/lib/relaton/3gpp/item_data.rb +9 -0
- data/lib/relaton/3gpp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df54ace8170262d7d798824f989d47b601aebc9a36ac9c7b23b0e7d755b3996f
|
|
4
|
+
data.tar.gz: a4dac9da0594e7537bf83b299f7af86d718ef74fc24ba5f4d74201cff5596101
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e0d9a1fd084613acbf2ad02340fc9a813628d816ee1f316871b41a0640ad656ae49a0254690e5caa91268719840fe8abdbc27e4a6f08cd5b325e579e3f728e36
|
|
7
|
+
data.tar.gz: e04c85ec2751fccd8335d905ec1d72110ce3524f8a360a7746dd88d5c9066af6ef7f6b76ded9b6a8c01ae560871ee6f07e5c671db291a1f4b69ecc822e11ab95
|
|
@@ -4,8 +4,7 @@ module Relaton
|
|
|
4
4
|
module ThreeGpp
|
|
5
5
|
# Methods for search IANA standards.
|
|
6
6
|
module Bibliography
|
|
7
|
-
|
|
8
|
-
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-3gpp/refs/heads/v2/"
|
|
7
|
+
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-3gpp/v2/"
|
|
9
8
|
|
|
10
9
|
# @param text [String]
|
|
11
10
|
# @return [RelatonBib::BibliographicItem]
|
|
@@ -14,7 +13,6 @@ module Relaton
|
|
|
14
13
|
row = index.search(text.sub(/^3GPP\s/, "")).min_by { |r| r[:id] }
|
|
15
14
|
return unless row
|
|
16
15
|
|
|
17
|
-
# file = text.sub(/^3GPP\s/, "").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
|
|
18
16
|
url = "#{SOURCE}#{row[:file]}"
|
|
19
17
|
resp = Net::HTTP.get_response URI(url)
|
|
20
18
|
return unless resp.code == "200"
|
|
@@ -22,9 +20,9 @@ module Relaton
|
|
|
22
20
|
item = Item.from_yaml(resp.body)
|
|
23
21
|
item.fetched = Date.today.to_s
|
|
24
22
|
item
|
|
25
|
-
rescue
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
|
24
|
+
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
25
|
+
Net::ProtocolError, Errno::ETIMEDOUT => e
|
|
28
26
|
raise Relaton::RequestError, e.message
|
|
29
27
|
end
|
|
30
28
|
|
|
@@ -9,7 +9,6 @@ module Relaton
|
|
|
9
9
|
class DataFetcher < Core::DataFetcher
|
|
10
10
|
CURRENT = "current.yaml".freeze
|
|
11
11
|
CSV_URL = "https://www.3gpp.org/ftp/Information/Databases/3GPPBibliography.csv".freeze
|
|
12
|
-
CSV_FILE = "3GPPBibliography.csv".freeze
|
|
13
12
|
|
|
14
13
|
def log_error(msg)
|
|
15
14
|
Util.error msg
|
|
@@ -22,7 +21,8 @@ module Relaton
|
|
|
22
21
|
#
|
|
23
22
|
# Parse documents
|
|
24
23
|
#
|
|
25
|
-
# @param [String] source source of documents, status-smg-3gpp for updare
|
|
24
|
+
# @param [String] source source of documents, status-smg-3gpp for updare
|
|
25
|
+
# or status-smg-3gpp-force for renewal
|
|
26
26
|
#
|
|
27
27
|
def fetch(source) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
28
28
|
renewal = source == "status-smg-3GPP-force"
|
|
@@ -30,7 +30,7 @@ module Relaton
|
|
|
30
30
|
return unless file && File.exist?(file) && File.size(file) > 20_000_000
|
|
31
31
|
|
|
32
32
|
if renewal
|
|
33
|
-
FileUtils.rm_f Dir.glob(File.join(@output, "/*"))
|
|
33
|
+
FileUtils.rm_f Dir.glob(File.join(@output, "/*"))
|
|
34
34
|
index.remove_all # if renewal
|
|
35
35
|
end
|
|
36
36
|
CSV.open(file, "r:bom|utf-8", headers: true, col_sep: ";").each do |row|
|
|
@@ -58,9 +58,8 @@ module Relaton
|
|
|
58
58
|
return unless last_modified
|
|
59
59
|
|
|
60
60
|
dt = DateTime.parse(last_modified)
|
|
61
|
-
if !renewal &&
|
|
62
|
-
|
|
63
|
-
dt == DateTime.parse(@current["date"])
|
|
61
|
+
if !renewal && !@current["date"].to_s.empty? &&
|
|
62
|
+
dt == DateTime.parse(@current["date"])
|
|
64
63
|
return
|
|
65
64
|
end
|
|
66
65
|
|
|
@@ -71,7 +70,6 @@ module Relaton
|
|
|
71
70
|
retry if n < 5
|
|
72
71
|
raise e
|
|
73
72
|
end
|
|
74
|
-
@current["file"] = CSV_FILE
|
|
75
73
|
@current["date"] = dt.to_s
|
|
76
74
|
tmp_file
|
|
77
75
|
end
|
|
@@ -102,7 +100,7 @@ module Relaton
|
|
|
102
100
|
#
|
|
103
101
|
# @param [RelatonW3c::W3cBibliographicItem, nil] bib bibliographic item
|
|
104
102
|
#
|
|
105
|
-
def save_doc(bib) # rubocop:disable Metrics/MethodLength
|
|
103
|
+
def save_doc(bib) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
|
106
104
|
return unless bib
|
|
107
105
|
|
|
108
106
|
bib1 = bib
|
|
@@ -128,7 +126,7 @@ module Relaton
|
|
|
128
126
|
def merge_duplication(bib, file)
|
|
129
127
|
hash = YAML.load_file file
|
|
130
128
|
existed = Item.from_hash hash
|
|
131
|
-
changed = update_source bib, existed
|
|
129
|
+
changed = update_source? bib, existed
|
|
132
130
|
bib1, bib2, chng = transposed_relation bib, existed
|
|
133
131
|
changed ||= chng
|
|
134
132
|
chng = add_contributor(bib1, bib2)
|
|
@@ -144,7 +142,7 @@ module Relaton
|
|
|
144
142
|
#
|
|
145
143
|
# @return [Boolean] true if link has been updated
|
|
146
144
|
#
|
|
147
|
-
def update_source(bib1, bib2)
|
|
145
|
+
def update_source?(bib1, bib2)
|
|
148
146
|
if bib1.source.any? && bib2.source.empty?
|
|
149
147
|
bib2.source = bib1.source
|
|
150
148
|
true
|
|
@@ -165,8 +163,9 @@ module Relaton
|
|
|
165
163
|
# related bibliographic item, true if relation has been added
|
|
166
164
|
#
|
|
167
165
|
def transposed_relation(bib, existed) # rubocop:disable Metrics/CyclomaticComplexity
|
|
168
|
-
|
|
169
|
-
bib
|
|
166
|
+
if (bib.date.none? && existed.date.none?) || (bib.date.any? && existed.date.none?)
|
|
167
|
+
return [bib, existed, false]
|
|
168
|
+
end
|
|
170
169
|
return [existed, bib, true] if bib.date.none? && existed.date.any?
|
|
171
170
|
|
|
172
171
|
check_transposed_date bib, existed
|
|
@@ -208,7 +207,7 @@ module Relaton
|
|
|
208
207
|
bib1.relation << rel
|
|
209
208
|
end
|
|
210
209
|
|
|
211
|
-
def add_contributor(bib1, bib2) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
|
210
|
+
def add_contributor(bib1, bib2) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
212
211
|
changed = false
|
|
213
212
|
|
|
214
213
|
bib2.contributor.each do |bc|
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
module Relaton
|
|
2
2
|
module ThreeGpp
|
|
3
3
|
class ItemData < Bib::ItemData
|
|
4
|
+
def create_id(without_date: false)
|
|
5
|
+
return id if id && !id.empty?
|
|
6
|
+
|
|
7
|
+
docid = find_primary_docid
|
|
8
|
+
return unless docid
|
|
9
|
+
|
|
10
|
+
pubid = without_date ? docid.content.sub(/:\d{4}$/, "") : docid.content
|
|
11
|
+
self.id = pubid.to_s.sub(/\A3GPP\s+/, "").gsub(/\W+/, "")
|
|
12
|
+
end
|
|
4
13
|
end
|
|
5
14
|
end
|
|
6
15
|
end
|
data/lib/relaton/3gpp/version.rb
CHANGED