relaton 1.11.1 → 1.11.4
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 +4 -4
- data/.github/workflows/rake.yml +1 -5
- data/.rubocop.yml +1 -1
- data/docs/README.adoc +0 -13
- data/lib/relaton/db.rb +13 -50
- data/lib/relaton/db_cache.rb +6 -6
- data/lib/relaton/registry.rb +28 -0
- data/lib/relaton/util.rb +1 -1
- data/lib/relaton/version.rb +1 -1
- data/relaton.gemspec +3 -3
- data/spec/relaton/db_spec.rb +24 -57
- data/spec/relaton/registry_spec.rb +1 -0
- data/spec/relaton/util_spec.rb +7 -0
- data/spec/relaton_spec.rb +8 -11
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +10 -11
- data/spec/vcr_cassetes/async_fetch.yml +1374 -1461
- data/spec/vcr_cassetes/bipm_i18n_async_fetch.yml +620 -0
- data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +12 -14
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +11 -13
- data/spec/vcr_cassetes/cie_001_1980.yml +8 -9
- data/spec/vcr_cassetes/ecma_6.yml +8 -9
- data/spec/vcr_cassetes/en_10160_1999.yml +30 -34
- data/spec/vcr_cassetes/fisp_140.yml +7 -8
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +7 -9
- data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +10 -11
- data/spec/vcr_cassetes/iec_60050_102_2007.yml +24 -29
- data/spec/vcr_cassetes/iec_combined_included.yml +72 -87
- data/spec/vcr_cassetes/ieee_528_2019.yml +128 -127
- data/spec/vcr_cassetes/iho_b_11.yml +8 -9
- data/spec/vcr_cassetes/iso_111111119115_1.yml +4 -5
- data/spec/vcr_cassetes/iso_19115_1.yml +17 -21
- data/spec/vcr_cassetes/iso_19115_1_2.yml +32 -40
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +20 -24
- data/spec/vcr_cassetes/iso_19133_2005.yml +19 -23
- data/spec/vcr_cassetes/iso_combined_applied.yml +30 -38
- data/spec/vcr_cassetes/iso_combined_included.yml +31 -39
- data/spec/vcr_cassetes/iso_dis_14093.yml +16 -20
- data/spec/vcr_cassetes/itu_combined_included.yml +183 -309
- data/spec/vcr_cassetes/oasis_amqp_core_types_v1_0_pt1.yml +11 -12
- data/spec/vcr_cassetes/ogc_19_025r1.yml +12 -13
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +5 -6
- data/spec/vcr_cassetes/rfc_8341.yml +113 -26
- data/spec/vcr_cassetes/sp_800_38b.yml +7 -8
- data/spec/vcr_cassetes/threads_from_env.yml +58 -66
- data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +30 -35
- data/spec/vcr_cassetes/w3c_json_ld11.yml +45 -26
- metadata +7 -14
- data/globalcache/iec/iec_60050_102_2007.xml +0 -58
- data/globalcache/iec/version +0 -1
- data/lib/relaton/static_cache/iso/iso_iec_dir_1.yml +0 -33
- data/lib/relaton/static_cache/iso/iso_iec_dir_1_iec_sup.yml +0 -32
- data/lib/relaton/static_cache/iso/iso_iec_dir_1_iso_sup.yml +0 -39
- data/lib/relaton/static_cache/iso/iso_iec_dir_2_iec.yml +0 -32
- data/lib/relaton/static_cache/iso/iso_iec_dir_2_iso.yml +0 -39
- data/lib/relaton/static_cache/iso/iso_iec_dir_iec_sup.yml +0 -32
- 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd53313a7d35f6ed1adf7669962afc84282d15d232247d3facec910aaba05270
|
|
4
|
+
data.tar.gz: 304a0e1c5a44731f0a4f9a30c063df920deb8694aca702044fd1ab03a10fe5e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cfb3d708769580fccb31ef09a408265a4b828e70082c7f44a2fe485c2982437cf4f8b8369ada51e7e2d9d3e05c05eada5eaca8126506ea5b9224b7575727501
|
|
7
|
+
data.tar.gz: 2255f0695f06f0714e55b03d9a9ad7c2b7567d417ff184e598c462e299aeed145fb6fb143fc9e83aedf7223479addd9542a6ea3d16b17298f55621676100010f
|
data/.github/workflows/rake.yml
CHANGED
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
strategy:
|
|
17
17
|
fail-fast: false
|
|
18
18
|
matrix:
|
|
19
|
-
ruby: [ '3.0', '2.7', '2.6'
|
|
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
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
|
|
14
|
+
@db = open_cache_biblio(gpath)
|
|
15
15
|
lpath = local_cache && File.expand_path(local_cache)
|
|
16
|
-
@local_db = open_cache_biblio(lpath
|
|
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 =
|
|
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 =
|
|
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|
|
|
@@ -101,7 +97,7 @@ module Relaton
|
|
|
101
97
|
|
|
102
98
|
# Fetch asynchronously
|
|
103
99
|
def fetch_async(code, year = nil, opts = {}, &block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
104
|
-
stdclass =
|
|
100
|
+
stdclass = @registry.class_by_ref code
|
|
105
101
|
if stdclass
|
|
106
102
|
unless @queues[stdclass]
|
|
107
103
|
processor = @registry.processors[stdclass]
|
|
@@ -142,7 +138,7 @@ module Relaton
|
|
|
142
138
|
@registry.processors.each do |name, processor|
|
|
143
139
|
std = name if processor.prefix == stdclass
|
|
144
140
|
end
|
|
145
|
-
std =
|
|
141
|
+
std = @registry.class_by_ref(code) or return nil unless std
|
|
146
142
|
|
|
147
143
|
check_bibliocache(code, year, opts, std)
|
|
148
144
|
end
|
|
@@ -151,8 +147,8 @@ module Relaton
|
|
|
151
147
|
# @param code [String]
|
|
152
148
|
# @return [Array]
|
|
153
149
|
def docid_type(code)
|
|
154
|
-
stdclass =
|
|
155
|
-
|
|
150
|
+
stdclass = @registry.class_by_ref(code) or return [nil, code]
|
|
151
|
+
_, code = strip_id_wrapper(code, stdclass)
|
|
156
152
|
[@registry.processors[stdclass].idtype, code]
|
|
157
153
|
end
|
|
158
154
|
|
|
@@ -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
|
|
@@ -218,7 +201,7 @@ module Relaton
|
|
|
218
201
|
# @param year [Integer, nil] year to filter
|
|
219
202
|
# @return [BibliographicItem, nil]
|
|
220
203
|
def search_edition_year(file, content, edition, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
221
|
-
processor = @registry.
|
|
204
|
+
processor = @registry.processor_by_ref(file.split("/")[-2])
|
|
222
205
|
item = if file.match?(/xml$/) then processor.from_xml(content)
|
|
223
206
|
else processor.hash_to_bib(YAML.safe_load(content))
|
|
224
207
|
end
|
|
@@ -269,7 +252,7 @@ module Relaton
|
|
|
269
252
|
type: "updates")
|
|
270
253
|
end
|
|
271
254
|
divider = stdclass == :relaton_itu ? " " : "/"
|
|
272
|
-
refs[1
|
|
255
|
+
refs[1..].each_with_object(doc) do |c, d|
|
|
273
256
|
bib = check_bibliocache(ref + divider + c, year, opts, stdclass)
|
|
274
257
|
if bib
|
|
275
258
|
d.relation << RelatonBib::DocumentRelation.new(
|
|
@@ -279,18 +262,6 @@ module Relaton
|
|
|
279
262
|
end
|
|
280
263
|
end
|
|
281
264
|
|
|
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
265
|
# TODO: i18n
|
|
295
266
|
# Fofmat ID
|
|
296
267
|
# @param code [String]
|
|
@@ -358,11 +329,6 @@ module Relaton
|
|
|
358
329
|
# RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
|
|
359
330
|
def check_bibliocache(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
360
331
|
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
332
|
db = @local_db || @db
|
|
367
333
|
altdb = @local_db && @db ? @db : nil
|
|
368
334
|
if db.nil?
|
|
@@ -450,13 +416,11 @@ module Relaton
|
|
|
450
416
|
end
|
|
451
417
|
|
|
452
418
|
# @param dir [String, nil] DB directory
|
|
453
|
-
# @param type [Symbol]
|
|
454
419
|
# @return [Relaton::DbCache, NilClass]
|
|
455
|
-
def open_cache_biblio(dir
|
|
420
|
+
def open_cache_biblio(dir) # rubocop:disable Metrics/MethodLength
|
|
456
421
|
return nil if dir.nil?
|
|
457
422
|
|
|
458
|
-
db = DbCache.new dir
|
|
459
|
-
return db if type == :static
|
|
423
|
+
db = DbCache.new dir
|
|
460
424
|
|
|
461
425
|
Dir["#{dir}/*/"].each do |fdir|
|
|
462
426
|
next if db.check_version?(fdir)
|
|
@@ -464,8 +428,7 @@ module Relaton
|
|
|
464
428
|
FileUtils.rm_rf(fdir, secure: true)
|
|
465
429
|
Util.log(
|
|
466
430
|
"[relaton] WARNING: cache #{fdir}: version is obsolete and cache is "\
|
|
467
|
-
|
|
468
|
-
:warning
|
|
431
|
+
"cleared.", :warning
|
|
469
432
|
)
|
|
470
433
|
end
|
|
471
434
|
db
|
data/lib/relaton/db_cache.rb
CHANGED
|
@@ -32,7 +32,7 @@ module Relaton
|
|
|
32
32
|
|
|
33
33
|
# Clear database
|
|
34
34
|
def clear
|
|
35
|
-
FileUtils.rm_rf Dir.glob "#{dir}/*"
|
|
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?
|
|
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
|
|
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
|
|
182
|
+
prefcode = key.downcase.match(/^(?<prefix>[^(]+)\((?<code>[^)]+)/)
|
|
183
183
|
fn = if prefcode
|
|
184
|
-
"#{prefcode[:prefix]}/#{prefcode[:code].gsub(/[-:\s
|
|
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(/^[
|
|
211
|
+
key.downcase.match(/^[^(]+(?=\()/).to_s
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
# @param file [String]
|
data/lib/relaton/registry.rb
CHANGED
|
@@ -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)
|
data/lib/relaton/util.rb
CHANGED
data/lib/relaton/version.rb
CHANGED
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.
|
|
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"
|
|
@@ -63,6 +63,6 @@ Gem::Specification.new do |spec|
|
|
|
63
63
|
spec.add_development_dependency "rubocop-rails", "~> 2.10.0"
|
|
64
64
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
|
65
65
|
spec.add_development_dependency "timecop", "~> 0.9"
|
|
66
|
-
spec.add_development_dependency "vcr", "~>
|
|
66
|
+
spec.add_development_dependency "vcr", "~> 6"
|
|
67
67
|
spec.add_development_dependency "webmock"
|
|
68
68
|
end
|
data/spec/relaton/db_spec.rb
CHANGED
|
@@ -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
|
|
79
|
-
expect(items[
|
|
80
|
-
expect(items[
|
|
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
|
|
97
|
-
expect(items[
|
|
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)
|
|
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
|
|
@@ -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
|
|
199
|
-
|
|
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
|
|
202
|
-
|
|
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/"
|
|
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
|
-
-
|
|
44
|
+
- 7178:6974:A78BC:C192B:62AAF846
|
|
45
45
|
Accept-Ranges:
|
|
46
46
|
- bytes
|
|
47
47
|
Date:
|
|
48
|
-
-
|
|
48
|
+
- Thu, 16 Jun 2022 09:30:46 GMT
|
|
49
49
|
Via:
|
|
50
50
|
- 1.1 varnish
|
|
51
51
|
X-Served-By:
|
|
52
|
-
- cache-
|
|
52
|
+
- cache-vie6334-VIE
|
|
53
53
|
X-Cache:
|
|
54
54
|
- MISS
|
|
55
55
|
X-Cache-Hits:
|
|
56
56
|
- '0'
|
|
57
57
|
X-Timer:
|
|
58
|
-
-
|
|
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
|
-
-
|
|
64
|
+
- da76509a3e570d0b83c3692633c0dfea81acef96
|
|
65
65
|
Expires:
|
|
66
|
-
-
|
|
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-
|
|
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
|
-
|
|
147
|
-
|
|
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
|