relaton-3gpp 2.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfd23ed3bc0f514455f602bf02265aa50838b8e902b3494dedc9471d886605cd
4
- data.tar.gz: 55d3470f35c46b98b61f54708a6f36b5c2f61471a55d36c2224fe7827e524f0a
3
+ metadata.gz: df54ace8170262d7d798824f989d47b601aebc9a36ac9c7b23b0e7d755b3996f
4
+ data.tar.gz: a4dac9da0594e7537bf83b299f7af86d718ef74fc24ba5f4d74201cff5596101
5
5
  SHA512:
6
- metadata.gz: 85f0b55228d20f356ac1581ee4738e32de7c40eb53dd0a16e77b0038f60537419e041cc7f380f285d6e59292db3ae337789eee0701185833f0db0d4dbd6a8496
7
- data.tar.gz: 97d43826476a9d39c8cf2cd981bfc0fcd1f3a5d92923027c742b9e79d0117c78c51cb98753c8f9da4102a2e6a05e61de4ec9bde88ad738c91504b2e72145ca5a
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
- # SOURCE = "http://xml2rfc.tools.ietf.org/public/rfc/bibxml-3gpp-new/"
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 SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
26
- EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
27
- Net::ProtocolError, Errno::ETIMEDOUT => e
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
 
@@ -1,5 +1,6 @@
1
1
  require "fileutils"
2
- require "net/ftp"
2
+ require "net/http"
3
+ require "uri"
3
4
  require_relative "../3gpp"
4
5
  require_relative "parser"
5
6
 
@@ -7,6 +8,7 @@ module Relaton
7
8
  module ThreeGpp
8
9
  class DataFetcher < Core::DataFetcher
9
10
  CURRENT = "current.yaml".freeze
11
+ CSV_URL = "https://www.3gpp.org/ftp/Information/Databases/3GPPBibliography.csv".freeze
10
12
 
11
13
  def log_error(msg)
12
14
  Util.error msg
@@ -19,7 +21,8 @@ module Relaton
19
21
  #
20
22
  # Parse documents
21
23
  #
22
- # @param [String] source source of documents, status-smg-3gpp for updare or status-smg-3gpp-force for renewal
24
+ # @param [String] source source of documents, status-smg-3gpp for updare
25
+ # or status-smg-3gpp-force for renewal
23
26
  #
24
27
  def fetch(source) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
25
28
  renewal = source == "status-smg-3GPP-force"
@@ -27,10 +30,10 @@ module Relaton
27
30
  return unless file && File.exist?(file) && File.size(file) > 20_000_000
28
31
 
29
32
  if renewal
30
- FileUtils.rm_f Dir.glob(File.join(@output, "/*")) # if renewal && dbs["2001-04-25_schedule"].any?
33
+ FileUtils.rm_f Dir.glob(File.join(@output, "/*"))
31
34
  index.remove_all # if renewal
32
35
  end
33
- CSV.open(file, "r:bom|utf-8", headers: true).each do |row|
36
+ CSV.open(file, "r:bom|utf-8", headers: true, col_sep: ";").each do |row|
34
37
  save_doc Parser.parse(row, @errors)
35
38
  end
36
39
  File.write CURRENT, @current.to_yaml, encoding: "UTF-8"
@@ -39,7 +42,7 @@ module Relaton
39
42
  end
40
43
 
41
44
  #
42
- # Get file from FTP. If file does not exist or changed, return nil
45
+ # Get file via HTTPS. If file has not changed, return nil
43
46
  #
44
47
  # @param [Boolean] renewal force to update all documents
45
48
  #
@@ -48,39 +51,56 @@ module Relaton
48
51
  def get_file(renewal) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
49
52
  @current = YAML.load_file CURRENT if File.exist? CURRENT
50
53
  @current ||= {}
54
+ uri = URI(CSV_URL)
51
55
  n = 0
52
56
  begin
53
- ftp = Net::FTP.new("www.3gpp.org", open_timeout: 30)
54
- ftp.resume = true
55
- ftp.login
56
- ftp.chdir "/Information/Databases/"
57
- file_path = ftp.list("*.csv").first
58
- return unless file_path
59
-
60
- d, t, _, file = file_path.split
61
- dt = DateTime.strptime("#{d} #{t}", "%m-%d-%y %I:%M%p")
62
- if !renewal && file == @current["file"] && !@current["date"].empty? && dt == DateTime.parse(@current["date"])
57
+ last_modified = head_last_modified(uri)
58
+ return unless last_modified
59
+
60
+ dt = DateTime.parse(last_modified)
61
+ if !renewal && !@current["date"].to_s.empty? &&
62
+ dt == DateTime.parse(@current["date"])
63
63
  return
64
64
  end
65
65
 
66
66
  tmp_file = File.join Dir.tmpdir, "3gpp.csv"
67
- ftp.get(file, tmp_file)
68
- rescue Net::OpenTimeout, Net::ReadTimeout => e
67
+ download(uri, tmp_file)
68
+ rescue Net::OpenTimeout, Net::ReadTimeout, SocketError => e
69
69
  n += 1
70
70
  retry if n < 5
71
71
  raise e
72
72
  end
73
- @current["file"] = file
74
73
  @current["date"] = dt.to_s
75
74
  tmp_file
76
75
  end
77
76
 
77
+ def head_last_modified(uri)
78
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https",
79
+ open_timeout: 30, read_timeout: 30) do |http|
80
+ resp = http.request(Net::HTTP::Head.new(uri.request_uri))
81
+ raise "HTTP #{resp.code} from #{uri}" unless resp.is_a?(Net::HTTPSuccess)
82
+
83
+ resp["last-modified"]
84
+ end
85
+ end
86
+
87
+ def download(uri, tmp_file)
88
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https",
89
+ open_timeout: 30, read_timeout: 120) do |http|
90
+ http.request(Net::HTTP::Get.new(uri.request_uri)) do |resp|
91
+ raise "HTTP #{resp.code} from #{uri}" unless resp.is_a?(Net::HTTPSuccess)
92
+
93
+ File.open(tmp_file, "wb") { |f| resp.read_body { |chunk| f.write(chunk) } }
94
+ end
95
+ end
96
+ end
97
+
78
98
  #
79
99
  # Save document to file
80
100
  #
81
101
  # @param [RelatonW3c::W3cBibliographicItem, nil] bib bibliographic item
82
102
  #
83
- def save_doc(bib) # rubocop:disable Metrics/MethodLength
103
+ def save_doc(bib) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
84
104
  return unless bib
85
105
 
86
106
  bib1 = bib
@@ -106,7 +126,7 @@ module Relaton
106
126
  def merge_duplication(bib, file)
107
127
  hash = YAML.load_file file
108
128
  existed = Item.from_hash hash
109
- changed = update_source bib, existed
129
+ changed = update_source? bib, existed
110
130
  bib1, bib2, chng = transposed_relation bib, existed
111
131
  changed ||= chng
112
132
  chng = add_contributor(bib1, bib2)
@@ -122,7 +142,7 @@ module Relaton
122
142
  #
123
143
  # @return [Boolean] true if link has been updated
124
144
  #
125
- def update_source(bib1, bib2)
145
+ def update_source?(bib1, bib2)
126
146
  if bib1.source.any? && bib2.source.empty?
127
147
  bib2.source = bib1.source
128
148
  true
@@ -143,8 +163,9 @@ module Relaton
143
163
  # related bibliographic item, true if relation has been added
144
164
  #
145
165
  def transposed_relation(bib, existed) # rubocop:disable Metrics/CyclomaticComplexity
146
- return [bib, existed, false] if bib.date.none? && existed.date.none? ||
147
- bib.date.any? && existed.date.none?
166
+ if (bib.date.none? && existed.date.none?) || (bib.date.any? && existed.date.none?)
167
+ return [bib, existed, false]
168
+ end
148
169
  return [existed, bib, true] if bib.date.none? && existed.date.any?
149
170
 
150
171
  check_transposed_date bib, existed
@@ -186,7 +207,7 @@ module Relaton
186
207
  bib1.relation << rel
187
208
  end
188
209
 
189
- 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
190
211
  changed = false
191
212
 
192
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
@@ -205,7 +205,13 @@ module Relaton
205
205
  end
206
206
 
207
207
  def other_contribs
208
- contribs = @row["Responsible Secondary"].strip.split(", ").map do |wg|
208
+ secondary = @row["Responsible Secondary"]
209
+ if secondary.nil? || secondary.strip.empty?
210
+ @errors[:editorial_group_contributor_other] &&= true
211
+ return []
212
+ end
213
+
214
+ contribs = secondary.strip.split(", ").map do |wg|
209
215
  editorial_group_contributor(wg, "other")
210
216
  end
211
217
  @errors[:editorial_group_contributor_other] &&= contribs.empty?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module ThreeGpp
5
- VERSION = "2.1.1"
5
+ VERSION = "2.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-3gpp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-12 00:00:00.000000000 Z
11
+ date: 2026-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv