relaton 1.19.0 → 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 +4 -4
- data/lib/relaton/db.rb +8 -7
- data/lib/relaton/registry.rb +19 -7
- data/lib/relaton/version.rb +1 -1
- data/relaton.gemspec +1 -0
- data/spec/relaton/processor_spec.rb +4 -4
- data/spec/relaton/registry_spec.rb +36 -0
- data/spec/relaton_spec.rb +10 -1
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +12200 -11280
- data/spec/vcr_cassetes/api_relaton_org.yml +8 -8
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +11 -11
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +14 -14
- data/spec/vcr_cassetes/cie_001_1980.yml +21 -21
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +6 -6
- data/spec/vcr_cassetes/ecma_6.yml +133 -133
- data/spec/vcr_cassetes/en_10160_1999.yml +10168 -10170
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +413 -419
- data/spec/vcr_cassetes/ieee_528_2019.yml +2157 -2149
- data/spec/vcr_cassetes/iso_19115_1.yml +1567 -1424
- data/spec/vcr_cassetes/iso_19115_1_2.yml +21 -21
- data/spec/vcr_cassetes/iso_19115_1_std.yml +1565 -1444
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +11 -11
- data/spec/vcr_cassetes/iso_19133_2005.yml +10 -10
- data/spec/vcr_cassetes/iso_combined_applied.yml +22 -22
- data/spec/vcr_cassetes/iso_combined_included.yml +22 -22
- data/spec/vcr_cassetes/iso_dis.yml +10 -10
- data/spec/vcr_cassetes/ogc_19_025r1.yml +16 -16
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +1205 -1211
- data/spec/vcr_cassetes/rfc_8341.yml +135 -135
- metadata +16 -3
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df2abbb732f8ab1fedc92f73e6f313af63075e1cf8f5e0cab2883d7abeaa448
|
4
|
+
data.tar.gz: 8915346acdf65d4a129da2b982b07429a5d4c5352874c230adf3189c670d677c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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)
|
data/lib/relaton/registry.rb
CHANGED
@@ -10,7 +10,7 @@ module Relaton
|
|
10
10
|
relaton_ogc relaton_calconnect relaton_omg relaton_un relaton_w3c
|
11
11
|
relaton_ieee relaton_iho relaton_bipm relaton_ecma relaton_cie relaton_bsi
|
12
12
|
relaton_cen relaton_iana relaton_3gpp relaton_oasis relaton_doi relaton_jis
|
13
|
-
relaton_xsf relaton_ccsds relaton_etsi relaton_isbn
|
13
|
+
relaton_xsf relaton_ccsds relaton_etsi relaton_isbn relaton/plateau
|
14
14
|
].freeze
|
15
15
|
|
16
16
|
include Singleton
|
@@ -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
|
-
|
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
|
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)
|
@@ -107,7 +117,9 @@ module Relaton
|
|
107
117
|
private
|
108
118
|
|
109
119
|
def camel_case(gem_name)
|
110
|
-
gem_name.split("
|
120
|
+
gem_name.split("/").map do |part|
|
121
|
+
part.split("_").map(&:capitalize).join
|
122
|
+
end.join("::")
|
111
123
|
end
|
112
124
|
end
|
113
125
|
end
|
data/lib/relaton/version.rb
CHANGED
data/relaton.gemspec
CHANGED
@@ -53,6 +53,7 @@ Gem::Specification.new do |spec|
|
|
53
53
|
spec.add_dependency "relaton-oasis", "~> 1.19.0"
|
54
54
|
spec.add_dependency "relaton-ogc", "~> 1.19.0"
|
55
55
|
spec.add_dependency "relaton-omg", "~> 1.19.0"
|
56
|
+
spec.add_dependency "relaton-plateau", "~> 1.19.0"
|
56
57
|
spec.add_dependency "relaton-un", "~> 1.19.0"
|
57
58
|
spec.add_dependency "relaton-w3c", "~> 1.19.0"
|
58
59
|
spec.add_dependency "relaton-xsf", "~> 1.19.0"
|
@@ -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 "
|
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
|
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
|
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
|
71
|
+
expect(processor.from_xml("xml")).to eq :item
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -127,6 +127,42 @@ RSpec.describe Relaton::Registry do
|
|
127
127
|
it "ISBN" do
|
128
128
|
expect(Relaton::Registry.instance.by_type("ISBN")).to be_instance_of RelatonIsbn::Processor
|
129
129
|
end
|
130
|
+
|
131
|
+
context "PLATEAU" do
|
132
|
+
let(:processor) { Relaton::Registry.instance.by_type("PLATEAU") }
|
133
|
+
before { processor }
|
134
|
+
|
135
|
+
it "finds processor" do
|
136
|
+
expect(processor).to be_instance_of Relaton::Plateau::Processor
|
137
|
+
end
|
138
|
+
|
139
|
+
it "fetch data" do
|
140
|
+
expect(Relaton::Plateau::Fetcher).to receive(:fetch).with("plateau-handbooks", output: "dir", format: "xml")
|
141
|
+
processor.fetch_data "plateau-handbooks", output: "dir", format: "xml"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "from_xml" do
|
145
|
+
expect(Relaton::Plateau::XMLParser).to receive(:from_xml).with(:xml).and_return :bibitem
|
146
|
+
expect(processor.from_xml(:xml)).to eq :bibitem
|
147
|
+
end
|
148
|
+
|
149
|
+
it "hash_to_bib" do
|
150
|
+
expect(Relaton::Plateau::HashConverter).to receive(:hash_to_bib).with(:hash).and_return bib: :bib
|
151
|
+
expect(Relaton::Plateau::BibItem).to receive(:new).with(bib: :bib).and_return :bibitem
|
152
|
+
expect(processor.hash_to_bib(:hash)).to eq :bibitem
|
153
|
+
end
|
154
|
+
|
155
|
+
it "grammar_hash" do
|
156
|
+
expect(processor.grammar_hash).to be_instance_of String
|
157
|
+
end
|
158
|
+
|
159
|
+
it "remove_index_file" do
|
160
|
+
index = double "index"
|
161
|
+
expect(index).to receive(:remove_file)
|
162
|
+
expect(Relaton::Index).to receive(:find_or_create).and_return index
|
163
|
+
processor.remove_index_file
|
164
|
+
end
|
165
|
+
end
|
130
166
|
end
|
131
167
|
|
132
168
|
it "find processot by dataset" do
|
data/spec/relaton_spec.rb
CHANGED
@@ -373,6 +373,15 @@ RSpec.describe Relaton::Db do
|
|
373
373
|
expect(bib.docidentifier.first.id).to eq "ISBN 978-0-580-50101-4"
|
374
374
|
end
|
375
375
|
|
376
|
+
it "get PLATEAU reference" do
|
377
|
+
docid = RelatonBib::DocumentIdentifier.new(id: "PLATEAU Hanbook #01", type: "PLATEAU")
|
378
|
+
item = Relaton::Plateau::BibItem.new docid: [docid]
|
379
|
+
expect(Relaton::Plateau::Bibliography).to receive(:get).with("PLATEAU Hanbook #01", nil, {}).and_return item
|
380
|
+
bib = @db.fetch "PLATEAU Hanbook #01"
|
381
|
+
expect(bib).to be_instance_of Relaton::Plateau::BibItem
|
382
|
+
expect(bib.docidentifier.first.id).to eq "PLATEAU Hanbook #01"
|
383
|
+
end
|
384
|
+
|
376
385
|
context "get combined documents" do
|
377
386
|
context "ISO" do
|
378
387
|
it "included" do
|
@@ -481,7 +490,7 @@ RSpec.describe Relaton::Db do
|
|
481
490
|
it "should clear cache if version is changed" do
|
482
491
|
expect(File.read("testcache/iso/version", encoding: "UTF-8")).not_to eq "new_version"
|
483
492
|
expect(File.read("testcache2/iso/version", encoding: "UTF-8")).not_to eq "new_version"
|
484
|
-
processor = double
|
493
|
+
processor = double "processor", short: :relaton_iso
|
485
494
|
expect(processor).to receive(:grammar_hash).and_return("new_version").exactly(2).times
|
486
495
|
expect(Relaton::Registry.instance).to receive(:by_type).and_return(processor).exactly(2).times
|
487
496
|
Relaton::Db.new "testcache", "testcache2"
|