relaton 1.11.3 → 1.11.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.adoc +0 -13
  3. data/lib/relaton/db.rb +6 -31
  4. data/lib/relaton/db_cache.rb +6 -6
  5. data/lib/relaton/version.rb +1 -1
  6. data/relaton.gemspec +1 -1
  7. data/spec/relaton/db_spec.rb +24 -57
  8. data/spec/relaton_spec.rb +8 -11
  9. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +9 -9
  10. data/spec/vcr_cassetes/async_fetch.yml +1441 -1441
  11. data/spec/vcr_cassetes/bipm_i18n_async_fetch.yml +620 -0
  12. data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +10 -10
  13. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +10 -10
  14. data/spec/vcr_cassetes/cie_001_1980.yml +7 -7
  15. data/spec/vcr_cassetes/ecma_6.yml +7 -7
  16. data/spec/vcr_cassetes/en_10160_1999.yml +29 -29
  17. data/spec/vcr_cassetes/fisp_140.yml +6 -6
  18. data/spec/vcr_cassetes/gb_t_20223_2006.yml +6 -6
  19. data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +10 -10
  20. data/spec/vcr_cassetes/iec_60050_102_2007.yml +28 -28
  21. data/spec/vcr_cassetes/iec_combined_included.yml +99 -97
  22. data/spec/vcr_cassetes/ieee_528_2019.yml +858 -859
  23. data/spec/vcr_cassetes/iho_b_11.yml +7 -7
  24. data/spec/vcr_cassetes/iso_111111119115_1.yml +3 -3
  25. data/spec/vcr_cassetes/iso_19115_1.yml +14 -14
  26. data/spec/vcr_cassetes/iso_19115_1_2.yml +29 -29
  27. data/spec/vcr_cassetes/iso_19115_all_parts.yml +18 -18
  28. data/spec/vcr_cassetes/iso_19133_2005.yml +17 -17
  29. data/spec/vcr_cassetes/iso_combined_applied.yml +27 -27
  30. data/spec/vcr_cassetes/iso_combined_included.yml +30 -30
  31. data/spec/vcr_cassetes/iso_dis_14093.yml +15 -15
  32. data/spec/vcr_cassetes/itu_combined_included.yml +182 -182
  33. data/spec/vcr_cassetes/oasis_amqp_core_types_v1_0_pt1.yml +10 -10
  34. data/spec/vcr_cassetes/ogc_19_025r1.yml +11 -11
  35. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +4 -4
  36. data/spec/vcr_cassetes/rfc_8341.yml +112 -24
  37. data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
  38. data/spec/vcr_cassetes/threads_from_env.yml +59 -59
  39. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +29 -29
  40. data/spec/vcr_cassetes/w3c_json_ld11.yml +44 -23
  41. metadata +3 -11
  42. data/globalcache/iec/iec_60050_102_2007.xml +0 -58
  43. data/globalcache/iec/version +0 -1
  44. data/lib/relaton/static_cache/iso/iso_iec_dir_1.yml +0 -33
  45. data/lib/relaton/static_cache/iso/iso_iec_dir_1_iec_sup.yml +0 -32
  46. data/lib/relaton/static_cache/iso/iso_iec_dir_1_iso_sup.yml +0 -39
  47. data/lib/relaton/static_cache/iso/iso_iec_dir_2_iec.yml +0 -32
  48. data/lib/relaton/static_cache/iso/iso_iec_dir_2_iso.yml +0 -39
  49. data/lib/relaton/static_cache/iso/iso_iec_dir_iec_sup.yml +0 -32
  50. data/lib/relaton/static_cache/iso/iso_iec_dir_jtc_1_sup.yml +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e53eb8b2768e1b80e472312aa1af438457ce7115fe078256318749666261f33
4
- data.tar.gz: 670a8f3815488a7b315c1e0b56f6376c16fd317cec1fb444d7c6d0dac9c92107
3
+ metadata.gz: bd53313a7d35f6ed1adf7669962afc84282d15d232247d3facec910aaba05270
4
+ data.tar.gz: 304a0e1c5a44731f0a4f9a30c063df920deb8694aca702044fd1ab03a10fe5e8
5
5
  SHA512:
6
- metadata.gz: 64186cb269dbd470798c3ccbe2996ea736c909c7258bc385528626e043bee1c7d88a1a6409948392ef73203ea4715a93b8474bfd3437503a08a1e312d430a968
7
- data.tar.gz: 434cbc56312aa11577c2227788eeb930ea2e85e9f5c98f37b5738e58d030bfbcf0cbffcdeb623dda7ef31ca7628bc80f7a88a63050814e3b87a0c1883abcb287
6
+ metadata.gz: 4cfb3d708769580fccb31ef09a408265a4b828e70082c7f44a2fe485c2982437cf4f8b8369ada51e7e2d9d3e05c05eada5eaca8126506ea5b9224b7575727501
7
+ data.tar.gz: 2255f0695f06f0714e55b03d9a9ad7c2b7567d417ff184e598c462e299aeed145fb6fb143fc9e83aedf7223479addd9542a6ea3d16b17298f55621676100010f
data/docs/README.adoc CHANGED
@@ -331,19 +331,6 @@ items[0].docidentifier[0].id
331
331
  => "ISO 19011 (all parts)"
332
332
  ----
333
333
 
334
- === Static DB
335
-
336
- This gem has a static DB which is distributed with it. Now the static contains documents:
337
- ----
338
- ISO/IEC DIR 1 IEC SUP
339
- ISO/IEC DIR 1 ISO SUP
340
- ISO/IEC DIR 1
341
- ISO/IEC DIR 2 IEC
342
- ISO/IEC DIR 2 ISO
343
- ISO/IEC DIR IEC SUP
344
- ISO/IEC DIR 1 JTC SUP
345
- ----
346
-
347
334
  === Get document type
348
335
  [source,ruby]
349
336
  ----
data/lib/relaton/db.rb CHANGED
@@ -11,11 +11,9 @@ module Relaton
11
11
  def initialize(global_cache, local_cache)
12
12
  @registry = Relaton::Registry.instance
13
13
  gpath = global_cache && File.expand_path(global_cache)
14
- @db = open_cache_biblio(gpath, type: :global)
14
+ @db = open_cache_biblio(gpath)
15
15
  lpath = local_cache && File.expand_path(local_cache)
16
- @local_db = open_cache_biblio(lpath, type: :local)
17
- @static_db = open_cache_biblio File.expand_path("../relaton/static_cache",
18
- __dir__)
16
+ @local_db = open_cache_biblio(lpath)
19
17
  @queues = {}
20
18
  @semaphore = Mutex.new
21
19
  end
@@ -87,9 +85,7 @@ module Relaton
87
85
  # @param year [Integer, nil]
88
86
  # @return [Array]
89
87
  def fetch_all(text = nil, edition: nil, year: nil)
90
- result = @static_db.all do |file, yml|
91
- search_yml file, yml, text, edition, year
92
- end.compact
88
+ result = []
93
89
  db = @db || @local_db
94
90
  if db
95
91
  result += db.all do |file, xml|
@@ -187,19 +183,6 @@ module Relaton
187
183
 
188
184
  private
189
185
 
190
- # @param file [String] file path
191
- # @param yml [String] content in YAML format
192
- # @param text [String, nil] text to serach
193
- # @param edition [String, nil] edition to filter
194
- # @param year [Integer, nil] year to filter
195
- # @return [BibliographicItem, nil]
196
- def search_yml(file, yml, text, edition, year)
197
- item = search_edition_year(file, yml, edition, year)
198
- return unless item
199
-
200
- item if match_xml_text(item.to_xml(bibdata: true), text)
201
- end
202
-
203
186
  # @param file [String] file path
204
187
  # @param xml [String] content in XML format
205
188
  # @param text [String, nil] text to serach
@@ -346,11 +329,6 @@ module Relaton
346
329
  # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
347
330
  def check_bibliocache(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
348
331
  id, searchcode = std_id(code, year, opts, stdclass)
349
- yaml = @static_db[id]
350
- if yaml
351
- return @registry.processors[stdclass].hash_to_bib YAML.safe_load(yaml)
352
- end
353
-
354
332
  db = @local_db || @db
355
333
  altdb = @local_db && @db ? @db : nil
356
334
  if db.nil?
@@ -438,13 +416,11 @@ module Relaton
438
416
  end
439
417
 
440
418
  # @param dir [String, nil] DB directory
441
- # @param type [Symbol]
442
419
  # @return [Relaton::DbCache, NilClass]
443
- def open_cache_biblio(dir, type: :static) # rubocop:disable Metrics/MethodLength
420
+ def open_cache_biblio(dir) # rubocop:disable Metrics/MethodLength
444
421
  return nil if dir.nil?
445
422
 
446
- db = DbCache.new dir, type == :static ? "yml" : "xml"
447
- return db if type == :static
423
+ db = DbCache.new dir
448
424
 
449
425
  Dir["#{dir}/*/"].each do |fdir|
450
426
  next if db.check_version?(fdir)
@@ -452,8 +428,7 @@ module Relaton
452
428
  FileUtils.rm_rf(fdir, secure: true)
453
429
  Util.log(
454
430
  "[relaton] WARNING: cache #{fdir}: version is obsolete and cache is "\
455
- "cleared.",
456
- :warning
431
+ "cleared.", :warning
457
432
  )
458
433
  end
459
434
  db
@@ -32,7 +32,7 @@ module Relaton
32
32
 
33
33
  # Clear database
34
34
  def clear
35
- FileUtils.rm_rf Dir.glob "#{dir}/*" if @ext == "xml" # unless it's static DB
35
+ FileUtils.rm_rf Dir.glob "#{dir}/*"
36
36
  end
37
37
 
38
38
  # Save item
@@ -86,7 +86,7 @@ module Relaton
86
86
  value = self[key]
87
87
  return unless value
88
88
 
89
- if value.match? /^not_found/
89
+ if value.match?(/^not_found/)
90
90
  value.match(/\d{4}-\d{2}-\d{2}/).to_s
91
91
  else
92
92
  doc = Nokogiri::XML value
@@ -115,7 +115,7 @@ module Relaton
115
115
  # @param fdir [String] dir pathe to flover cache
116
116
  # @return [TrueClass, FalseClass]
117
117
  def check_version?(fdir)
118
- version_dir = fdir + "/version"
118
+ version_dir = "#{fdir}/version"
119
119
  return false unless File.exist? version_dir
120
120
 
121
121
  v = File.read version_dir, encoding: "utf-8"
@@ -179,9 +179,9 @@ module Relaton
179
179
  # @param key [String]
180
180
  # @return [String]
181
181
  def filename(key)
182
- prefcode = key.downcase.match /^(?<prefix>[^\(]+)\((?<code>[^\)]+)/
182
+ prefcode = key.downcase.match(/^(?<prefix>[^(]+)\((?<code>[^)]+)/)
183
183
  fn = if prefcode
184
- "#{prefcode[:prefix]}/#{prefcode[:code].gsub(/[-:\s\/\()]/, '_').squeeze('_')}"
184
+ "#{prefcode[:prefix]}/#{prefcode[:code].gsub(/[-:\s\/()]/, '_').squeeze('_')}"
185
185
  else
186
186
  key.gsub(/[-:\s]/, "_")
187
187
  end
@@ -208,7 +208,7 @@ module Relaton
208
208
  # @param key [String]
209
209
  # @return [String]
210
210
  def prefix(key)
211
- key.downcase.match(/^[^\(]+(?=\()/).to_s
211
+ key.downcase.match(/^[^(]+(?=\()/).to_s
212
212
  end
213
213
 
214
214
  # @param file [String]
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.11.3".freeze
2
+ VERSION = "1.11.4".freeze
3
3
  end
data/relaton.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.bindir = "bin"
27
27
  spec.require_paths = ["lib"]
28
28
  spec.files = `git ls-files`.split("\n")
29
- spec.test_files = `git ls-files -- {spec}/*`.split("\n")
29
+ # spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
31
31
 
32
32
  spec.add_dependency "relaton-3gpp", "~> 1.11.0"
@@ -75,9 +75,9 @@ RSpec.describe Relaton::Db do
75
75
 
76
76
  it "all documents" do
77
77
  items = db.fetch_all
78
- expect(items.size).to be 9
79
- expect(items[7]).to be_instance_of RelatonIec::IecBibliographicItem
80
- expect(items[8]).to be_instance_of RelatonIsoBib::IsoBibliographicItem
78
+ expect(items.size).to be 2
79
+ expect(items[0]).to be_instance_of RelatonIec::IecBibliographicItem
80
+ expect(items[1]).to be_instance_of RelatonIsoBib::IsoBibliographicItem
81
81
  end
82
82
 
83
83
  context "search for text" do
@@ -93,8 +93,8 @@ RSpec.describe Relaton::Db do
93
93
  items = db.fetch_all "123"
94
94
  expect(items.size).to eq 2
95
95
  items = db.fetch_all "ISO"
96
- expect(items.size).to eq 8
97
- expect(items[7].id).to eq "ISO123"
96
+ expect(items.size).to eq 1
97
+ expect(items[0].id).to eq "ISO123"
98
98
  end
99
99
 
100
100
  it "and fail" do
@@ -163,19 +163,32 @@ RSpec.describe Relaton::Db do
163
163
  results = []
164
164
  VCR.use_cassette "async_fetch", match_requests_on: %i[method uri body] do
165
165
  refs.each do |ref|
166
- db.fetch_async(ref) do |r|
167
- queue << [r, ref]
168
- end
169
- end
170
- Timeout.timeout(60) do
171
- refs.size.times { results << queue.pop }
166
+ db.fetch_async(ref) { |r| queue << [r, ref] }
172
167
  end
168
+ Timeout.timeout(60) { refs.size.times { results << queue.pop } }
173
169
  end
174
170
  results.each do |result|
175
171
  expect(result[0]).to be_instance_of RelatonItu::ItuBibliographicItem
176
172
  end
177
173
  end
178
174
 
175
+ it "BIPM i18n" do
176
+ expect(File).to receive(:exist?).with(/index\.yaml/).and_return false
177
+ allow(File).to receive(:exist?).and_call_original
178
+ refs = ["CGPM Resolution 1889-00", "CGPM Résolution 1889-00",
179
+ "CGPM Réunion 9", "CGPM Meeting 9"]
180
+ results = []
181
+ VCR.use_cassette "bipm_i18n_async_fetch" do
182
+ refs.each do |ref|
183
+ db.fetch_async(ref) { |r| queue << [r, ref] }
184
+ end
185
+ Timeout.timeout(60) { refs.size.times { results << queue.pop } }
186
+ end
187
+ results.each do |result|
188
+ expect(result[0]).to be_instance_of RelatonBipm::BipmBibliographicItem
189
+ end
190
+ end
191
+
179
192
  it "prefix not found" do
180
193
  result = ""
181
194
  VCR.use_cassette "rfc_unsuccess" do
@@ -195,50 +208,4 @@ RSpec.describe Relaton::Db do
195
208
  end
196
209
  end
197
210
  end
198
-
199
- context "fetch documents form static cache" do
200
- let(:db) { Relaton::Db.new nil, nil }
201
-
202
- it "fetches ISO/IEC DIR 1 IEC SUP" do
203
- bib = db.fetch "ISO/IEC DIR 1 IEC SUP"
204
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
205
- expect(bib.docidentifier.first.id).to eq "ISO/IEC DIR 1 IEC SUP"
206
- end
207
-
208
- it "fetches ISO/IEC DIR 1 ISO SUP" do
209
- bib = db.fetch "ISO/IEC DIR 1 ISO SUP"
210
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
211
- expect(bib.docidentifier.first.id).to eq "ISO/IEC DIR 1 ISO SUP"
212
- end
213
-
214
- it "fetches ISO/IEC DIR 1" do
215
- bib = db.fetch "ISO/IEC DIR 1"
216
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
217
- expect(bib.docidentifier.first.id).to eq "ISO/IEC DIR 1"
218
- end
219
-
220
- it "fetches ISO/IEC DIR 2 IEC" do
221
- bib = db.fetch "ISO/IEC DIR 2 IEC"
222
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
223
- expect(bib.docidentifier.first.id).to eq "ISO/IEC DIR 2 IEC"
224
- end
225
-
226
- it "fetches ISO/IEC DIR 2 ISO" do
227
- bib = db.fetch "ISO/IEC DIR 2 ISO"
228
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
229
- expect(bib.docidentifier.first.id).to eq "ISO/IEC DIR 2 ISO"
230
- end
231
-
232
- it "fetches ISO/IEC DIR IEC SUP" do
233
- bib = db.fetch "ISO/IEC DIR IEC SUP"
234
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
235
- expect(bib.docidentifier.first.id).to eq "ISO/IEC DIR IEC SUP"
236
- end
237
-
238
- it "fetches ISO/IEC DIR JTC 1 SUP" do
239
- bib = db.fetch "ISO/IEC DIR JTC 1 SUP"
240
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
241
- expect(bib.docidentifier.first.id).to eq "ISO/IEC DIR JTC 1 SUP"
242
- end
243
- end
244
211
  end
data/spec/relaton_spec.rb CHANGED
@@ -6,7 +6,7 @@ RSpec.describe Relaton::Db do
6
6
 
7
7
  it "rejects an illegal reference prefix" do
8
8
  expect { @db.fetch("XYZ XYZ", nil, {}) }.to output(
9
- /does not have a recognised prefix/
9
+ /does not have a recognised prefix/,
10
10
  ).to_stderr
11
11
  end
12
12
 
@@ -38,7 +38,7 @@ RSpec.describe Relaton::Db do
38
38
  'type="standard">'
39
39
  testcache = Relaton::DbCache.new "testcache"
40
40
  expect(
41
- testcache.valid_entry?("ISO(ISO 19133:2005)", Date.today.year.to_s)
41
+ testcache.valid_entry?("ISO(ISO 19133:2005)", Date.today.year.to_s),
42
42
  ).to eq Date.today.year.to_s
43
43
  end
44
44
  end
@@ -195,11 +195,13 @@ RSpec.describe Relaton::Db do
195
195
  expect(File.exist?("testcache")).to be true
196
196
  expect(File.exist?("testcache2")).to be true
197
197
  testcache = Relaton::DbCache.new "testcache"
198
- expect(testcache["IETF(RFC 8341)"]).to include "<docidentifier "\
199
- "type=\"RFC\" primary=\"true\">RFC 8341</docidentifier>"
198
+ expect(testcache["IETF(RFC 8341)"]).to include(
199
+ '<docidentifier type="IETF" primary="true">RFC 8341</docidentifier>',
200
+ )
200
201
  testcache = Relaton::DbCache.new "testcache2"
201
- expect(testcache["IETF(RFC 8341)"]).to include "<docidentifier "\
202
- "type=\"RFC\" primary=\"true\">RFC 8341</docidentifier>"
202
+ expect(testcache["IETF(RFC 8341)"]).to include(
203
+ '<docidentifier type="IETF" primary="true">RFC 8341</docidentifier>',
204
+ )
203
205
  end
204
206
  end
205
207
 
@@ -246,11 +248,6 @@ RSpec.describe Relaton::Db do
246
248
  end
247
249
 
248
250
  it "get W3C reference" do
249
- # w3c_fr = /\.relaton\/w3c\/bibliography\.yml/
250
- # expect(File).to receive(:exist?).with(w3c_fr).and_return false
251
- # expect(File).to receive(:exist?).and_call_original.at_least :once
252
- # expect(File).to receive(:write).with w3c_fr, kind_of(String), kind_of(Hash)
253
- # expect(File).to receive(:write).and_call_original.at_least :once
254
251
  VCR.use_cassette "w3c_json_ld11" do
255
252
  bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
256
253
  expect(bib).to be_instance_of RelatonW3c::W3cBibliographicItem
@@ -31,7 +31,7 @@ http_interactions:
31
31
  Content-Type:
32
32
  - text/plain; charset=utf-8
33
33
  Etag:
34
- - W/"7b1fd8c3cc8a83e47b78d925027060ef4583c418e75be5749d38f6a37e0f01ca"
34
+ - W/"ba4b443468f355962dc7524aa69c4ad80bbb98e840d6137fe420b6fa3fccf2d0"
35
35
  Strict-Transport-Security:
36
36
  - max-age=31536000
37
37
  X-Content-Type-Options:
@@ -41,29 +41,29 @@ http_interactions:
41
41
  X-Xss-Protection:
42
42
  - 1; mode=block
43
43
  X-Github-Request-Id:
44
- - FEF4:1395A:3E1BC8:42A2CE:6290BA99
44
+ - 7178:6974:A78BC:C192B:62AAF846
45
45
  Accept-Ranges:
46
46
  - bytes
47
47
  Date:
48
- - Fri, 27 May 2022 11:48:42 GMT
48
+ - Thu, 16 Jun 2022 09:30:46 GMT
49
49
  Via:
50
50
  - 1.1 varnish
51
51
  X-Served-By:
52
- - cache-vie6371-VIE
52
+ - cache-vie6334-VIE
53
53
  X-Cache:
54
54
  - MISS
55
55
  X-Cache-Hits:
56
56
  - '0'
57
57
  X-Timer:
58
- - S1653652122.797835,VS0,VE233
58
+ - S1655371847.568153,VS0,VE230
59
59
  Vary:
60
60
  - Authorization,Accept-Encoding,Origin
61
61
  Access-Control-Allow-Origin:
62
62
  - "*"
63
63
  X-Fastly-Request-Id:
64
- - 740cb118933ba3ba55fcbdb02f6f313a4eb80f39
64
+ - da76509a3e570d0b83c3692633c0dfea81acef96
65
65
  Expires:
66
- - Fri, 27 May 2022 11:53:42 GMT
66
+ - Thu, 16 Jun 2022 09:35:46 GMT
67
67
  Source-Age:
68
68
  - '0'
69
69
  body:
@@ -127,7 +127,7 @@ http_interactions:
127
127
  value: withdrawn
128
128
  place:
129
129
  - Sophia Antipolis Cedex, France
130
- fetched: '2022-04-30'
130
+ fetched: '2022-06-15'
131
131
  doctype: TR
132
132
  editorialgroup:
133
133
  - name: SMG5
@@ -143,5 +143,5 @@ http_interactions:
143
143
  freeze_stage3_meeting: SMG-28
144
144
  close_meeting: SP-28
145
145
  project_end: '1999-02-12'
146
- recorded_at: Fri, 27 May 2022 11:48:41 GMT
146
+ recorded_at: Thu, 16 Jun 2022 09:30:46 GMT
147
147
  recorded_with: VCR 6.1.0