relaton-3gpp 1.14.1 → 1.14.3

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: 2b517c9d22d68ff8b15cac60a6ecc2d6a943e42143f93e7db5eec0cdf840953f
4
- data.tar.gz: cead26203248e1acff2ac1eb4101b596ef0f3759434d6d0ecb68ebb95d99e6b8
3
+ metadata.gz: 9e8d98ffac2c963fb2b403b0db8d549218150a7a23cb13ed17fd65604287fd54
4
+ data.tar.gz: dafdb6e3178f868bf6b25cf1cb8fc250a4e92d694a18d7d9396b3f6df1088402
5
5
  SHA512:
6
- metadata.gz: d96c27426f3fd56f74d310afb3c2f1da70d0ad0fea25ee768e3005597986fc160e20c6e8c719c7ca51e45f631ca49d0ad04f0fc867713112aac82697ba690bcb
7
- data.tar.gz: b7c2c50c0e06fd11cc4f9a128e9a8c955856b86a55b0580beb96488021b37698515a40a58e56455400b6c47b8a527f188ad2e131bcadf81ab56c06ae8d3ab2f4
6
+ metadata.gz: 98c8bc6c6460f8e11670d03abcf4d67be9855cbe46cb1770847f02e0a0674600b8dcfba2b444ae9c7a5ae7d2f58b11d6b1435a3fb80a218a327dea7967d7686d
7
+ data.tar.gz: 6bbf146a6e1b27e47e0340f50835dff409a22c647b6e63ade2c5dbc3d9ed6da326fa3b06e736d29f3dcd94d1e9bb7939d52d1fdd3ce0f34350103b3bd99911d5
data/README.adoc CHANGED
@@ -132,12 +132,13 @@ There is a 3GPP dataset ftp://www.3gpp.org/Information/Databases/Spec_Status/[la
132
132
  The method `Relaton3GPP::DataFetcher.fetch(output: "data", format: "yaml")` converts all the documents from the dataset and save them to the `./data` folder in YAML format.
133
133
  Arguments:
134
134
 
135
+ - `source` - a data source name. Possible values are: `status-smg-3GPP` and `status-smg-3GPP-force`. The first one only downloads a dataset if it's updated. The second one forces this gem to download the latest dataset.
135
136
  - `output` - folder to save documents (default './data').
136
137
  - `format` - a format in which the documents are saved. Possible formats are: `yaml`, `xml`, `bibxml` (default `yaml`).
137
138
 
138
139
  [source,ruby]
139
140
  ----
140
- Relaton3GPP::DataFetcher.fetch output: "data", format: "yaml"
141
+ Relaton3GPP::DataFetcher.fetch "status-smg-3GPP" output: "data", format: "yaml"
141
142
  Started at: 2021-12-10 19:58:46 +0100
142
143
  Stopped at: 2021-12-10 20:08:03 +0100
143
144
  Done in: 557 sec.
@@ -22,14 +22,15 @@ module Relaton3gpp
22
22
  #
23
23
  # Initialize fetcher and run fetch
24
24
  #
25
+ # @param [Strin] source source name
25
26
  # @param [Strin] output directory to save files, default: "data"
26
27
  # @param [Strin] format format of output files (xml, yaml, bibxml), default: yaml
27
28
  #
28
- def self.fetch(output: "data", format: "yaml")
29
+ def self.fetch(source, output: "data", format: "yaml")
29
30
  t1 = Time.now
30
31
  puts "Started at: #{t1}"
31
32
  FileUtils.mkdir_p output
32
- new(output, format).fetch
33
+ new(output, format).fetch(source == "status-smg-3GPP-force")
33
34
  t2 = Time.now
34
35
  puts "Stopped at: #{t2}"
35
36
  puts "Done in: #{(t2 - t1).round} sec."
@@ -38,8 +39,10 @@ module Relaton3gpp
38
39
  #
39
40
  # Parse documents
40
41
  #
41
- def fetch # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
42
- file = get_file
42
+ # @param [Boolean] renewal force to update all documents
43
+ #
44
+ def fetch(renewal) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
45
+ file = get_file renewal
43
46
  return unless file
44
47
 
45
48
  Zip::File.open(file) do |zip_file|
@@ -53,7 +56,7 @@ module Relaton3gpp
53
56
  specrels = dbs["Specs_GSM+3G_release-info"]
54
57
  releases = dbs["Releases"]
55
58
  tstatus = dbs["temp-status"]
56
- FileUtils.rm_rf @output if dbs["2001-04-25_schedule"].any?
59
+ FileUtils.rm_f File.join(@output, "/*") if renewal && dbs["2001-04-25_schedule"].any?
57
60
  dbs["2001-04-25_schedule"].each do |row|
58
61
  fetch_doc row, specs, specrels, releases, tstatus
59
62
  end
@@ -63,9 +66,11 @@ module Relaton3gpp
63
66
  #
64
67
  # Get file from FTP
65
68
  #
69
+ # @param [Boolean] renewal force to update all documents
70
+ #
66
71
  # @return [String] file name
67
72
  #
68
- def get_file # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
73
+ def get_file(renewal) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
69
74
  @current = YAML.load_file CURRENT if File.exist? CURRENT
70
75
  @current ||= {}
71
76
  n = 0
@@ -75,8 +80,10 @@ module Relaton3gpp
75
80
  ftp.login
76
81
  ftp.chdir "/Information/Databases/Spec_Status/"
77
82
  d, t, _, file = ftp.list("*.zip").first.split
78
- dt = DateTime.strptime("#{d} #{t}", "%m-%d-%y %I:%M%p")
79
- return if file == @current["file"] && dt == DateTime.parse(@current["date"])
83
+ unless renewal
84
+ dt = DateTime.strptime("#{d} #{t}", "%m-%d-%y %I:%M%p")
85
+ return if file == @current["file"] && dt == DateTime.parse(@current["date"])
86
+ end
80
87
 
81
88
  ftp.getbinaryfile file
82
89
  rescue Net::ReadTimeout => e
@@ -9,7 +9,7 @@ module Relaton3gpp
9
9
  @prefix = "3GPP"
10
10
  @defaultprefix = %r{^3GPP\s}
11
11
  @idtype = "3GPP"
12
- @datasets = %w[status-smg-3GPP]
12
+ @datasets = %w[status-smg-3GPP status-smg-3GPP-force]
13
13
  end
14
14
 
15
15
  # @param code [String]
@@ -23,13 +23,13 @@ module Relaton3gpp
23
23
  #
24
24
  # Fetch all the documents from http://xml2rfc.tools.ietf.org/public/rfc/bibxml-3gpp-new/
25
25
  #
26
- # @param [String] _source source name
26
+ # @param [String] source source name
27
27
  # @param [Hash] opts
28
28
  # @option opts [String] :output directory to output documents
29
29
  # @option opts [String] :format
30
30
  #
31
- def fetch_data(_source, opts)
32
- DataFetcher.fetch(**opts)
31
+ def fetch_data(source, opts)
32
+ DataFetcher.fetch(source, **opts)
33
33
  end
34
34
 
35
35
  # @param xml [String]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Relaton3gpp
4
- VERSION = "1.14.1"
4
+ VERSION = "1.14.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-3gpp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.1
4
+ version: 1.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.