relaton 1.6.0 → 1.7.pre7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +46 -0
- data/docs/README.adoc +233 -3
- data/globalcache/iec/iec_60050_102_2007.xml +58 -0
- data/globalcache/iec/version +1 -0
- data/lib/relaton.rb +8 -7
- data/lib/relaton/config.rb +3 -2
- data/lib/relaton/db.rb +247 -35
- data/lib/relaton/db_cache.rb +38 -7
- data/lib/relaton/processor.rb +11 -0
- data/lib/relaton/registry.rb +1 -1
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/workers_pool.rb +23 -0
- data/relaton.gemspec +18 -16
- data/spec/relaton/db_cache_spec.rb +26 -1
- data/spec/relaton/db_spec.rb +145 -0
- data/spec/relaton/processor_spec.rb +4 -0
- data/spec/relaton/regirtry_spec.rb +54 -44
- data/spec/relaton_spec.rb +121 -20
- data/spec/vcr_cassetes/19133_2005.yml +22 -22
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +10 -10
- data/spec/vcr_cassetes/cie_001_1980.yml +120 -0
- data/spec/vcr_cassetes/ecma_6.yml +159 -0
- data/spec/vcr_cassetes/fisp_140.yml +6 -6
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +15 -11
- data/spec/vcr_cassetes/hist_cmbined_included.yml +105 -0
- data/spec/vcr_cassetes/iec_60050_102_2007.yml +285 -0
- data/spec/vcr_cassetes/iec_combined_included.yml +945 -0
- data/spec/vcr_cassetes/ieee_528_2019.yml +14 -14
- data/spec/vcr_cassetes/iho_b_11.yml +15 -15
- data/spec/vcr_cassetes/iso_111111119115_1.yml +4 -4
- data/spec/vcr_cassetes/iso_19115.yml +23 -23
- data/spec/vcr_cassetes/iso_19115_1.yml +22 -22
- data/spec/vcr_cassetes/iso_19115_1_2.yml +44 -44
- data/spec/vcr_cassetes/iso_awi_24229.yml +21 -21
- data/spec/vcr_cassetes/iso_combined_applied.yml +361 -0
- data/spec/vcr_cassetes/iso_combined_included.yml +361 -0
- data/spec/vcr_cassetes/itu_combined_included.yml +1296 -0
- data/spec/vcr_cassetes/ogc_19_025r1.yml +2569 -1910
- data/spec/vcr_cassetes/ogm_ami4ccm_1_0.yml +7 -7
- data/spec/vcr_cassetes/rfc_8341.yml +47 -15
- data/spec/vcr_cassetes/rfc_unsuccess.yml +70 -0
- data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
- data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +31 -31
- data/spec/vcr_cassetes/w3c_json_ld11.yml +18 -12
- metadata +81 -71
- data/.github/workflows/macos.yml +0 -34
- data/.github/workflows/ubuntu.yml +0 -32
- data/.github/workflows/windows.yml +0 -35
data/lib/relaton/db_cache.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "fileutils"
|
2
|
+
require "timeout"
|
2
3
|
|
3
4
|
module Relaton
|
4
5
|
class DbCache
|
@@ -14,6 +15,26 @@ module Relaton
|
|
14
15
|
# set_version # unless File.exist? file_version
|
15
16
|
end
|
16
17
|
|
18
|
+
# Move caches to anothe dir
|
19
|
+
# @param new_dir [String, nil]
|
20
|
+
# @return [String, nil]
|
21
|
+
def mv(new_dir)
|
22
|
+
return unless new_dir && @ext == "xml"
|
23
|
+
|
24
|
+
if File.exist? new_dir
|
25
|
+
warn "[relaton] WARNING: target directory exists \"#{new_dir}\""
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
FileUtils.mv dir, new_dir
|
30
|
+
@dir = new_dir
|
31
|
+
end
|
32
|
+
|
33
|
+
# Clear database
|
34
|
+
def clear
|
35
|
+
FileUtils.rm_rf Dir.glob "#{dir}/*" if @ext == "xml" # unless it's static DB
|
36
|
+
end
|
37
|
+
|
17
38
|
# Save item
|
18
39
|
# @param key [String]
|
19
40
|
# @param value [String] Bibitem xml serialization
|
@@ -26,7 +47,7 @@ module Relaton
|
|
26
47
|
prefix_dir = "#{@dir}/#{prefix(key)}"
|
27
48
|
FileUtils::mkdir_p prefix_dir unless Dir.exist? prefix_dir
|
28
49
|
set_version prefix_dir
|
29
|
-
|
50
|
+
file_safe_write "#{filename(key)}.#{ext(value)}", value
|
30
51
|
end
|
31
52
|
|
32
53
|
# @param value [String]
|
@@ -65,7 +86,7 @@ module Relaton
|
|
65
86
|
value = self[key]
|
66
87
|
return unless value
|
67
88
|
|
68
|
-
if value
|
89
|
+
if value.match? /^not_found/
|
69
90
|
value.match(/\d{4}-\d{2}-\d{2}/).to_s
|
70
91
|
else
|
71
92
|
doc = Nokogiri::XML value
|
@@ -76,8 +97,9 @@ module Relaton
|
|
76
97
|
# Returns all items
|
77
98
|
# @return [Array<String>]
|
78
99
|
def all
|
79
|
-
Dir.glob("#{@dir}/**/*.xml").sort.map do |f|
|
80
|
-
File.read(f, encoding: "utf-8")
|
100
|
+
Dir.glob("#{@dir}/**/*.{xml,yml,yaml}").sort.map do |f|
|
101
|
+
content = File.read(f, encoding: "utf-8")
|
102
|
+
block_given? ? yield(f, content) : content
|
81
103
|
end
|
82
104
|
end
|
83
105
|
|
@@ -106,7 +128,7 @@ module Relaton
|
|
106
128
|
def set_version(fdir)
|
107
129
|
file_version = "#{fdir}/version"
|
108
130
|
unless File.exist? file_version
|
109
|
-
|
131
|
+
file_safe_write file_version, grammar_hash(fdir)
|
110
132
|
end
|
111
133
|
self
|
112
134
|
end
|
@@ -159,7 +181,7 @@ module Relaton
|
|
159
181
|
def filename(key)
|
160
182
|
prefcode = key.downcase.match /^(?<prefix>[^\(]+)\((?<code>[^\)]+)/
|
161
183
|
fn = if prefcode
|
162
|
-
"#{prefcode[:prefix]}/#{prefcode[:code].gsub(/[-:\s\/\()]/, '_').squeeze(
|
184
|
+
"#{prefcode[:prefix]}/#{prefcode[:code].gsub(/[-:\s\/\()]/, '_').squeeze('_')}"
|
163
185
|
else
|
164
186
|
key.gsub(/[-:\s]/, "_")
|
165
187
|
end
|
@@ -189,6 +211,15 @@ module Relaton
|
|
189
211
|
key.downcase.match(/^[^\(]+(?=\()/).to_s
|
190
212
|
end
|
191
213
|
|
214
|
+
# @param file [String]
|
215
|
+
# @content [String]
|
216
|
+
def file_safe_write(file, content)
|
217
|
+
File.open file, File::RDWR | File::CREAT, encoding: "UTF-8" do |f|
|
218
|
+
Timeout.timeout(10) { f.flock File::LOCK_EX }
|
219
|
+
f.write content
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
192
223
|
class << self
|
193
224
|
private
|
194
225
|
|
@@ -209,7 +240,7 @@ module Relaton
|
|
209
240
|
# local_cache: local cache name; none created if nil; "relaton" created
|
210
241
|
# if empty global_cache: boolean to create global_cache
|
211
242
|
# flush_caches: flush caches
|
212
|
-
def init_bib_caches(opts)
|
243
|
+
def init_bib_caches(opts) # rubocop:disable Metrics/CyclomaticComplexity
|
213
244
|
globalname = global_bibliocache_name if opts[:global_cache]
|
214
245
|
localname = local_bibliocache_name(opts[:local_cache])
|
215
246
|
localname = "relaton" if localname&.empty?
|
data/lib/relaton/processor.rb
CHANGED
@@ -20,5 +20,16 @@ module Relaton
|
|
20
20
|
def hash_to_bib(_hash)
|
21
21
|
raise "This is an abstract class!"
|
22
22
|
end
|
23
|
+
|
24
|
+
def grammar_hash
|
25
|
+
raise "This is an abstract class!"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Retuns default number of workers. Should be overraded by childred classes if need.
|
29
|
+
#
|
30
|
+
# @return [Integer] nuber of wokrers
|
31
|
+
def threads
|
32
|
+
10
|
33
|
+
end
|
23
34
|
end
|
24
35
|
end
|
data/lib/relaton/registry.rb
CHANGED
@@ -8,7 +8,7 @@ module Relaton
|
|
8
8
|
SUPPORTED_GEMS = %w[
|
9
9
|
relaton_gb relaton_iec relaton_ietf relaton_iso relaton_itu relaton_nist
|
10
10
|
relaton_ogc relaton_calconnect relaton_omg relaton_un relaton_w3c
|
11
|
-
relaton_ieee relaton_iho relaton_bipm
|
11
|
+
relaton_ieee relaton_iho relaton_bipm relaton_ecma relaton_cie
|
12
12
|
].freeze
|
13
13
|
|
14
14
|
include Singleton
|
data/lib/relaton/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Relaton
|
4
|
+
# Workers poll.
|
5
|
+
class WorkersPool
|
6
|
+
def initialize(workers = 2, &_block)
|
7
|
+
num_workers = workers < 2 ? 2 : workers
|
8
|
+
@queue = SizedQueue.new(num_workers * 2)
|
9
|
+
@threads = Array.new num_workers do
|
10
|
+
Thread.new do
|
11
|
+
while item = @queue.pop
|
12
|
+
yield(item)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def <<(item)
|
19
|
+
@queue << item
|
20
|
+
self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/relaton.gemspec
CHANGED
@@ -30,23 +30,25 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
31
31
|
|
32
32
|
# spec.add_dependency "algoliasearch"
|
33
|
-
spec.add_dependency "relaton-bipm", "~> 1.
|
34
|
-
spec.add_dependency "relaton-calconnect", "~> 1.
|
35
|
-
spec.add_dependency "relaton-
|
36
|
-
spec.add_dependency "relaton-
|
37
|
-
spec.add_dependency "relaton-
|
38
|
-
spec.add_dependency "relaton-
|
39
|
-
spec.add_dependency "relaton-
|
40
|
-
spec.add_dependency "relaton-
|
41
|
-
spec.add_dependency "relaton-
|
42
|
-
spec.add_dependency "relaton-
|
43
|
-
spec.add_dependency "relaton-
|
44
|
-
spec.add_dependency "relaton-
|
45
|
-
spec.add_dependency "relaton-
|
46
|
-
spec.add_dependency "relaton-
|
33
|
+
spec.add_dependency "relaton-bipm", "~> 1.7.0"
|
34
|
+
spec.add_dependency "relaton-calconnect", "~> 1.7.0"
|
35
|
+
spec.add_dependency "relaton-cie", "~> 1.7.pre1"
|
36
|
+
spec.add_dependency "relaton-ecma", "~> 1.7.pre1"
|
37
|
+
spec.add_dependency "relaton-gb", "~> 1.7.0"
|
38
|
+
spec.add_dependency "relaton-iec", ">= 1.7.6"
|
39
|
+
spec.add_dependency "relaton-ieee", "~> 1.7.0"
|
40
|
+
spec.add_dependency "relaton-ietf", "~> 1.7.0"
|
41
|
+
spec.add_dependency "relaton-iho", "~> 1.7.0"
|
42
|
+
spec.add_dependency "relaton-iso", ">= 1.7.1"
|
43
|
+
spec.add_dependency "relaton-itu", ">= 1.7.2"
|
44
|
+
spec.add_dependency "relaton-nist", ">= 1.7.1"
|
45
|
+
spec.add_dependency "relaton-ogc", "~> 1.7.0"
|
46
|
+
spec.add_dependency "relaton-omg", "~> 1.7.0"
|
47
|
+
spec.add_dependency "relaton-un", "~> 1.7.0"
|
48
|
+
spec.add_dependency "relaton-w3c", "~> 1.7.0"
|
47
49
|
|
48
50
|
spec.add_development_dependency "byebug", "~> 11.0"
|
49
|
-
spec.add_development_dependency "debase"
|
51
|
+
# spec.add_development_dependency "debase"
|
50
52
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
51
53
|
spec.add_development_dependency "guard", "~> 2.14"
|
52
54
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
@@ -54,7 +56,7 @@ Gem::Specification.new do |spec|
|
|
54
56
|
spec.add_development_dependency "rake", "~> 10.0"
|
55
57
|
spec.add_development_dependency "rspec", "~> 3.6"
|
56
58
|
spec.add_development_dependency "rubocop", "= 0.54.0"
|
57
|
-
spec.add_development_dependency "ruby-debug-ide"
|
59
|
+
# spec.add_development_dependency "ruby-debug-ide"
|
58
60
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
59
61
|
spec.add_development_dependency "timecop", "~> 0.9"
|
60
62
|
spec.add_development_dependency "vcr", "~> 5"
|
@@ -1,13 +1,38 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "timeout"
|
3
|
+
|
1
4
|
RSpec.describe Relaton::DbCache do
|
2
5
|
it "creates default caches" do
|
3
6
|
cache_path = File.expand_path("~/.relaton/cache")
|
4
7
|
FileUtils.mv cache_path, "relaton1/cache", force: true
|
5
8
|
FileUtils.rm_rf %w(relaton)
|
6
9
|
Relaton::DbCache.init_bib_caches(
|
7
|
-
global_cache: true, local_cache: "", flush_caches: true
|
10
|
+
global_cache: true, local_cache: "", flush_caches: true
|
8
11
|
)
|
9
12
|
expect(File.exist?(cache_path)).to be true
|
10
13
|
expect(File.exist?("relaton")).to be true
|
11
14
|
FileUtils.mv "relaton1/cache", cache_path if File.exist? "relaton1"
|
12
15
|
end
|
16
|
+
|
17
|
+
it "write same file by concurent processes" do
|
18
|
+
dir = "testcache/iso"
|
19
|
+
FileUtils.mkdir_p dir unless File.exist? dir
|
20
|
+
file_name = File.join dir, "iso_123.xml"
|
21
|
+
file = File.open file_name, File::RDWR | File::CREAT, encoding: "UTF-8"
|
22
|
+
file.flock File::LOCK_EX
|
23
|
+
command = <<~RBY
|
24
|
+
require "relaton"
|
25
|
+
cache = Relaton::DbCache.new "testcache"
|
26
|
+
cache["ISO(ISO 123)"] = "test 1"
|
27
|
+
RBY
|
28
|
+
pid = spawn RbConfig.ruby, "-e #{command}"
|
29
|
+
sleep 0.1
|
30
|
+
file.write "test 2"
|
31
|
+
file.flock File::LOCK_UN
|
32
|
+
file.close
|
33
|
+
Process.waitpid pid, 0
|
34
|
+
expect($?.exitstatus).to eq 0
|
35
|
+
expect(File.read(file_name)).to eq "test 1"
|
36
|
+
FileUtils.rm_rf "testcache"
|
37
|
+
end
|
13
38
|
end
|
data/spec/relaton/db_spec.rb
CHANGED
@@ -1,6 +1,121 @@
|
|
1
1
|
RSpec.describe Relaton::Db do
|
2
2
|
before(:each) { FileUtils.rm_rf %w[testcache testcache2] }
|
3
3
|
|
4
|
+
context "modifing database" do
|
5
|
+
let(:db) { Relaton::Db.new "testcache", "testcache2" }
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
db.save_entry "ISO(ISO 123)", "<bibitem id='ISO123></bibitem>"
|
9
|
+
end
|
10
|
+
|
11
|
+
context "move to new dir" do
|
12
|
+
let(:db) { Relaton::Db.new "global_cache", "local_cache" }
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
FileUtils.rm_rf "global_cache"
|
16
|
+
FileUtils.rm_rf "local_cache"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "global cache" do
|
20
|
+
expect(File.exist?("global_cache")).to be true
|
21
|
+
expect(db.mv("testcache")).to eq "testcache"
|
22
|
+
expect(File.exist?("testcache")).to be true
|
23
|
+
expect(File.exist?("global_cache")).to be false
|
24
|
+
end
|
25
|
+
|
26
|
+
it "local cache" do
|
27
|
+
expect(File.exist?("local_cache")).to be true
|
28
|
+
expect(db.mv("testcache2", type: :local)).to eq "testcache2"
|
29
|
+
expect(File.exist?("testcache2")).to be true
|
30
|
+
expect(File.exist?("local_cache")).to be false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "warn if moving in existed dir" do
|
35
|
+
expect(File).to receive(:exist?).with("new_cache_dir")
|
36
|
+
.and_return true
|
37
|
+
expect do
|
38
|
+
expect(db.mv("new_cache_dir")).to be_nil
|
39
|
+
end.to output(/\[relaton\] WARNING: target directory exists/).to_stderr
|
40
|
+
end
|
41
|
+
|
42
|
+
it "clear" do
|
43
|
+
expect(File.exist?("testcache/iso")).to be true
|
44
|
+
expect(File.exist?("testcache2/iso")).to be true
|
45
|
+
db.clear
|
46
|
+
expect(File.exist?("testcache/iso")).to be false
|
47
|
+
expect(File.exist?("testcache2/iso")).to be false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "query in local DB" do
|
52
|
+
let(:db) { Relaton::Db.new "testcache", "testcache2" }
|
53
|
+
|
54
|
+
before(:each) do
|
55
|
+
db.save_entry "ISO(ISO 123)", <<~DOC
|
56
|
+
<bibitem id='ISO123'>
|
57
|
+
<title>The first test</title><edition>2</edition><date type="published"><on>2011-10-12</on></date>
|
58
|
+
</bibitem>
|
59
|
+
DOC
|
60
|
+
db.save_entry "IEC(IEC 123)", <<~DOC
|
61
|
+
<bibitem id="IEC123">
|
62
|
+
<title>The second test</title><edition>1</edition><date type="published"><on>2015-12</on></date>
|
63
|
+
</bibitem>
|
64
|
+
DOC
|
65
|
+
end
|
66
|
+
|
67
|
+
after(:each) { db.clear }
|
68
|
+
|
69
|
+
it "one document" do
|
70
|
+
item = db.fetch_db "ISO((ISO 124)"
|
71
|
+
expect(item).to be_nil
|
72
|
+
item = db.fetch_db "ISO(ISO 123)"
|
73
|
+
expect(item).to be_instance_of RelatonIsoBib::IsoBibliographicItem
|
74
|
+
end
|
75
|
+
|
76
|
+
it "all documents" do
|
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
|
81
|
+
end
|
82
|
+
|
83
|
+
context "search for text" do
|
84
|
+
it do
|
85
|
+
items = db.fetch_all "test"
|
86
|
+
expect(items.size).to eq 2
|
87
|
+
items = db.fetch_all "first"
|
88
|
+
expect(items.size).to eq 1
|
89
|
+
expect(items[0].id).to eq "ISO123"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "in attributes" do
|
93
|
+
items = db.fetch_all "123"
|
94
|
+
expect(items.size).to eq 2
|
95
|
+
items = db.fetch_all "ISO"
|
96
|
+
expect(items.size).to eq 8
|
97
|
+
expect(items[7].id).to eq "ISO123"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "and fail" do
|
101
|
+
items = db.fetch_all "bibitem"
|
102
|
+
expect(items.size).to eq 0
|
103
|
+
end
|
104
|
+
|
105
|
+
it "and edition" do
|
106
|
+
items = db.fetch_all "123", edition: "2"
|
107
|
+
expect(items.size).to eq 1
|
108
|
+
expect(items[0].id).to eq "ISO123"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "and year" do
|
112
|
+
items = db.fetch_all "123", year: 2015
|
113
|
+
expect(items.size).to eq 1
|
114
|
+
expect(items[0].id).to eq "IEC123"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
4
119
|
it "returns docid type" do
|
5
120
|
db = Relaton::Db.new "testcache", "testcache2"
|
6
121
|
expect(db.docid_type("CN(GB/T 1.1)")).to eq ["Chinese Standard", "GB/T 1.1"]
|
@@ -30,6 +145,36 @@ RSpec.describe Relaton::Db do
|
|
30
145
|
end
|
31
146
|
end
|
32
147
|
|
148
|
+
it "fetch document with net retries" do
|
149
|
+
db = Relaton::Db.new nil, nil
|
150
|
+
expect(db.instance_variable_get(:@registry).processors[:relaton_ietf]).to receive(:get)
|
151
|
+
.and_raise(RelatonBib::RequestError).exactly(3).times
|
152
|
+
expect { db.fetch "RFC 8341", nil, retries: 3 }.to raise_error RelatonBib::RequestError
|
153
|
+
end
|
154
|
+
|
155
|
+
context "async fetch" do
|
156
|
+
let(:db) { Relaton::Db.new nil, nil }
|
157
|
+
let(:queue) { Queue.new }
|
158
|
+
|
159
|
+
it "success" do
|
160
|
+
result = nil
|
161
|
+
VCR.use_cassette "rfc_8341" do
|
162
|
+
db.fetch_async("RFC 8341") { |r| queue << r }
|
163
|
+
Timeout.timeout(5) { result = queue.pop }
|
164
|
+
end
|
165
|
+
expect(result).to be_instance_of RelatonIetf::IetfBibliographicItem
|
166
|
+
end
|
167
|
+
|
168
|
+
it "prefix not found" do
|
169
|
+
result = ""
|
170
|
+
VCR.use_cassette "rfc_unsuccess" do
|
171
|
+
db.fetch_async("ABC 123456") { |r| queue << r }
|
172
|
+
Timeout.timeout(5) { result = queue.pop }
|
173
|
+
end
|
174
|
+
expect(result).to be_nil
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
33
178
|
context "fetch documents form static cache" do
|
34
179
|
let(:db) { Relaton::Db.new nil, nil }
|
35
180
|
|
@@ -23,5 +23,9 @@ RSpec.describe Relaton::Processor do
|
|
23
23
|
it "hash_to_bib method should be implemented" do
|
24
24
|
expect { subject.hash_to_bib({}) }.to raise_error StandardError
|
25
25
|
end
|
26
|
+
|
27
|
+
it "grammar_hash method should be implemented" do
|
28
|
+
expect { subject.grammar_hash }.to raise_error StandardError
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
@@ -2,72 +2,82 @@ RSpec.describe Relaton::Registry do
|
|
2
2
|
it "outputs backend not present" do
|
3
3
|
stub_const "Relaton::Registry::SUPPORTED_GEMS", ["not_supported_gem"]
|
4
4
|
expect { Relaton::Registry.clone.instance }.to output(
|
5
|
-
/backend not_supported_gem not present
|
5
|
+
/backend not_supported_gem not present/
|
6
6
|
).to_stdout
|
7
7
|
end
|
8
8
|
|
9
9
|
it "finds ISO processor" do
|
10
|
-
expect(Relaton::Registry.instance.find_processor("relaton_iso"))
|
11
|
-
to be_instance_of RelatonIso::Processor
|
10
|
+
expect(Relaton::Registry.instance.find_processor("relaton_iso"))
|
11
|
+
.to be_instance_of RelatonIso::Processor
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns supported processors" do
|
15
15
|
expect(Relaton::Registry.instance.supported_processors).to include :relaton_iso
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
context "finds processor by type" do
|
19
|
+
it "CN" do
|
20
|
+
expect(Relaton::Registry.instance.by_type("CN")).to be_instance_of RelatonGb::Processor
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
it "IEC" do
|
24
|
+
expect(Relaton::Registry.instance.by_type("IEC")).to be_instance_of RelatonIec::Processor
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
it "IETF" do
|
28
|
+
expect(Relaton::Registry.instance.by_type("IETF")).to be_instance_of RelatonIetf::Processor
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
it "ISO" do
|
32
|
+
expect(Relaton::Registry.instance.by_type("ISO")).to be_instance_of RelatonIso::Processor
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
it "ITU" do
|
36
|
+
expect(Relaton::Registry.instance.by_type("ITU")).to be_instance_of RelatonItu::Processor
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
it "NIST" do
|
40
|
+
expect(Relaton::Registry.instance.by_type("NIST")).to be_instance_of RelatonNist::Processor
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
it "OGC" do
|
44
|
+
expect(Relaton::Registry.instance.by_type("OGC")).to be_instance_of RelatonOgc::Processor
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
it "CC" do
|
48
|
+
expect(Relaton::Registry.instance.by_type("CC")).to be_instance_of RelatonCalconnect::Processor
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
it "OMG" do
|
52
|
+
expect(Relaton::Registry.instance.by_type("OMG")).to be_instance_of RelatonOmg::Processor
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
it "UN" do
|
56
|
+
expect(Relaton::Registry.instance.by_type("UN")).to be_instance_of RelatonUn::Processor
|
57
|
+
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
it "W3C" do
|
60
|
+
expect(Relaton::Registry.instance.by_type("W3C")).to be_instance_of RelatonW3c::Processor
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
it "IEEE" do
|
64
|
+
expect(Relaton::Registry.instance.by_type("IEEE")).to be_instance_of RelatonIeee::Processor
|
65
|
+
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
it "IHO" do
|
68
|
+
expect(Relaton::Registry.instance.by_type("IHO")).to be_instance_of RelatonIho::Processor
|
69
|
+
end
|
70
|
+
|
71
|
+
it "BIPM" do
|
72
|
+
expect(Relaton::Registry.instance.by_type("BIPM")).to be_instance_of RelatonBipm::Processor
|
73
|
+
end
|
74
|
+
|
75
|
+
it "ECMA" do
|
76
|
+
expect(Relaton::Registry.instance.by_type("ECMA")).to be_instance_of RelatonEcma::Processor
|
77
|
+
end
|
69
78
|
|
70
|
-
|
71
|
-
|
79
|
+
it "CIE" do
|
80
|
+
expect(Relaton::Registry.instance.by_type("CIE")).to be_instance_of RelatonCie::Processor
|
81
|
+
end
|
72
82
|
end
|
73
83
|
end
|