relaton 1.11.2 → 1.11.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -5
  3. data/.rubocop.yml +1 -1
  4. data/docs/README.adoc +0 -13
  5. data/lib/relaton/db.rb +29 -54
  6. data/lib/relaton/db_cache.rb +6 -6
  7. data/lib/relaton/registry.rb +28 -0
  8. data/lib/relaton/version.rb +1 -1
  9. data/relaton.gemspec +2 -2
  10. data/spec/relaton/db_spec.rb +40 -57
  11. data/spec/relaton/registry_spec.rb +1 -0
  12. data/spec/relaton_spec.rb +8 -11
  13. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +10 -11
  14. data/spec/vcr_cassetes/async_fetch.yml +1374 -1461
  15. data/spec/vcr_cassetes/bipm_i18n_async_fetch.yml +620 -0
  16. data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +12 -14
  17. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +11 -13
  18. data/spec/vcr_cassetes/cie_001_1980.yml +8 -9
  19. data/spec/vcr_cassetes/ecma_6.yml +8 -9
  20. data/spec/vcr_cassetes/en_10160_1999.yml +30 -34
  21. data/spec/vcr_cassetes/fisp_140.yml +7 -8
  22. data/spec/vcr_cassetes/gb_t_20223_2006.yml +7 -9
  23. data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +10 -11
  24. data/spec/vcr_cassetes/iec_60050_102_2007.yml +24 -29
  25. data/spec/vcr_cassetes/iec_combined_included.yml +72 -87
  26. data/spec/vcr_cassetes/ieee_528_2019.yml +128 -127
  27. data/spec/vcr_cassetes/iho_b_11.yml +8 -9
  28. data/spec/vcr_cassetes/iso_111111119115_1.yml +4 -5
  29. data/spec/vcr_cassetes/iso_19115_1.yml +17 -21
  30. data/spec/vcr_cassetes/iso_19115_1_2.yml +32 -40
  31. data/spec/vcr_cassetes/iso_19115_all_parts.yml +20 -24
  32. data/spec/vcr_cassetes/iso_19133_2005.yml +19 -23
  33. data/spec/vcr_cassetes/iso_combined_applied.yml +30 -38
  34. data/spec/vcr_cassetes/iso_combined_included.yml +31 -39
  35. data/spec/vcr_cassetes/iso_dis_14093.yml +16 -20
  36. data/spec/vcr_cassetes/itu_combined_included.yml +183 -309
  37. data/spec/vcr_cassetes/oasis_amqp_core_types_v1_0_pt1.yml +11 -12
  38. data/spec/vcr_cassetes/ogc_19_025r1.yml +12 -13
  39. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +5 -6
  40. data/spec/vcr_cassetes/rfc_8341.yml +113 -26
  41. data/spec/vcr_cassetes/sp_800_38b.yml +7 -8
  42. data/spec/vcr_cassetes/threads_from_env.yml +58 -66
  43. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +30 -35
  44. data/spec/vcr_cassetes/w3c_json_ld11.yml +45 -26
  45. metadata +4 -12
  46. data/globalcache/iec/iec_60050_102_2007.xml +0 -58
  47. data/globalcache/iec/version +0 -1
  48. data/lib/relaton/static_cache/iso/iso_iec_dir_1.yml +0 -33
  49. data/lib/relaton/static_cache/iso/iso_iec_dir_1_iec_sup.yml +0 -32
  50. data/lib/relaton/static_cache/iso/iso_iec_dir_1_iso_sup.yml +0 -39
  51. data/lib/relaton/static_cache/iso/iso_iec_dir_2_iec.yml +0 -32
  52. data/lib/relaton/static_cache/iso/iso_iec_dir_2_iso.yml +0 -39
  53. data/lib/relaton/static_cache/iso/iso_iec_dir_iec_sup.yml +0 -32
  54. 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: 451c0d9a82ae4722a2840928ff36a7c9f352dcfd5a2a3c6356eb0629d18141dd
4
- data.tar.gz: 2f68099b406013f4a9a4bcc080aeb771060fba85db058251ad78e98ec5989ab8
3
+ metadata.gz: 4c30099df631e2cbb313f936f4d6a339d9a0767c6d81f3e9523f6013ce95e77a
4
+ data.tar.gz: 9413dc9a5806d1b7a997c68298029407a5bc5fb0daa92e8c7f19c66b8b285bd3
5
5
  SHA512:
6
- metadata.gz: da891dd5fb56ea1c68ebf14d88aae5db6c0b861e6d48bac73686ce572b60be8f919145cb53c179521b91b68a22ef3b694156e4b0599553f900a7a842a24300d3
7
- data.tar.gz: 5e2cac57ca860937d708dcba84516947f8952ff6b3f7df51811dc54ef4d1f2e97c660a77a6f4f65ce6d87f010e2d556834d940d2baef72f7c27fe156d1bd8fcc
6
+ metadata.gz: 33f734e4a386c381de112a99f649c54a586c1367cf91065a693235c8c7252a414a38bffa589de960c3cb4564ab08a0311557c38e08804566ac06a8baf6207de7
7
+ data.tar.gz: d0e46c2f6ad5ac0263de42c693db297786b583da4a9b86fe2f3db9f2807e6fdd98c9934ff892d362f1e6a53f2c6cf9a8856b66f405b7fc8270c99f198b9a46b3
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
19
+ ruby: [ '3.0', '2.7', '2.6' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  steps:
@@ -24,10 +24,6 @@ jobs:
24
24
  with:
25
25
  submodules: true
26
26
 
27
- # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
28
- - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
29
- run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
30
-
31
27
  - uses: ruby/setup-ruby@v1
32
28
  with:
33
29
  ruby-version: ${{ matrix.ruby }}
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.5
10
+ TargetRubyVersion: 2.6
11
11
  Rails:
12
12
  Enabled: false
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
@@ -63,7 +61,7 @@ module Relaton
63
61
  # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
64
62
  ##
65
63
  def fetch(code, year = nil, opts = {})
66
- stdclass = standard_class(code) || return
64
+ stdclass = @registry.class_by_ref(code) || return
67
65
  processor = @registry.processors[stdclass]
68
66
  ref = if processor.respond_to?(:urn_to_code)
69
67
  processor.urn_to_code(code)&.first
@@ -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|
@@ -99,9 +95,18 @@ module Relaton
99
95
  result
100
96
  end
101
97
 
98
+ #
102
99
  # Fetch asynchronously
103
- def fetch_async(code, year = nil, opts = {}, &block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
104
- stdclass = standard_class code
100
+ #
101
+ # @param [String] ref reference
102
+ # @param [String] year document yer
103
+ # @param [Hash] opts options
104
+ #
105
+ # @return [RelatonBib::BibliographicItem, RelatonBib::RequestError, nil] bibitem if document is found,
106
+ # request error if server doesn't answer, nil if document not found
107
+ #
108
+ def fetch_async(ref, year = nil, opts = {}, &block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
109
+ stdclass = @registry.class_by_ref ref
105
110
  if stdclass
106
111
  unless @queues[stdclass]
107
112
  processor = @registry.processors[stdclass]
@@ -110,11 +115,14 @@ module Relaton
110
115
  args[3].call fetch(*args[0..2])
111
116
  rescue RelatonBib::RequestError => e
112
117
  args[3].call e
118
+ rescue StandardError => e
119
+ Util.log "[relaton] ERROR: #{args[0]} -- #{e.message}", :error
120
+ args[3].call nil
113
121
  end
114
122
  @queues[stdclass] = { queue: Queue.new, workers_pool: wp }
115
123
  Thread.new { process_queue @queues[stdclass] }
116
124
  end
117
- @queues[stdclass][:queue] << [code, year, opts, block]
125
+ @queues[stdclass][:queue] << [ref, year, opts, block]
118
126
  else yield nil
119
127
  end
120
128
  end
@@ -142,7 +150,7 @@ module Relaton
142
150
  @registry.processors.each do |name, processor|
143
151
  std = name if processor.prefix == stdclass
144
152
  end
145
- std = standard_class(code) or return nil unless std
153
+ std = @registry.class_by_ref(code) or return nil unless std
146
154
 
147
155
  check_bibliocache(code, year, opts, std)
148
156
  end
@@ -151,8 +159,8 @@ module Relaton
151
159
  # @param code [String]
152
160
  # @return [Array]
153
161
  def docid_type(code)
154
- stdclass = standard_class(code) or return [nil, code]
155
- _prefix, code = strip_id_wrapper(code, stdclass)
162
+ stdclass = @registry.class_by_ref(code) or return [nil, code]
163
+ _, code = strip_id_wrapper(code, stdclass)
156
164
  [@registry.processors[stdclass].idtype, code]
157
165
  end
158
166
 
@@ -187,19 +195,6 @@ module Relaton
187
195
 
188
196
  private
189
197
 
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
198
  # @param file [String] file path
204
199
  # @param xml [String] content in XML format
205
200
  # @param text [String, nil] text to serach
@@ -218,7 +213,7 @@ module Relaton
218
213
  # @param year [Integer, nil] year to filter
219
214
  # @return [BibliographicItem, nil]
220
215
  def search_edition_year(file, content, edition, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
221
- processor = @registry.processors[standard_class(file.split("/")[-2])]
216
+ processor = @registry.processor_by_ref(file.split("/")[-2])
222
217
  item = if file.match?(/xml$/) then processor.from_xml(content)
223
218
  else processor.hash_to_bib(YAML.safe_load(content))
224
219
  end
@@ -269,7 +264,7 @@ module Relaton
269
264
  type: "updates")
270
265
  end
271
266
  divider = stdclass == :relaton_itu ? " " : "/"
272
- refs[1..-1].each_with_object(doc) do |c, d|
267
+ refs[1..].each_with_object(doc) do |c, d|
273
268
  bib = check_bibliocache(ref + divider + c, year, opts, stdclass)
274
269
  if bib
275
270
  d.relation << RelatonBib::DocumentRelation.new(
@@ -279,18 +274,6 @@ module Relaton
279
274
  end
280
275
  end
281
276
 
282
- # @param code [String] code of standard
283
- # @return [Symbol] standard class name
284
- def standard_class(code)
285
- @registry.processors.each do |name, processor|
286
- return name if /^(urn:)?#{processor.prefix}/i.match?(code) ||
287
- processor.defaultprefix.match(code)
288
- end
289
- Util.log <<~WARN, :info
290
- [relaton] #{code} does not have a recognised prefix
291
- WARN
292
- end
293
-
294
277
  # TODO: i18n
295
278
  # Fofmat ID
296
279
  # @param code [String]
@@ -358,11 +341,6 @@ module Relaton
358
341
  # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
359
342
  def check_bibliocache(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
360
343
  id, searchcode = std_id(code, year, opts, stdclass)
361
- yaml = @static_db[id]
362
- if yaml
363
- return @registry.processors[stdclass].hash_to_bib YAML.safe_load(yaml)
364
- end
365
-
366
344
  db = @local_db || @db
367
345
  altdb = @local_db && @db ? @db : nil
368
346
  if db.nil?
@@ -390,8 +368,8 @@ module Relaton
390
368
  else
391
369
  return bib_retval(db[id], stdclass) if opts[:fetch_db]
392
370
 
393
- db[id] ||= new_bib_entry(searchcode, year, opts, stdclass, db: db,
394
- id: id)
371
+ entry = new_bib_entry(searchcode, year, opts, stdclass, db: db, id: id) unless db[id]
372
+ @semaphore.synchronize { db[id] ||= entry }
395
373
  end
396
374
  bib_retval(db[id], stdclass)
397
375
  end
@@ -450,13 +428,11 @@ module Relaton
450
428
  end
451
429
 
452
430
  # @param dir [String, nil] DB directory
453
- # @param type [Symbol]
454
431
  # @return [Relaton::DbCache, NilClass]
455
- def open_cache_biblio(dir, type: :static) # rubocop:disable Metrics/MethodLength
432
+ def open_cache_biblio(dir) # rubocop:disable Metrics/MethodLength
456
433
  return nil if dir.nil?
457
434
 
458
- db = DbCache.new dir, type == :static ? "yml" : "xml"
459
- return db if type == :static
435
+ db = DbCache.new dir
460
436
 
461
437
  Dir["#{dir}/*/"].each do |fdir|
462
438
  next if db.check_version?(fdir)
@@ -464,8 +440,7 @@ module Relaton
464
440
  FileUtils.rm_rf(fdir, secure: true)
465
441
  Util.log(
466
442
  "[relaton] WARNING: cache #{fdir}: version is obsolete and cache is "\
467
- "cleared.",
468
- :warning
443
+ "cleared.", :warning
469
444
  )
470
445
  end
471
446
  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]
@@ -77,6 +77,34 @@ module Relaton
77
77
  processors.values.detect { |v| v.prefix == type&.upcase }
78
78
  end
79
79
 
80
+ #
81
+ # Find processor by reference or prefix
82
+ #
83
+ # @param [String] ref reference or prefix
84
+ #
85
+ # @return [Relaton::Processor] processor
86
+ #
87
+ def processor_by_ref(ref)
88
+ @processors[class_by_ref(ref)]
89
+ end
90
+
91
+ #
92
+ # Find processor by refernce or prefix
93
+ #
94
+ # @param ref [String] reference or prefix
95
+ #
96
+ # @return [Symbol, nil] standard class name
97
+ #
98
+ def class_by_ref(ref)
99
+ @processors.each do |class_name, processor|
100
+ return class_name if /^(urn:)?#{processor.prefix}(?!\w)/i.match?(ref) ||
101
+ processor.defaultprefix.match(ref)
102
+ end
103
+ Util.log <<~WARN, :info
104
+ [relaton] #{ref} does not have a recognised prefix
105
+ WARN
106
+ end
107
+
80
108
  private
81
109
 
82
110
  def camel_case(gem_name)
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.11.2".freeze
2
+ VERSION = "1.11.5".freeze
3
3
  end
data/relaton.gemspec CHANGED
@@ -26,8 +26,8 @@ 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")
30
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
29
+ # spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
31
31
 
32
32
  spec.add_dependency "relaton-3gpp", "~> 1.11.0"
33
33
  spec.add_dependency "relaton-bipm", "~> 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
@@ -185,6 +198,22 @@ RSpec.describe Relaton::Db do
185
198
  expect(result).to be_nil
186
199
  end
187
200
 
201
+ it "handle HTTP request error" do
202
+ expect(db).to receive(:fetch).and_raise RelatonBib::RequestError
203
+ db.fetch_async("ISO REF") { |r| queue << r }
204
+ result = Timeout.timeout(5) { queue.pop }
205
+ expect(result).to be_instance_of RelatonBib::RequestError
206
+ end
207
+
208
+ it "handle other errors" do
209
+ expect(db).to receive(:fetch).and_raise Errno::EACCES
210
+ expect do
211
+ db.fetch_async("ISO REF") { |r| queue << r }
212
+ result = Timeout.timeout(5) { queue.pop }
213
+ expect(result).to be_nil
214
+ end.to output("[relaton] ERROR: ISO REF -- Permission denied\n").to_stderr
215
+ end
216
+
188
217
  it "use threads number from RELATON_FETCH_PARALLEL" do
189
218
  expect(ENV).to receive(:[]).with("RELATON_FETCH_PARALLEL").and_return(1)
190
219
  allow(ENV).to receive(:[]).and_call_original
@@ -195,50 +224,4 @@ RSpec.describe Relaton::Db do
195
224
  end
196
225
  end
197
226
  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
227
  end
@@ -70,6 +70,7 @@ RSpec.describe Relaton::Registry do
70
70
 
71
71
  it "BIPM" do
72
72
  expect(Relaton::Registry.instance.by_type("BIPM")).to be_instance_of RelatonBipm::Processor
73
+ expect(Relaton::Registry.instance.processor_by_ref("CCTF")).to be_instance_of RelatonBipm::Processor
73
74
  end
74
75
 
75
76
  it "ECMA" do
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\" scope=\"anchor\">RFC8341</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\" scope=\"anchor\">RFC8341</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
- - 687A:10CE7:F2C38C:107FE9E:6278EE7D
44
+ - 7178:6974:A78BC:C192B:62AAF846
45
45
  Accept-Ranges:
46
46
  - bytes
47
47
  Date:
48
- - Mon, 09 May 2022 10:35:41 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-vie6353-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
- - S1652092541.458281,VS0,VE220
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
- - bc2e33f28bbade3cfbf583259d99518383e6f9f3
64
+ - da76509a3e570d0b83c3692633c0dfea81acef96
65
65
  Expires:
66
- - Mon, 09 May 2022 10:40:41 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,6 +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
- http_version:
147
- recorded_at: Mon, 09 May 2022 10:35:41 GMT
148
- recorded_with: VCR 5.1.0
146
+ recorded_at: Thu, 16 Jun 2022 09:30:46 GMT
147
+ recorded_with: VCR 6.1.0