relaton-3gpp 2.1.1 → 2.1.2

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: 54738dbc6d23452b7685329da5f52ba2196a82ea0f1e05bb9b26e6ae6e1d4041
4
+ data.tar.gz: 168cf0029d68af44d35a62c1ebd964ba0d23df56b3f6caab3ef7fa085ac01441
5
5
  SHA512:
6
- metadata.gz: 85f0b55228d20f356ac1581ee4738e32de7c40eb53dd0a16e77b0038f60537419e041cc7f380f285d6e59292db3ae337789eee0701185833f0db0d4dbd6a8496
7
- data.tar.gz: 97d43826476a9d39c8cf2cd981bfc0fcd1f3a5d92923027c742b9e79d0117c78c51cb98753c8f9da4102a2e6a05e61de4ec9bde88ad738c91504b2e72145ca5a
6
+ metadata.gz: ee5c52cc7ba3f52a7b5ed138ba2f0dae231703151170ec1dec041541381b59b493f55341afb1226de266d905710f303f43f352891de101614aba2a8f5409d238
7
+ data.tar.gz: 345b4a68391146d9d5a853c9878e344f1dcc2586dd902cd92361d674d8fb61c9b65de354c8e8937c75e6cd6a6c30472a21d35dd8de88d3d9e8b139006b6d61e2
@@ -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,8 @@ 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
12
+ CSV_FILE = "3GPPBibliography.csv".freeze
10
13
 
11
14
  def log_error(msg)
12
15
  Util.error msg
@@ -30,7 +33,7 @@ module Relaton
30
33
  FileUtils.rm_f Dir.glob(File.join(@output, "/*")) # if renewal && dbs["2001-04-25_schedule"].any?
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,33 +51,52 @@ 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 && CSV_FILE == @current["file"] &&
62
+ !@current["date"].to_s.empty? &&
63
+ dt == DateTime.parse(@current["date"])
63
64
  return
64
65
  end
65
66
 
66
67
  tmp_file = File.join Dir.tmpdir, "3gpp.csv"
67
- ftp.get(file, tmp_file)
68
- rescue Net::OpenTimeout, Net::ReadTimeout => e
68
+ download(uri, tmp_file)
69
+ rescue Net::OpenTimeout, Net::ReadTimeout, SocketError => e
69
70
  n += 1
70
71
  retry if n < 5
71
72
  raise e
72
73
  end
73
- @current["file"] = file
74
+ @current["file"] = CSV_FILE
74
75
  @current["date"] = dt.to_s
75
76
  tmp_file
76
77
  end
77
78
 
79
+ def head_last_modified(uri)
80
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https",
81
+ open_timeout: 30, read_timeout: 30) do |http|
82
+ resp = http.request(Net::HTTP::Head.new(uri.request_uri))
83
+ raise "HTTP #{resp.code} from #{uri}" unless resp.is_a?(Net::HTTPSuccess)
84
+
85
+ resp["last-modified"]
86
+ end
87
+ end
88
+
89
+ def download(uri, tmp_file)
90
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https",
91
+ open_timeout: 30, read_timeout: 120) do |http|
92
+ http.request(Net::HTTP::Get.new(uri.request_uri)) do |resp|
93
+ raise "HTTP #{resp.code} from #{uri}" unless resp.is_a?(Net::HTTPSuccess)
94
+
95
+ File.open(tmp_file, "wb") { |f| resp.read_body { |chunk| f.write(chunk) } }
96
+ end
97
+ end
98
+ end
99
+
78
100
  #
79
101
  # Save document to file
80
102
  #
@@ -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.2"
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.2
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