relaton 1.19.1 → 1.19.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a133026bf858511b0385b639ec7cc96ab0f855c31a5446d1d118d009eda235d
4
- data.tar.gz: b9b89a70476bf01a6c9ca710047ccf13f4531174dafa12e5b37908bdf668d44c
3
+ metadata.gz: 7df2abbb732f8ab1fedc92f73e6f313af63075e1cf8f5e0cab2883d7abeaa448
4
+ data.tar.gz: 8915346acdf65d4a129da2b982b07429a5d4c5352874c230adf3189c670d677c
5
5
  SHA512:
6
- metadata.gz: d35962b592b2eb4ed65261bed9638d304bd91ffc09baf1cb40c7e245692381b28d6d4985fe321d326d09770afa738ea3cce1e15ab499501d4221228559051140
7
- data.tar.gz: 46d9116df1ae0f23d7aea5763908bb4b5ac3ec3073d2bbd8b67578c94b85ab5ab89f327747f420ca2226409955ff78de41a4eeabd7992cb32383491386a45b99
6
+ metadata.gz: 3978d4e5a0e4ab36f49998140d18b9d57e3bce51c943c294fabf04ca16314ebe55cd470fc4de791d9a0c5c274cff0b7fdb889a3d3ca0ebb868cc4a4bcb154d86
7
+ data.tar.gz: 86462982a81ebde5250a3b3c2b95d5f6b9859af635a2a624276af15272f7479a95372de8336d9507ddd150e2af9c684b35de3c85e5ffc29ec4044ffefb79ff5d
data/lib/relaton/db.rb CHANGED
@@ -28,6 +28,7 @@ module Relaton
28
28
  @db&.clear
29
29
  @local_db&.clear
30
30
  @registry.processors.each_value do |p|
31
+ require p.short.to_s
31
32
  p.remove_index_file if p.respond_to? :remove_index_file
32
33
  end
33
34
  end
@@ -59,7 +60,7 @@ module Relaton
59
60
  def fetch(text, year = nil, opts = {})
60
61
  reference = text.strip
61
62
  stdclass = @registry.class_by_ref(reference) || return
62
- processor = @registry.processors[stdclass]
63
+ processor = @registry[stdclass]
63
64
  ref = if processor.respond_to?(:urn_to_code)
64
65
  processor.urn_to_code(reference)&.first
65
66
  else reference
@@ -105,7 +106,7 @@ module Relaton
105
106
  stdclass = @registry.class_by_ref ref
106
107
  if stdclass
107
108
  unless @queues[stdclass]
108
- processor = @registry.processors[stdclass]
109
+ processor = @registry[stdclass]
109
110
  threads = ENV["RELATON_FETCH_PARALLEL"]&.to_i || processor.threads
110
111
  wp = WorkersPool.new(threads) do |args|
111
112
  args[3].call fetch(*args[0..2])
@@ -157,7 +158,7 @@ module Relaton
157
158
  def docid_type(code)
158
159
  stdclass = @registry.class_by_ref(code) or return [nil, code]
159
160
  _, code = strip_id_wrapper(code, stdclass)
160
- [@registry.processors[stdclass].idtype, code]
161
+ [@registry[stdclass].idtype, code]
161
162
  end
162
163
 
163
164
  # @param key [String]
@@ -293,7 +294,7 @@ module Relaton
293
294
  else return
294
295
  end
295
296
 
296
- doc = @registry.processors[stdclass].hash_to_bib docid: { id: code }
297
+ doc = @registry[stdclass].hash_to_bib docid: { id: code }
297
298
  ref = refs[0]
298
299
  updates = check_bibliocache(refs[0], year, opts, stdclass)
299
300
  if updates
@@ -336,7 +337,7 @@ module Relaton
336
337
  # @param stdClass [Symbol]
337
338
  # @return [Array]
338
339
  def strip_id_wrapper(code, stdclass)
339
- prefix = @registry.processors[stdclass].prefix
340
+ prefix = @registry[stdclass].prefix
340
341
  code = code.sub(/\u2013/, "-").sub(/^#{prefix}\((.+)\)$/, "\\1")
341
342
  [prefix, code]
342
343
  end
@@ -355,7 +356,7 @@ module Relaton
355
356
  # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
356
357
  def bib_retval(entry, stdclass)
357
358
  if entry && !entry.match?(/^not_found/)
358
- @registry.processors[stdclass].from_xml(entry)
359
+ @registry[stdclass].from_xml(entry)
359
360
  end
360
361
  end
361
362
 
@@ -443,7 +444,7 @@ module Relaton
443
444
  end
444
445
 
445
446
  def fetch_entry(code, year, opts, stdclass, **args)
446
- processor = @registry.processors[stdclass]
447
+ processor = @registry[stdclass]
447
448
  bib = net_retry(code, year, opts, processor, opts.fetch(:retries, 1))
448
449
 
449
450
  entry = check_entry(bib, stdclass, **args)
@@ -26,7 +26,6 @@ module Relaton
26
26
  # Util.info("Info: detecting backends:")
27
27
 
28
28
  SUPPORTED_GEMS.each do |b|
29
- require b
30
29
  require "#{b}/processor"
31
30
  register Kernel.const_get "#{camel_case(b)}::Processor"
32
31
  rescue LoadError => e
@@ -61,7 +60,7 @@ module Relaton
61
60
  # @return [Relaton::Processor, nil]
62
61
  #
63
62
  def find_processor_by_dataset(dataset)
64
- processors.values.detect { |p| p.datasets&.include? dataset }
63
+ require_gem(processors.values.detect { |p| p.datasets&.include? dataset })
65
64
  end
66
65
 
67
66
  #
@@ -73,7 +72,18 @@ module Relaton
73
72
  # RelatonGb::Processor, RelatonOgc::Processor,
74
73
  # RelatonCalconnect::Processor]
75
74
  def by_type(type)
76
- processors.values.detect { |v| v.prefix == type&.upcase }
75
+ require_gem(processors.values.detect { |v| v.prefix == type&.upcase })
76
+ end
77
+
78
+ def [](stdclass)
79
+ require_gem processors[stdclass]
80
+ end
81
+
82
+ def require_gem(processor)
83
+ return unless processor
84
+
85
+ require processor.short.to_s
86
+ processor
77
87
  end
78
88
 
79
89
  #
@@ -84,7 +94,7 @@ module Relaton
84
94
  # @return [Relaton::Processor] processor
85
95
  #
86
96
  def processor_by_ref(ref)
87
- @processors[class_by_ref(ref)]
97
+ require_gem processors[class_by_ref(ref)]
88
98
  end
89
99
 
90
100
  #
@@ -95,7 +105,7 @@ module Relaton
95
105
  # @return [Symbol, nil] standard class name
96
106
  #
97
107
  def class_by_ref(ref)
98
- ref = ref.match(/^\w+\((.*)\)$/) ? Regexp.last_match(1) : ref
108
+ ref = ref =~ /^\w+\((.*)\)$/ ? Regexp.last_match(1) : ref
99
109
  @processors.each do |class_name, processor|
100
110
  return class_name if /^(urn:)?#{processor.prefix}\b/i.match?(ref) ||
101
111
  processor.defaultprefix.match(ref)
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.19.1".freeze
2
+ VERSION = "1.19.2".freeze
3
3
  end
@@ -17,7 +17,7 @@ RSpec.describe Relaton::Processor do
17
17
  end
18
18
 
19
19
  it "fetch_data method should be implemented" do
20
- expect { subject.fetch_data "cource", {} }.to raise_error StandardError
20
+ expect { subject.fetch_data "source", {} }.to raise_error StandardError
21
21
  end
22
22
 
23
23
  it "from_xml method should be implemented" do
@@ -43,7 +43,7 @@ RSpec.describe Relaton::Processor do
43
43
 
44
44
  it "get method should call get method of #{flavor}" do
45
45
  expect(bibliography).to receive(:get).with("code", nil, {}).and_return :item
46
- expect(processor.get "code", nil, {}).to eq :item
46
+ expect(processor.get("code", nil, {})).to eq :item
47
47
  end
48
48
 
49
49
  it "grammar_hash method should call grammar_hash method of #{flavor}" do
@@ -58,7 +58,7 @@ RSpec.describe Relaton::Processor do
58
58
 
59
59
  it "fetch_data method should call fetch_data method of #{flavor}" do
60
60
  expect(fetcher_class).to receive(:fetch).with(output: "dir", format: "bibxml").and_return :item
61
- expect(processor.fetch_data source, output: "dir", format: "bibxml").to eq :item
61
+ expect(processor.fetch_data(source, output: "dir", format: "bibxml")).to eq :item
62
62
  end
63
63
  end
64
64
 
@@ -68,7 +68,7 @@ RSpec.describe Relaton::Processor do
68
68
 
69
69
  it "from_xml method should call from_xml method of #{flavor}" do
70
70
  expect(parser_class).to receive(:from_xml).with("xml").and_return :item
71
- expect(processor.from_xml "xml").to eq :item
71
+ expect(processor.from_xml("xml")).to eq :item
72
72
  end
73
73
  end
74
74
 
data/spec/relaton_spec.rb CHANGED
@@ -490,7 +490,7 @@ RSpec.describe Relaton::Db do
490
490
  it "should clear cache if version is changed" do
491
491
  expect(File.read("testcache/iso/version", encoding: "UTF-8")).not_to eq "new_version"
492
492
  expect(File.read("testcache2/iso/version", encoding: "UTF-8")).not_to eq "new_version"
493
- processor = double
493
+ processor = double "processor", short: :relaton_iso
494
494
  expect(processor).to receive(:grammar_hash).and_return("new_version").exactly(2).times
495
495
  expect(Relaton::Registry.instance).to receive(:by_type).and_return(processor).exactly(2).times
496
496
  Relaton::Db.new "testcache", "testcache2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.19.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-25 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-3gpp