relaton 1.20.2 → 2.0.0.pre.alpha.1
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/.rubocop.yml +1 -1
- data/CLAUDE.md +4 -2
- data/Rakefile +1 -1
- data/bin/rspec +1 -2
- data/docs/README.adoc +93 -86
- data/lib/relaton/config.rb +2 -3
- data/lib/relaton/db.rb +57 -39
- data/lib/relaton/db_cache.rb +3 -2
- data/lib/relaton/registry.rb +23 -30
- data/lib/relaton/util.rb +2 -1
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/workers_pool.rb +1 -1
- data/lib/relaton.rb +6 -7
- data/relaton.gemspec +31 -31
- data/spec/relaton/db_cache_spec.rb +1 -1
- data/spec/relaton/db_spec.rb +84 -46
- data/spec/relaton/registry_spec.rb +43 -41
- data/spec/relaton/util_spec.rb +1 -0
- data/spec/relaton_spec.rb +345 -163
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +12595 -13226
- data/spec/vcr_cassetes/api_relaton_org.yml +7 -7
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +76 -78
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +48 -42
- data/spec/vcr_cassetes/cie_001_1980.yml +302 -262
- data/spec/vcr_cassetes/cipm_meeting_43.yml +1380 -1370
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +3 -3
- data/spec/vcr_cassetes/ecma_6.yml +182 -238
- data/spec/vcr_cassetes/en_10160_1999.yml +13083 -13122
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +9 -9
- data/spec/vcr_cassetes/ieee_528_2019.yml +2633 -2411
- data/spec/vcr_cassetes/iso_19115_1.yml +13692 -13957
- data/spec/vcr_cassetes/iso_19115_1_2.yml +235 -244
- data/spec/vcr_cassetes/iso_19115_1_std.yml +13690 -13955
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +161 -168
- data/spec/vcr_cassetes/iso_19133_2005.yml +83 -79
- data/spec/vcr_cassetes/iso_combined_applied.yml +239 -238
- data/spec/vcr_cassetes/iso_combined_included.yml +240 -239
- data/spec/vcr_cassetes/iso_dis.yml +87 -88
- data/spec/vcr_cassetes/ogc_19_025r1.yml +248 -243
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +268 -1513
- data/spec/vcr_cassetes/rfc_8341.yml +1090 -1086
- metadata +62 -80
- data/lib/relaton/processor.rb +0 -46
- data/spec/relaton/processor_spec.rb +0 -113
data/spec/relaton/db_spec.rb
CHANGED
|
@@ -6,8 +6,10 @@ RSpec.describe Relaton::Db do
|
|
|
6
6
|
if example.metadata[:vcr]
|
|
7
7
|
# Force to download index file
|
|
8
8
|
require "relaton/index"
|
|
9
|
-
allow_any_instance_of(Relaton::Index::Type)
|
|
10
|
-
|
|
9
|
+
allow_any_instance_of(Relaton::Index::Type)
|
|
10
|
+
.to receive(:actual?).and_return(false)
|
|
11
|
+
allow_any_instance_of(Relaton::Index::FileIO)
|
|
12
|
+
.to receive(:check_file).and_return(nil)
|
|
11
13
|
end
|
|
12
14
|
end
|
|
13
15
|
|
|
@@ -16,11 +18,11 @@ RSpec.describe Relaton::Db do
|
|
|
16
18
|
context "instance methods" do
|
|
17
19
|
context "#search_edition_year" do
|
|
18
20
|
it "create bibitem from YAML content" do
|
|
19
|
-
h = { "docid" => [{ "id" => "ISO 123", type: "ISO",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
expect(item).to be_instance_of
|
|
21
|
+
h = { "docid" => [{ "id" => "ISO 123", type: "ISO",
|
|
22
|
+
"primary" => true }] }
|
|
23
|
+
item = subject.send :search_edition_year, "iso/item.yaml", h.to_yaml,
|
|
24
|
+
nil, nil
|
|
25
|
+
expect(item).to be_instance_of Relaton::Iso::ItemData
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
|
|
@@ -33,18 +35,24 @@ RSpec.describe Relaton::Db do
|
|
|
33
35
|
it "warn if cached entry is not_found" do
|
|
34
36
|
expect do
|
|
35
37
|
expect(subject).to_not receive(:fetch_entry)
|
|
36
|
-
entry = subject.send :new_bib_entry, "ISO 123", nil, {},
|
|
38
|
+
entry = subject.send :new_bib_entry, "ISO 123", nil, {},
|
|
39
|
+
:relaton_iso, db: db, id: "ISO(ISO 123)"
|
|
37
40
|
expect(entry).to be_nil
|
|
38
|
-
end.to output(
|
|
39
|
-
|
|
41
|
+
end.to output(
|
|
42
|
+
"[relaton] INFO: (ISO 123) not found in cache, " \
|
|
43
|
+
"if you wish to ignore cache please use " \
|
|
44
|
+
"`no-cache` option.\n",
|
|
45
|
+
).to_stderr_from_any_process
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
it "ignore cache" do
|
|
43
49
|
expect(subject).to receive(:fetch_entry).with(
|
|
44
|
-
"ISO 123", nil, { no_cache: true }, :relaton_iso,
|
|
50
|
+
"ISO 123", nil, { no_cache: true }, :relaton_iso,
|
|
51
|
+
db: db, id: "ISO(ISO 123)"
|
|
45
52
|
).and_return :entry
|
|
46
53
|
entry = subject.send(
|
|
47
|
-
:new_bib_entry, "ISO 123", nil, { no_cache: true },
|
|
54
|
+
:new_bib_entry, "ISO 123", nil, { no_cache: true },
|
|
55
|
+
:relaton_iso, db: db, id: "ISO(ISO 123)"
|
|
48
56
|
)
|
|
49
57
|
expect(entry).to be :entry
|
|
50
58
|
end
|
|
@@ -54,7 +62,8 @@ RSpec.describe Relaton::Db do
|
|
|
54
62
|
it "retrun nil for BIPM documents" do
|
|
55
63
|
code = double "code"
|
|
56
64
|
expect(code).not_to receive(:split)
|
|
57
|
-
expect(subject.send(:combine_doc, code, nil, {},
|
|
65
|
+
expect(subject.send(:combine_doc, code, nil, {},
|
|
66
|
+
:relaton_bipm)).to be_nil
|
|
58
67
|
end
|
|
59
68
|
end
|
|
60
69
|
|
|
@@ -62,19 +71,29 @@ RSpec.describe Relaton::Db do
|
|
|
62
71
|
let(:db_cache) { double "db_cache" }
|
|
63
72
|
|
|
64
73
|
before do
|
|
65
|
-
expect(subject).to receive(:net_retry).with(
|
|
74
|
+
expect(subject).to receive(:net_retry).with(
|
|
75
|
+
"ISO 123", nil, {},
|
|
76
|
+
kind_of(Relaton::Iso::Processor), 1
|
|
77
|
+
).and_return :bib
|
|
66
78
|
end
|
|
67
79
|
|
|
68
80
|
it "using cache" do
|
|
69
|
-
expect(db_cache).to receive(:[]).with("ISO(ISO 123)")
|
|
70
|
-
|
|
71
|
-
expect(
|
|
72
|
-
|
|
81
|
+
expect(db_cache).to receive(:[]).with("ISO(ISO 123)")
|
|
82
|
+
.and_return nil
|
|
83
|
+
expect(db_cache).to receive(:[]=)
|
|
84
|
+
.with("ISO(ISO 123)", :entry)
|
|
85
|
+
expect(subject).to receive(:check_entry).with(
|
|
86
|
+
:bib, :relaton_iso,
|
|
87
|
+
db: db_cache, id: "ISO(ISO 123)"
|
|
88
|
+
).and_return :entry
|
|
89
|
+
entry = subject.send :fetch_entry, "ISO 123", nil, {}, :relaton_iso,
|
|
90
|
+
db: db_cache, id: "ISO(ISO 123)"
|
|
73
91
|
expect(entry).to be :entry
|
|
74
92
|
end
|
|
75
93
|
|
|
76
94
|
it "DbCache is undefined" do
|
|
77
|
-
expect(subject).to receive(:check_entry).with(:bib, :relaton_iso,
|
|
95
|
+
expect(subject).to receive(:check_entry).with(:bib, :relaton_iso,
|
|
96
|
+
**{}).and_return :entry
|
|
78
97
|
entry = subject.send :fetch_entry, "ISO 123", nil, {}, :relaton_iso
|
|
79
98
|
expect(entry).to be :entry
|
|
80
99
|
end
|
|
@@ -85,7 +104,8 @@ RSpec.describe Relaton::Db do
|
|
|
85
104
|
:bib, :relaton_iso, db: db_cache, id: "ISO(ISO 123)", no_cache: true
|
|
86
105
|
).and_return :entry
|
|
87
106
|
expect(db_cache).to receive(:[]).with("ISO(ISO 123)").and_return :entry
|
|
88
|
-
entry = subject.send :fetch_entry, "ISO 123", nil, {}, :relaton_iso,
|
|
107
|
+
entry = subject.send :fetch_entry, "ISO 123", nil, {}, :relaton_iso,
|
|
108
|
+
db: db_cache, id: "ISO(ISO 123)", no_cache: true
|
|
89
109
|
expect(entry).to be :entry
|
|
90
110
|
end
|
|
91
111
|
end
|
|
@@ -144,7 +164,8 @@ RSpec.describe Relaton::Db do
|
|
|
144
164
|
expect(result).to be false
|
|
145
165
|
end
|
|
146
166
|
|
|
147
|
-
it "returns false when date is on or after
|
|
167
|
+
it "returns false when date is on or after " \
|
|
168
|
+
":publication_date_before (exclusive)" do
|
|
148
169
|
result = subject.send(
|
|
149
170
|
:pub_date_in_range?, xml_with_date,
|
|
150
171
|
publication_date_before: "2019-06-15"
|
|
@@ -224,7 +245,7 @@ RSpec.describe Relaton::Db do
|
|
|
224
245
|
:relaton_iso
|
|
225
246
|
)
|
|
226
247
|
expect(id).to eq(
|
|
227
|
-
"ISO(ISO 19115-1 after-2018-01-01 before-2020-12-31)"
|
|
248
|
+
"ISO(ISO 19115-1 after-2018-01-01 before-2020-12-31)",
|
|
228
249
|
)
|
|
229
250
|
expect(code).to eq "ISO 19115-1"
|
|
230
251
|
end
|
|
@@ -243,7 +264,7 @@ RSpec.describe Relaton::Db do
|
|
|
243
264
|
:relaton_iso
|
|
244
265
|
)
|
|
245
266
|
expect(id).to eq(
|
|
246
|
-
"ISO(ISO 19115-1:2014 (all parts) after-2014-01-01)"
|
|
267
|
+
"ISO(ISO 19115-1:2014 (all parts) after-2014-01-01)",
|
|
247
268
|
)
|
|
248
269
|
end
|
|
249
270
|
end
|
|
@@ -269,9 +290,7 @@ RSpec.describe Relaton::Db do
|
|
|
269
290
|
{ publication_date_after: "2019-01-01",
|
|
270
291
|
fetch_db: true }, :relaton_iso
|
|
271
292
|
)
|
|
272
|
-
expect(item).to be_instance_of(
|
|
273
|
-
RelatonIsoBib::IsoBibliographicItem
|
|
274
|
-
)
|
|
293
|
+
expect(item).to be_instance_of(Relaton::Iso::ItemData)
|
|
275
294
|
end
|
|
276
295
|
|
|
277
296
|
it "does not return base cached entry when date does not match" do
|
|
@@ -288,8 +307,10 @@ RSpec.describe Relaton::Db do
|
|
|
288
307
|
it "::init_bib_caches" do
|
|
289
308
|
expect(FileUtils).to receive(:rm_rf).with(/\/\.relaton\/cache$/)
|
|
290
309
|
expect(FileUtils).to receive(:rm_rf).with(/testcache\/cache$/)
|
|
291
|
-
expect(Relaton::Db).to receive(:new).with(/\/\.relaton\/cache$/,
|
|
292
|
-
|
|
310
|
+
expect(Relaton::Db).to receive(:new).with(/\/\.relaton\/cache$/,
|
|
311
|
+
/testcache\/cache$/)
|
|
312
|
+
Relaton::Db.init_bib_caches(global_cache: true, local_cache: "testcache",
|
|
313
|
+
flush_caches: true)
|
|
293
314
|
end
|
|
294
315
|
end
|
|
295
316
|
|
|
@@ -328,7 +349,9 @@ RSpec.describe Relaton::Db do
|
|
|
328
349
|
allow(File).to receive(:exist?).and_call_original
|
|
329
350
|
expect do
|
|
330
351
|
expect(db.mv("new_cache_dir")).to be_nil
|
|
331
|
-
end.to output(
|
|
352
|
+
end.to output(
|
|
353
|
+
/\[relaton\] INFO: target directory exists/,
|
|
354
|
+
).to_stderr_from_any_process
|
|
332
355
|
end
|
|
333
356
|
|
|
334
357
|
it "clear" do
|
|
@@ -362,14 +385,14 @@ RSpec.describe Relaton::Db do
|
|
|
362
385
|
item = db.fetch_db "ISO((ISO 124)"
|
|
363
386
|
expect(item).to be_nil
|
|
364
387
|
item = db.fetch_db "ISO(ISO 123)"
|
|
365
|
-
expect(item).to be_instance_of
|
|
388
|
+
expect(item).to be_instance_of Relaton::Iso::ItemData
|
|
366
389
|
end
|
|
367
390
|
|
|
368
391
|
it "all documents" do
|
|
369
392
|
items = db.fetch_all
|
|
370
393
|
expect(items.size).to be 2
|
|
371
|
-
expect(items[0]).to be_instance_of
|
|
372
|
-
expect(items[1]).to be_instance_of
|
|
394
|
+
expect(items[0]).to be_instance_of Relaton::Iec::ItemData
|
|
395
|
+
expect(items[1]).to be_instance_of Relaton::Iso::ItemData
|
|
373
396
|
end
|
|
374
397
|
|
|
375
398
|
context "search for text" do
|
|
@@ -381,6 +404,12 @@ RSpec.describe Relaton::Db do
|
|
|
381
404
|
expect(items[0].id).to eq "ISO123"
|
|
382
405
|
end
|
|
383
406
|
|
|
407
|
+
it "with spaces in text" do
|
|
408
|
+
items = db.fetch_all "first test"
|
|
409
|
+
expect(items.size).to eq 1
|
|
410
|
+
expect(items[0].id).to eq "ISO123"
|
|
411
|
+
end
|
|
412
|
+
|
|
384
413
|
it "in attributes" do
|
|
385
414
|
items = db.fetch_all "123"
|
|
386
415
|
expect(items.size).to eq 2
|
|
@@ -415,40 +444,47 @@ RSpec.describe Relaton::Db do
|
|
|
415
444
|
|
|
416
445
|
context "#fetch" do
|
|
417
446
|
it "doesn't use cache" do
|
|
418
|
-
docid =
|
|
419
|
-
|
|
420
|
-
|
|
447
|
+
docid = Relaton::Bib::Docidentifier.new content: "ISO 19115-1",
|
|
448
|
+
type: "ISO"
|
|
449
|
+
item = Relaton::Iso::ItemData.new docid: [docid]
|
|
450
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
451
|
+
.with("ISO 19115-1", nil, {}).and_return item
|
|
421
452
|
bib = subject.fetch("ISO 19115-1", nil, {})
|
|
422
|
-
expect(bib).to be_instance_of
|
|
453
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
423
454
|
end
|
|
424
455
|
|
|
425
456
|
it "when no local db", vcr: "iso_19115_1" do
|
|
426
457
|
db = Relaton::Db.new "testcache", nil
|
|
427
458
|
bib = db.fetch("ISO 19115-1", nil, {})
|
|
428
|
-
expect(bib).to be_instance_of
|
|
459
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
429
460
|
end
|
|
430
461
|
|
|
431
462
|
it "document with net retries" do
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
463
|
+
registry = subject.instance_variable_get(:@registry)
|
|
464
|
+
expect(registry.processors[:relaton_ietf]).to receive(:get)
|
|
465
|
+
.and_raise(Relaton::RequestError).exactly(3).times
|
|
466
|
+
expect do
|
|
467
|
+
subject.fetch "RFC 8341", nil, retries: 3
|
|
468
|
+
end.to raise_error Relaton::RequestError
|
|
435
469
|
end
|
|
436
470
|
|
|
437
471
|
it "strip reference" do
|
|
438
|
-
expect(subject).to receive(:combine_doc)
|
|
472
|
+
expect(subject).to receive(:combine_doc)
|
|
473
|
+
.with("ISO 19115-1", nil, {}, :relaton_iso)
|
|
474
|
+
.and_return :doc
|
|
439
475
|
expect(subject.fetch(" ISO 19115-1 ", nil, {})).to be :doc
|
|
440
476
|
end
|
|
441
477
|
|
|
442
478
|
it "BIPM Meeting", vcr: "cipm_meeting_43" do
|
|
443
479
|
bib = subject.fetch("CIPM Meeting 43")
|
|
444
|
-
expect(bib).to be_instance_of
|
|
480
|
+
expect(bib).to be_instance_of Relaton::Bipm::ItemData
|
|
445
481
|
end
|
|
446
482
|
end
|
|
447
483
|
|
|
448
484
|
it "fetch std", vcr: "iso_19115_1_std" do
|
|
449
485
|
db = Relaton::Db.new "testcache", nil
|
|
450
486
|
bib = db.fetch_std("ISO 19115-1", nil, :relaton_iso, {})
|
|
451
|
-
expect(bib).to be_instance_of
|
|
487
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
452
488
|
end
|
|
453
489
|
|
|
454
490
|
context "async fetch" do
|
|
@@ -491,16 +527,18 @@ RSpec.describe Relaton::Db do
|
|
|
491
527
|
end
|
|
492
528
|
|
|
493
529
|
it "handle HTTP request error" do
|
|
494
|
-
expect(subject).to receive(:fetch).and_raise
|
|
530
|
+
expect(subject).to receive(:fetch).and_raise Relaton::RequestError
|
|
495
531
|
subject.fetch_async("ISO REF") { |r| queue << r }
|
|
496
532
|
result = Timeout.timeout(5) { queue.pop }
|
|
497
|
-
expect(result).to be_instance_of
|
|
533
|
+
expect(result).to be_instance_of Relaton::RequestError
|
|
498
534
|
end
|
|
499
535
|
|
|
500
536
|
it "handle other errors" do
|
|
501
537
|
expect(subject).to receive(:fetch).and_raise Errno::EACCES
|
|
502
538
|
log_io = Relaton.logger_pool[:default].instance_variable_get(:@logdev)
|
|
503
|
-
expect(log_io).to receive(:write).with(
|
|
539
|
+
expect(log_io).to receive(:write).with(
|
|
540
|
+
"[relaton] ERROR: `ISO REF` -- Permission denied\n",
|
|
541
|
+
)
|
|
504
542
|
subject.fetch_async("ISO REF") { |r| queue << r }
|
|
505
543
|
result = Timeout.timeout(5) { queue.pop }
|
|
506
544
|
expect(result).to be_nil
|
|
@@ -10,122 +10,125 @@ RSpec.describe Relaton::Registry do
|
|
|
10
10
|
|
|
11
11
|
it "finds ISO processor" do
|
|
12
12
|
expect(Relaton::Registry.instance.find_processor("relaton_iso"))
|
|
13
|
-
.to be_instance_of
|
|
13
|
+
.to be_instance_of Relaton::Iso::Processor
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "returns supported processors" do
|
|
17
|
-
|
|
17
|
+
processors = Relaton::Registry.instance.supported_processors
|
|
18
|
+
expect(processors).to include :relaton_iso
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
context "finds processor by type" do
|
|
21
22
|
it "CN" do
|
|
22
|
-
expect(Relaton::Registry.instance.by_type("CN")).to be_instance_of
|
|
23
|
+
expect(Relaton::Registry.instance.by_type("CN")).to be_instance_of Relaton::Gb::Processor
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
it "IEC" do
|
|
26
|
-
expect(Relaton::Registry.instance.by_type("IEC")).to be_instance_of
|
|
27
|
+
expect(Relaton::Registry.instance.by_type("IEC")).to be_instance_of Relaton::Iec::Processor
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
it "IETF" do
|
|
30
|
-
expect(Relaton::Registry.instance.by_type("IETF")).to be_instance_of
|
|
31
|
+
expect(Relaton::Registry.instance.by_type("IETF")).to be_instance_of Relaton::Ietf::Processor
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
it "ISO" do
|
|
34
|
-
expect(Relaton::Registry.instance.by_type("ISO")).to be_instance_of
|
|
35
|
+
expect(Relaton::Registry.instance.by_type("ISO")).to be_instance_of Relaton::Iso::Processor
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
it "ITU" do
|
|
38
|
-
expect(Relaton::Registry.instance.by_type("ITU")).to be_instance_of
|
|
39
|
+
expect(Relaton::Registry.instance.by_type("ITU")).to be_instance_of Relaton::Itu::Processor
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
it "NIST" do
|
|
42
|
-
expect(Relaton::Registry.instance.by_type("NIST")).to be_instance_of
|
|
43
|
+
expect(Relaton::Registry.instance.by_type("NIST")).to be_instance_of Relaton::Nist::Processor
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
it "OGC" do
|
|
46
|
-
expect(Relaton::Registry.instance.by_type("OGC")).to be_instance_of
|
|
47
|
+
expect(Relaton::Registry.instance.by_type("OGC")).to be_instance_of Relaton::Ogc::Processor
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
it "CC" do
|
|
50
|
-
expect(Relaton::Registry.instance.by_type("CC")).to be_instance_of
|
|
51
|
+
expect(Relaton::Registry.instance.by_type("CC")).to be_instance_of Relaton::Calconnect::Processor
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
it "OMG" do
|
|
54
|
-
expect(Relaton::Registry.instance.by_type("OMG")).to be_instance_of
|
|
55
|
+
expect(Relaton::Registry.instance.by_type("OMG")).to be_instance_of Relaton::Omg::Processor
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
it "UN" do
|
|
58
|
-
expect(Relaton::Registry.instance.by_type("UN")).to be_instance_of
|
|
59
|
+
expect(Relaton::Registry.instance.by_type("UN")).to be_instance_of Relaton::Un::Processor
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
it "W3C" do
|
|
62
|
-
expect(Relaton::Registry.instance.by_type("W3C")).to be_instance_of
|
|
63
|
+
expect(Relaton::Registry.instance.by_type("W3C")).to be_instance_of Relaton::W3c::Processor
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
it "IEEE" do
|
|
66
|
-
expect(Relaton::Registry.instance.by_type("IEEE")).to be_instance_of
|
|
67
|
+
expect(Relaton::Registry.instance.by_type("IEEE")).to be_instance_of Relaton::Ieee::Processor
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
it "IHO" do
|
|
70
|
-
expect(Relaton::Registry.instance.by_type("IHO")).to be_instance_of
|
|
71
|
+
expect(Relaton::Registry.instance.by_type("IHO")).to be_instance_of Relaton::Iho::Processor
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
it "BIPM" do
|
|
74
|
-
expect(Relaton::Registry.instance.by_type("BIPM")).to be_instance_of
|
|
75
|
-
expect(Relaton::Registry.instance.processor_by_ref("CCTF"))
|
|
75
|
+
expect(Relaton::Registry.instance.by_type("BIPM")).to be_instance_of Relaton::Bipm::Processor
|
|
76
|
+
expect(Relaton::Registry.instance.processor_by_ref("CCTF"))
|
|
77
|
+
.to be_instance_of Relaton::Bipm::Processor
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
it "ECMA" do
|
|
79
|
-
expect(Relaton::Registry.instance.by_type("ECMA")).to be_instance_of
|
|
81
|
+
expect(Relaton::Registry.instance.by_type("ECMA")).to be_instance_of Relaton::Ecma::Processor
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
it "CIE" do
|
|
83
|
-
expect(Relaton::Registry.instance.by_type("CIE")).to be_instance_of
|
|
85
|
+
expect(Relaton::Registry.instance.by_type("CIE")).to be_instance_of Relaton::Cie::Processor
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
it "BSI" do
|
|
87
|
-
expect(Relaton::Registry.instance.by_type("BSI")).to be_instance_of
|
|
89
|
+
expect(Relaton::Registry.instance.by_type("BSI")).to be_instance_of Relaton::Bsi::Processor
|
|
88
90
|
end
|
|
89
91
|
|
|
90
92
|
it "CEN" do
|
|
91
|
-
expect(Relaton::Registry.instance.by_type("CEN")).to be_instance_of
|
|
93
|
+
expect(Relaton::Registry.instance.by_type("CEN")).to be_instance_of Relaton::Cen::Processor
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
it "IANA" do
|
|
95
|
-
expect(Relaton::Registry.instance.by_type("IANA")).to be_instance_of
|
|
97
|
+
expect(Relaton::Registry.instance.by_type("IANA")).to be_instance_of Relaton::Iana::Processor
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
it "3GPP" do
|
|
99
|
-
expect(Relaton::Registry.instance.by_type("3GPP")).to be_instance_of
|
|
101
|
+
expect(Relaton::Registry.instance.by_type("3GPP")).to be_instance_of Relaton::ThreeGpp::Processor
|
|
100
102
|
end
|
|
101
103
|
|
|
102
104
|
it "OASIS" do
|
|
103
|
-
expect(Relaton::Registry.instance.by_type("OASIS")).to be_instance_of
|
|
105
|
+
expect(Relaton::Registry.instance.by_type("OASIS")).to be_instance_of Relaton::Oasis::Processor
|
|
104
106
|
end
|
|
105
107
|
|
|
106
108
|
it "DOI" do
|
|
107
|
-
expect(Relaton::Registry.instance.by_type("DOI")).to be_instance_of
|
|
108
|
-
expect(Relaton::Registry.instance.processor_by_ref("doi:10.1000/182"))
|
|
109
|
+
expect(Relaton::Registry.instance.by_type("DOI")).to be_instance_of Relaton::Doi::Processor
|
|
110
|
+
expect(Relaton::Registry.instance.processor_by_ref("doi:10.1000/182"))
|
|
111
|
+
.to be_instance_of Relaton::Doi::Processor
|
|
109
112
|
end
|
|
110
113
|
|
|
111
114
|
it "JIS" do
|
|
112
|
-
expect(Relaton::Registry.instance.by_type("JIS")).to be_instance_of
|
|
115
|
+
expect(Relaton::Registry.instance.by_type("JIS")).to be_instance_of Relaton::Jis::Processor
|
|
113
116
|
end
|
|
114
117
|
|
|
115
118
|
it "XSF" do
|
|
116
|
-
expect(Relaton::Registry.instance.by_type("XEP")).to be_instance_of
|
|
119
|
+
expect(Relaton::Registry.instance.by_type("XEP")).to be_instance_of Relaton::Xsf::Processor
|
|
117
120
|
end
|
|
118
121
|
|
|
119
122
|
it "CCSDS" do
|
|
120
|
-
expect(Relaton::Registry.instance.by_type("CCSDS")).to be_instance_of
|
|
123
|
+
expect(Relaton::Registry.instance.by_type("CCSDS")).to be_instance_of Relaton::Ccsds::Processor
|
|
121
124
|
end
|
|
122
125
|
|
|
123
126
|
it "ETSI" do
|
|
124
|
-
expect(Relaton::Registry.instance.by_type("ETSI")).to be_instance_of
|
|
127
|
+
expect(Relaton::Registry.instance.by_type("ETSI")).to be_instance_of Relaton::Etsi::Processor
|
|
125
128
|
end
|
|
126
129
|
|
|
127
130
|
it "ISBN" do
|
|
128
|
-
expect(Relaton::Registry.instance.by_type("ISBN")).to be_instance_of
|
|
131
|
+
expect(Relaton::Registry.instance.by_type("ISBN")).to be_instance_of Relaton::Isbn::Processor
|
|
129
132
|
end
|
|
130
133
|
|
|
131
134
|
context "PLATEAU" do
|
|
@@ -137,21 +140,19 @@ RSpec.describe Relaton::Registry do
|
|
|
137
140
|
end
|
|
138
141
|
|
|
139
142
|
it "fetch data" do
|
|
140
|
-
|
|
143
|
+
require "relaton/plateau/data_fetcher"
|
|
144
|
+
expect(Relaton::Plateau::DataFetcher).to receive(:fetch)
|
|
145
|
+
.with("plateau-handbooks", output: "dir", format: "xml")
|
|
141
146
|
processor.fetch_data "plateau-handbooks", output: "dir", format: "xml"
|
|
142
147
|
end
|
|
143
148
|
|
|
144
149
|
it "from_xml" do
|
|
145
|
-
|
|
150
|
+
require "relaton/plateau"
|
|
151
|
+
expect(Relaton::Plateau::Item).to receive(:from_xml)
|
|
152
|
+
.with(:xml).and_return :bibitem
|
|
146
153
|
expect(processor.from_xml(:xml)).to eq :bibitem
|
|
147
154
|
end
|
|
148
155
|
|
|
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
156
|
it "grammar_hash" do
|
|
156
157
|
expect(processor.grammar_hash).to be_instance_of String
|
|
157
158
|
end
|
|
@@ -167,10 +168,11 @@ RSpec.describe Relaton::Registry do
|
|
|
167
168
|
|
|
168
169
|
it "find processot by dataset" do
|
|
169
170
|
expect(Relaton::Registry.instance.find_processor_by_dataset("nist-tech-pubs"))
|
|
170
|
-
.to be_instance_of
|
|
171
|
+
.to be_instance_of Relaton::Nist::Processor
|
|
171
172
|
end
|
|
172
173
|
|
|
173
174
|
it "find processor by dataset" do
|
|
174
|
-
expect(Relaton::Registry.instance.find_processor_by_dataset
|
|
175
|
+
expect(Relaton::Registry.instance.find_processor_by_dataset("etsi-csv"))
|
|
176
|
+
.to be_instance_of Relaton::Etsi::Processor
|
|
175
177
|
end
|
|
176
178
|
end
|
data/spec/relaton/util_spec.rb
CHANGED