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.
Files changed (56) 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 +13 -50
  6. data/lib/relaton/db_cache.rb +6 -6
  7. data/lib/relaton/registry.rb +28 -0
  8. data/lib/relaton/util.rb +1 -1
  9. data/lib/relaton/version.rb +1 -1
  10. data/relaton.gemspec +3 -3
  11. data/spec/relaton/db_spec.rb +24 -57
  12. data/spec/relaton/registry_spec.rb +1 -0
  13. data/spec/relaton/util_spec.rb +7 -0
  14. data/spec/relaton_spec.rb +8 -11
  15. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +10 -11
  16. data/spec/vcr_cassetes/async_fetch.yml +1374 -1461
  17. data/spec/vcr_cassetes/bipm_i18n_async_fetch.yml +620 -0
  18. data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +12 -14
  19. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +11 -13
  20. data/spec/vcr_cassetes/cie_001_1980.yml +8 -9
  21. data/spec/vcr_cassetes/ecma_6.yml +8 -9
  22. data/spec/vcr_cassetes/en_10160_1999.yml +30 -34
  23. data/spec/vcr_cassetes/fisp_140.yml +7 -8
  24. data/spec/vcr_cassetes/gb_t_20223_2006.yml +7 -9
  25. data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +10 -11
  26. data/spec/vcr_cassetes/iec_60050_102_2007.yml +24 -29
  27. data/spec/vcr_cassetes/iec_combined_included.yml +72 -87
  28. data/spec/vcr_cassetes/ieee_528_2019.yml +128 -127
  29. data/spec/vcr_cassetes/iho_b_11.yml +8 -9
  30. data/spec/vcr_cassetes/iso_111111119115_1.yml +4 -5
  31. data/spec/vcr_cassetes/iso_19115_1.yml +17 -21
  32. data/spec/vcr_cassetes/iso_19115_1_2.yml +32 -40
  33. data/spec/vcr_cassetes/iso_19115_all_parts.yml +20 -24
  34. data/spec/vcr_cassetes/iso_19133_2005.yml +19 -23
  35. data/spec/vcr_cassetes/iso_combined_applied.yml +30 -38
  36. data/spec/vcr_cassetes/iso_combined_included.yml +31 -39
  37. data/spec/vcr_cassetes/iso_dis_14093.yml +16 -20
  38. data/spec/vcr_cassetes/itu_combined_included.yml +183 -309
  39. data/spec/vcr_cassetes/oasis_amqp_core_types_v1_0_pt1.yml +11 -12
  40. data/spec/vcr_cassetes/ogc_19_025r1.yml +12 -13
  41. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +5 -6
  42. data/spec/vcr_cassetes/rfc_8341.yml +113 -26
  43. data/spec/vcr_cassetes/sp_800_38b.yml +7 -8
  44. data/spec/vcr_cassetes/threads_from_env.yml +58 -66
  45. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +30 -35
  46. data/spec/vcr_cassetes/w3c_json_ld11.yml +45 -26
  47. metadata +7 -14
  48. data/globalcache/iec/iec_60050_102_2007.xml +0 -58
  49. data/globalcache/iec/version +0 -1
  50. data/lib/relaton/static_cache/iso/iso_iec_dir_1.yml +0 -33
  51. data/lib/relaton/static_cache/iso/iso_iec_dir_1_iec_sup.yml +0 -32
  52. data/lib/relaton/static_cache/iso/iso_iec_dir_1_iso_sup.yml +0 -39
  53. data/lib/relaton/static_cache/iso/iso_iec_dir_2_iec.yml +0 -32
  54. data/lib/relaton/static_cache/iso/iso_iec_dir_2_iso.yml +0 -39
  55. data/lib/relaton/static_cache/iso/iso_iec_dir_iec_sup.yml +0 -32
  56. 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: c48be5786c54e546b11600e0b15a3b104c318c9cc991ea7bf4ef90e064e38e49
4
- data.tar.gz: 7d5080df0ee89e1b6c2b1115e6652f57b575749898ed9ea05b06e4bd074011c6
3
+ metadata.gz: bd53313a7d35f6ed1adf7669962afc84282d15d232247d3facec910aaba05270
4
+ data.tar.gz: 304a0e1c5a44731f0a4f9a30c063df920deb8694aca702044fd1ab03a10fe5e8
5
5
  SHA512:
6
- metadata.gz: 5747e84497e8268c07f1f8d922bfc46265ccf05283368ec0e090124c39a1a0d9cff46c30d15c1fba58094b6bc4f2a087becb4f3e845e83eb4796f75036263be3
7
- data.tar.gz: 6c8c00b7ed446f679e526dc50f5d9d8a14a7e8de1103fe0d2ec90e8334f7e31aea1c4de2e03960cc52c9641e992ba2b88a54901b0b1d6ed1c45b960fd57c9333
6
+ metadata.gz: 4cfb3d708769580fccb31ef09a408265a4b828e70082c7f44a2fe485c2982437cf4f8b8369ada51e7e2d9d3e05c05eada5eaca8126506ea5b9224b7575727501
7
+ data.tar.gz: 2255f0695f06f0714e55b03d9a9ad7c2b7567d417ff184e598c462e299aeed145fb6fb143fc9e83aedf7223479addd9542a6ea3d16b17298f55621676100010f
@@ -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|
@@ -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 = standard_class code
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 = standard_class(code) or return nil unless 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 = standard_class(code) or return [nil, code]
155
- _prefix, code = strip_id_wrapper(code, stdclass)
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.processors[standard_class(file.split("/")[-2])]
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..-1].each_with_object(doc) do |c, d|
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, type: :static) # rubocop:disable Metrics/MethodLength
420
+ def open_cache_biblio(dir) # rubocop:disable Metrics/MethodLength
456
421
  return nil if dir.nil?
457
422
 
458
- db = DbCache.new dir, type == :static ? "yml" : "xml"
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
- "cleared.",
468
- :warning
431
+ "cleared.", :warning
469
432
  )
470
433
  end
471
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]
@@ -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
@@ -6,7 +6,7 @@ module Relaton
6
6
  log_types = Relaton.configuration.logs.map(&:to_s) || []
7
7
 
8
8
  if log_types.include?(type.to_s)
9
- warn(message)
9
+ warn CGI.unescapeHTML(message)
10
10
  end
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.11.1".freeze
2
+ VERSION = "1.11.4".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"
@@ -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", "~> 5"
66
+ spec.add_development_dependency "vcr", "~> 6"
67
67
  spec.add_development_dependency "webmock"
68
68
  end
@@ -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
@@ -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
@@ -0,0 +1,7 @@
1
+ RSpec.describe Relaton::Util do
2
+ it "logs HTML entities" do
3
+ expect do
4
+ Relaton::Util.log("Kolbe &amp; Gr&#246;ger 2003")
5
+ end.to output("Kolbe & Gröger 2003\n").to_stderr
6
+ end
7
+ 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\" 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