relaton 1.20.3 → 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/.github/workflows/rake.yml +0 -1
- 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 -30
- 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 +344 -176
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +12593 -13227
- 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 +46 -42
- data/spec/vcr_cassetes/cie_001_1980.yml +288 -248
- data/spec/vcr_cassetes/cipm_meeting_43.yml +1378 -1370
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +3 -3
- data/spec/vcr_cassetes/ecma_6.yml +168 -166
- data/spec/vcr_cassetes/en_10160_1999.yml +11086 -11233
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +456 -596
- data/spec/vcr_cassetes/ieee_528_2019.yml +2630 -2410
- data/spec/vcr_cassetes/iso_19115_1.yml +13688 -13955
- data/spec/vcr_cassetes/iso_19115_1_2.yml +236 -245
- data/spec/vcr_cassetes/iso_19115_1_std.yml +13688 -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 +238 -237
- 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 +246 -245
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +255 -258
- data/spec/vcr_cassetes/rfc_8341.yml +1088 -1090
- metadata +62 -66
- data/lib/relaton/processor.rb +0 -46
- data/spec/relaton/processor_spec.rb +0 -113
data/spec/relaton_spec.rb
CHANGED
|
@@ -15,27 +15,31 @@ RSpec.describe Relaton::Db do
|
|
|
15
15
|
|
|
16
16
|
it "rejects an illegal reference prefix" do
|
|
17
17
|
expect { @db.fetch("XYZ XYZ", nil, {}) }.to output(
|
|
18
|
-
/\[relaton\] INFO: \(XYZ XYZ\) `XYZ XYZ` does not
|
|
18
|
+
/\[relaton\] INFO: \(XYZ XYZ\) `XYZ XYZ` does not/,
|
|
19
19
|
).to_stderr_from_any_process
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
context "gets an ISO reference" do
|
|
23
23
|
it "and caches it" do
|
|
24
|
-
docid =
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ISO 19115-1",
|
|
25
|
+
type: "ISO")
|
|
26
|
+
item = Relaton::Iso::ItemData.new(
|
|
27
|
+
docid: [docid], fetched: Date.today.to_s,
|
|
28
|
+
)
|
|
29
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
30
|
+
.with("ISO 19115-1", nil, {}).and_return item
|
|
27
31
|
bib = @db.fetch("ISO 19115-1", nil, {})
|
|
28
|
-
expect(bib).to be_instance_of
|
|
32
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
29
33
|
bib = @db.fetch("ISO 19115-1", nil, {})
|
|
30
|
-
expect(bib).to be_instance_of
|
|
34
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
it "with year in code" do
|
|
34
38
|
VCR.use_cassette "iso_19133_2005" do
|
|
35
39
|
bib = @db.fetch("ISO 19133:2005")
|
|
36
|
-
expect(bib).to be_instance_of
|
|
40
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
37
41
|
xml = bib.to_xml
|
|
38
|
-
expect(xml).to include 'id="
|
|
42
|
+
expect(xml).to include 'id="ISO191332005"'
|
|
39
43
|
expect(xml).to include 'type="standard"'
|
|
40
44
|
testcache = Relaton::DbCache.new "testcache"
|
|
41
45
|
expect(
|
|
@@ -48,14 +52,14 @@ RSpec.describe Relaton::Db do
|
|
|
48
52
|
it "implicity" do
|
|
49
53
|
VCR.use_cassette "iso_19115_all_parts" do
|
|
50
54
|
bib = @db.fetch("ISO 19115", nil, all_parts: true)
|
|
51
|
-
expect(bib.docidentifier[0].
|
|
55
|
+
expect(bib.docidentifier[0].content).to eq "ISO 19115 (all parts)"
|
|
52
56
|
end
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
it "explicity" do
|
|
56
60
|
VCR.use_cassette "iso_19115_all_parts" do
|
|
57
61
|
bib = @db.fetch("ISO 19115 (all parts)")
|
|
58
|
-
expect(bib.docidentifier[0].
|
|
62
|
+
expect(bib.docidentifier[0].content).to eq "ISO 19115 (all parts)"
|
|
59
63
|
end
|
|
60
64
|
end
|
|
61
65
|
end
|
|
@@ -63,47 +67,57 @@ RSpec.describe Relaton::Db do
|
|
|
63
67
|
it "gets sn ISO/DIS reference" do
|
|
64
68
|
VCR.use_cassette "iso_dis" do
|
|
65
69
|
bib = @db.fetch "ISO/DIS 14460"
|
|
66
|
-
expect(bib.docidentifier[0].
|
|
70
|
+
expect(bib.docidentifier[0].content).to eq "ISO/DIS 14460"
|
|
67
71
|
end
|
|
68
72
|
end
|
|
69
73
|
end
|
|
70
74
|
|
|
71
75
|
context "IEC" do
|
|
72
76
|
before do
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
item =
|
|
76
|
-
expect(
|
|
77
|
+
docid = Relaton::Bib::Docidentifier.new(content: "IEC 60050-102:2007",
|
|
78
|
+
type: "IEC")
|
|
79
|
+
item = Relaton::Iec::ItemData.new docidentifier: [docid]
|
|
80
|
+
expect(Relaton::Iec::Bibliography).to receive(:get).with(
|
|
81
|
+
"IEC 60050-102:2007", nil, {}
|
|
82
|
+
).and_return item
|
|
77
83
|
end
|
|
78
84
|
|
|
79
85
|
it "get by reference" do
|
|
80
86
|
bib = @db.fetch "IEC 60050-102:2007"
|
|
81
|
-
expect(bib.docidentifier[0].
|
|
87
|
+
expect(bib.docidentifier[0].content).to eq "IEC 60050-102:2007"
|
|
82
88
|
end
|
|
83
89
|
|
|
84
90
|
it "get by URN" do
|
|
85
91
|
bib = @db.fetch "urn:iec:std:iec:60050-102:2007:::"
|
|
86
|
-
expect(bib.docidentifier[0].
|
|
92
|
+
expect(bib.docidentifier[0].content).to eq "IEC 60050-102:2007"
|
|
87
93
|
end
|
|
88
94
|
end
|
|
89
95
|
|
|
90
96
|
context "NIST references" do
|
|
91
97
|
it "gets FISP" do
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
require "relaton/nist"
|
|
99
|
+
docid = Relaton::Bib::Docidentifier.new(content: "NIST FIPS 140",
|
|
100
|
+
type: "NIST")
|
|
101
|
+
item = Relaton::Nist::ItemData.new docidentifier: [docid]
|
|
102
|
+
expect(Relaton::Nist::Bibliography).to receive(:get).with(
|
|
103
|
+
"NIST FIPS 140", nil, {}
|
|
104
|
+
).and_return item
|
|
95
105
|
bib = @db.fetch "NIST FIPS 140"
|
|
96
|
-
expect(bib).to be_instance_of
|
|
97
|
-
expect(bib.docidentifier[0].
|
|
106
|
+
expect(bib).to be_instance_of Relaton::Nist::ItemData
|
|
107
|
+
expect(bib.docidentifier[0].content).to eq "NIST FIPS 140"
|
|
98
108
|
end
|
|
99
109
|
|
|
100
110
|
it "gets SP" do
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
require "relaton/nist"
|
|
112
|
+
docid = Relaton::Bib::Docidentifier.new(content: "NIST SP 800-38B",
|
|
113
|
+
type: "NIST")
|
|
114
|
+
item = Relaton::Nist::ItemData.new docidentifier: [docid]
|
|
115
|
+
expect(Relaton::Nist::Bibliography).to receive(:get).with(
|
|
116
|
+
"NIST SP 800-38B", nil, {}
|
|
117
|
+
).and_return item
|
|
104
118
|
bib = @db.fetch "NIST SP 800-38B"
|
|
105
|
-
expect(bib).to be_instance_of
|
|
106
|
-
expect(bib.docidentifier[0].
|
|
119
|
+
expect(bib).to be_instance_of Relaton::Nist::ItemData
|
|
120
|
+
expect(bib.docidentifier[0].content).to eq "NIST SP 800-38B"
|
|
107
121
|
end
|
|
108
122
|
end
|
|
109
123
|
|
|
@@ -150,19 +164,19 @@ RSpec.describe Relaton::Db do
|
|
|
150
164
|
it "and cache it" do
|
|
151
165
|
VCR.use_cassette "gb_t_20223_2006" do
|
|
152
166
|
bib = @db.fetch "CN(GB/T 20223)", "2006", {}
|
|
153
|
-
expect(bib).to be_instance_of
|
|
167
|
+
expect(bib).to be_instance_of Relaton::Gb::ItemData
|
|
154
168
|
expect(bib.to_xml(bibdata: true)).to include <<~XML
|
|
155
|
-
<project-number>GB/T 20223</project-number>
|
|
169
|
+
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
156
170
|
XML
|
|
157
171
|
expect(File.exist?("testcache")).to be true
|
|
158
172
|
expect(File.exist?("testcache2")).to be true
|
|
159
173
|
testcache = Relaton::DbCache.new "testcache"
|
|
160
174
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
161
|
-
<project-number>GB/T 20223</project-number>
|
|
175
|
+
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
162
176
|
XML
|
|
163
177
|
testcache = Relaton::DbCache.new "testcache2"
|
|
164
178
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
165
|
-
<project-number>GB/T 20223</project-number>
|
|
179
|
+
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
166
180
|
XML
|
|
167
181
|
end
|
|
168
182
|
end
|
|
@@ -170,19 +184,19 @@ RSpec.describe Relaton::Db do
|
|
|
170
184
|
it "with year" do
|
|
171
185
|
VCR.use_cassette "gb_t_20223_2006" do
|
|
172
186
|
bib = @db.fetch "CN(GB/T 20223-2006)", nil, {}
|
|
173
|
-
expect(bib).to be_instance_of
|
|
187
|
+
expect(bib).to be_instance_of Relaton::Gb::ItemData
|
|
174
188
|
expect(bib.to_xml(bibdata: true)).to include <<~XML
|
|
175
|
-
<project-number>GB/T 20223</project-number>
|
|
189
|
+
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
176
190
|
XML
|
|
177
191
|
expect(File.exist?("testcache")).to be true
|
|
178
192
|
expect(File.exist?("testcache2")).to be true
|
|
179
193
|
testcache = Relaton::DbCache.new "testcache"
|
|
180
194
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
181
|
-
<project-number>GB/T 20223</project-number>
|
|
195
|
+
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
182
196
|
XML
|
|
183
197
|
testcache = Relaton::DbCache.new "testcache2"
|
|
184
198
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
185
|
-
<project-number>GB/T 20223</project-number>
|
|
199
|
+
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
186
200
|
XML
|
|
187
201
|
end
|
|
188
202
|
end
|
|
@@ -191,8 +205,10 @@ RSpec.describe Relaton::Db do
|
|
|
191
205
|
it "get RFC reference and cache it" do
|
|
192
206
|
VCR.use_cassette "rfc_8341" do
|
|
193
207
|
bib = @db.fetch "RFC 8341", nil, {}
|
|
194
|
-
expect(bib).to be_instance_of
|
|
195
|
-
expect(bib.to_xml).to match(
|
|
208
|
+
expect(bib).to be_instance_of Relaton::Ietf::ItemData
|
|
209
|
+
expect(bib.to_xml).to match(
|
|
210
|
+
/<bibitem id="RFC8341" type="standard" schema-version="v[\d.]+">/,
|
|
211
|
+
)
|
|
196
212
|
expect(File.exist?("testcache")).to be true
|
|
197
213
|
expect(File.exist?("testcache2")).to be true
|
|
198
214
|
testcache = Relaton::DbCache.new "testcache"
|
|
@@ -215,190 +231,238 @@ RSpec.describe Relaton::Db do
|
|
|
215
231
|
.at_most :once
|
|
216
232
|
allow(File).to receive(:write).and_call_original
|
|
217
233
|
VCR.use_cassette "ogc_19_025r1" do
|
|
218
|
-
|
|
219
|
-
expect(File).to receive(:exist?).with(
|
|
234
|
+
ogc_bib = "/Users/andrej/.relaton/ogc/bibliography.json"
|
|
235
|
+
expect(File).to receive(:exist?).with(ogc_bib)
|
|
236
|
+
.and_return(false).at_most :once
|
|
237
|
+
ogc_etag = "/Users/andrej/.relaton/ogc/etag.txt"
|
|
238
|
+
expect(File).to receive(:exist?).with(ogc_etag)
|
|
239
|
+
.and_return(false).at_most :once
|
|
220
240
|
allow(File).to receive(:exist?).and_call_original
|
|
221
241
|
bib = @db.fetch "OGC 19-025r1", nil, {}
|
|
222
|
-
expect(bib).to be_instance_of
|
|
242
|
+
expect(bib).to be_instance_of Relaton::Ogc::ItemData
|
|
223
243
|
end
|
|
224
244
|
end
|
|
225
245
|
|
|
226
246
|
it "get Calconnect refrence and cache it" do
|
|
227
247
|
VCR.use_cassette "cc_dir_10005_2019", match_requests_on: [:path] do
|
|
228
248
|
bib = @db.fetch "CC/DIR 10005:2019", nil, {}
|
|
229
|
-
expect(bib).to be_instance_of
|
|
249
|
+
expect(bib).to be_instance_of Relaton::Calconnect::ItemData
|
|
230
250
|
end
|
|
231
251
|
end
|
|
232
252
|
|
|
233
253
|
it "get OMG reference" do
|
|
234
254
|
VCR.use_cassette "omg_ami4ccm_1_0" do
|
|
235
255
|
bib = @db.fetch "OMG AMI4CCM 1.0", nil, {}
|
|
236
|
-
expect(bib).to be_instance_of
|
|
256
|
+
expect(bib).to be_instance_of Relaton::Bib::ItemData
|
|
237
257
|
end
|
|
238
258
|
end
|
|
239
259
|
|
|
240
260
|
# it "get UN reference" do
|
|
241
|
-
# docid = RelatonBib::DocumentIdentifier.new(
|
|
242
|
-
#
|
|
243
|
-
#
|
|
261
|
+
# docid = RelatonBib::DocumentIdentifier.new(
|
|
262
|
+
# id: "UN TRADE/CEFACT/2004/32", type: "UN",
|
|
263
|
+
# )
|
|
264
|
+
# item = RelatonUn::UnBibliographicItem.new(
|
|
265
|
+
# docid: [docid],
|
|
266
|
+
# session: RelatonUn::Session.new(session_number: "1"),
|
|
267
|
+
# )
|
|
268
|
+
# expect(RelatonUn::UnBibliography).to receive(:get)
|
|
269
|
+
# .with("UN TRADE/CEFACT/2004/32", nil, {})
|
|
270
|
+
# .and_return item
|
|
244
271
|
# bib = @db.fetch "UN TRADE/CEFACT/2004/32", nil, {}
|
|
245
|
-
# expect(bib).to be_instance_of
|
|
246
|
-
#
|
|
272
|
+
# expect(bib).to be_instance_of(
|
|
273
|
+
# RelatonUn::UnBibliographicItem,
|
|
274
|
+
# )
|
|
275
|
+
# expect(bib.docidentifier.first.id)
|
|
276
|
+
# .to eq "UN TRADE/CEFACT/2004/32"
|
|
247
277
|
# end
|
|
248
278
|
|
|
249
279
|
it "get W3C reference" do
|
|
250
|
-
require "
|
|
251
|
-
docid =
|
|
252
|
-
|
|
253
|
-
|
|
280
|
+
require "relaton/w3c"
|
|
281
|
+
docid = Relaton::Bib::Docidentifier.new(
|
|
282
|
+
content: "W3C REC-json-ld11-20200716", type: "W3C",
|
|
283
|
+
)
|
|
284
|
+
item = Relaton::W3c::ItemData.new docidentifier: [docid]
|
|
285
|
+
expect(Relaton::W3c::Bibliography).to receive(:get).with(
|
|
286
|
+
"W3C REC-json-ld11-20200716", nil, {}
|
|
287
|
+
).and_return item
|
|
254
288
|
bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
|
|
255
|
-
expect(bib).to be_instance_of
|
|
256
|
-
expect(bib.docidentifier.first.
|
|
289
|
+
expect(bib).to be_instance_of Relaton::W3c::ItemData
|
|
290
|
+
expect(bib.docidentifier.first.content).to eq "W3C REC-json-ld11-20200716"
|
|
257
291
|
end
|
|
258
292
|
|
|
259
293
|
it "get CCSDS reference" do
|
|
260
|
-
require "
|
|
261
|
-
docid =
|
|
262
|
-
|
|
263
|
-
|
|
294
|
+
require "relaton/ccsds"
|
|
295
|
+
docid = Relaton::Bib::Docidentifier.new content: "CCSDS 230.2-G-1",
|
|
296
|
+
type: "CCSDS"
|
|
297
|
+
item = Relaton::Ccsds::ItemData.new docidentifier: [docid]
|
|
298
|
+
expect(Relaton::Ccsds::Bibliography).to receive(:get).with(
|
|
299
|
+
"CCSDS 230.2-G-1", nil, {}
|
|
300
|
+
).and_return item
|
|
264
301
|
bib = @db.fetch "CCSDS 230.2-G-1", nil, {}
|
|
265
|
-
expect(bib).to be_instance_of
|
|
266
|
-
expect(bib.docidentifier.first.
|
|
302
|
+
expect(bib).to be_instance_of Relaton::Ccsds::ItemData
|
|
303
|
+
expect(bib.docidentifier.first.content).to eq "CCSDS 230.2-G-1"
|
|
267
304
|
end
|
|
268
305
|
|
|
269
306
|
it "get IEEE reference", vcr: "ieee_528_2019" do
|
|
270
307
|
bib = @db.fetch "IEEE Std 528-2019"
|
|
271
|
-
expect(bib).to be_instance_of
|
|
308
|
+
expect(bib).to be_instance_of Relaton::Ieee::ItemData
|
|
272
309
|
end
|
|
273
310
|
|
|
274
311
|
it "get IHO reference" do
|
|
275
|
-
require "
|
|
276
|
-
docid =
|
|
277
|
-
item =
|
|
278
|
-
expect(
|
|
312
|
+
require "relaton/iho"
|
|
313
|
+
docid = Relaton::Bib::Docidentifier.new(content: "IHO B-11", type: "IHO")
|
|
314
|
+
item = Relaton::Iho::ItemData.new docidentifier: [docid]
|
|
315
|
+
expect(Relaton::Iho::Bibliography).to receive(:get).with("IHO B-11", nil,
|
|
316
|
+
{}).and_return item
|
|
279
317
|
bib = @db.fetch "IHO B-11"
|
|
280
|
-
expect(bib).to be_instance_of
|
|
281
|
-
expect(bib.docidentifier.first.
|
|
318
|
+
expect(bib).to be_instance_of Relaton::Iho::ItemData
|
|
319
|
+
expect(bib.docidentifier.first.content).to eq "IHO B-11"
|
|
282
320
|
end
|
|
283
321
|
|
|
284
322
|
it "get ECMA reference" do
|
|
285
323
|
VCR.use_cassette "ecma_6" do
|
|
286
324
|
bib = @db.fetch "ECMA-6"
|
|
287
|
-
expect(bib).to be_instance_of
|
|
325
|
+
expect(bib).to be_instance_of Relaton::Ecma::ItemData
|
|
288
326
|
end
|
|
289
327
|
end
|
|
290
328
|
|
|
291
329
|
it "get CIE reference" do
|
|
292
330
|
VCR.use_cassette "cie_001_1980" do
|
|
293
331
|
bib = @db.fetch "CIE 001-1980"
|
|
294
|
-
expect(bib).to be_instance_of
|
|
332
|
+
expect(bib).to be_instance_of Relaton::Cie::ItemData
|
|
295
333
|
end
|
|
296
334
|
end
|
|
297
335
|
|
|
298
336
|
it "get BSI reference" do
|
|
299
|
-
require "
|
|
300
|
-
docid =
|
|
301
|
-
|
|
302
|
-
|
|
337
|
+
require "relaton/bsi"
|
|
338
|
+
docid = Relaton::Bib::Docidentifier.new(content: "BSI BS EN ISO 8848",
|
|
339
|
+
type: "BSI")
|
|
340
|
+
item = Relaton::Bsi::ItemData.new docidentifier: [docid]
|
|
341
|
+
expect(Relaton::Bsi::Bibliography).to receive(:get).with(
|
|
342
|
+
"BSI BS EN ISO 8848", nil, {}
|
|
343
|
+
).and_return item
|
|
303
344
|
bib = @db.fetch "BSI BS EN ISO 8848"
|
|
304
|
-
expect(bib).to be_instance_of
|
|
345
|
+
expect(bib).to be_instance_of Relaton::Bsi::ItemData
|
|
305
346
|
end
|
|
306
347
|
|
|
307
348
|
it "get CEN reference" do
|
|
308
349
|
VCR.use_cassette "en_10160_1999" do
|
|
309
350
|
bib = @db.fetch "EN 10160:1999"
|
|
310
|
-
expect(bib).to be_instance_of
|
|
351
|
+
expect(bib).to be_instance_of Relaton::Cen::ItemData
|
|
311
352
|
end
|
|
312
353
|
end
|
|
313
354
|
|
|
314
355
|
it "get IANA reference" do
|
|
315
|
-
require "
|
|
316
|
-
docid =
|
|
317
|
-
|
|
318
|
-
|
|
356
|
+
require "relaton/iana"
|
|
357
|
+
docid = Relaton::Bib::Docidentifier.new(
|
|
358
|
+
content: "IANA service-names-port-numbers", type: "IANA",
|
|
359
|
+
)
|
|
360
|
+
item = Relaton::Iana::ItemData.new docidentifier: [docid]
|
|
361
|
+
expect(Relaton::Iana::Bibliography).to receive(:get).with(
|
|
362
|
+
"IANA service-names-port-numbers", nil, {}
|
|
363
|
+
).and_return item
|
|
319
364
|
bib = @db.fetch "IANA service-names-port-numbers"
|
|
320
|
-
expect(bib).to be_instance_of
|
|
365
|
+
expect(bib).to be_instance_of Relaton::Iana::ItemData
|
|
321
366
|
end
|
|
322
367
|
|
|
323
368
|
it "get 3GPP reference" do
|
|
324
369
|
VCR.use_cassette "3gpp_tr_00_01u_umts_3_0_0" do
|
|
325
370
|
bib = @db.fetch "3GPP TR 00.01U:UMTS/3.0.0"
|
|
326
|
-
expect(bib).to be_instance_of
|
|
371
|
+
expect(bib).to be_instance_of Relaton::ThreeGpp::ItemData
|
|
327
372
|
end
|
|
328
373
|
end
|
|
329
374
|
|
|
330
375
|
it "get OASIS reference" do
|
|
331
|
-
require "
|
|
332
|
-
docid =
|
|
333
|
-
|
|
334
|
-
|
|
376
|
+
require "relaton/oasis"
|
|
377
|
+
docid = Relaton::Bib::Docidentifier.new(
|
|
378
|
+
content: "OASIS amqp-core-types-v1.0-Pt1", type: "OASIS",
|
|
379
|
+
)
|
|
380
|
+
item = Relaton::Oasis::ItemData.new docidentifier: [docid]
|
|
381
|
+
expect(Relaton::Oasis::Bibliography).to receive(:get).with(
|
|
382
|
+
"OASIS amqp-core-types-v1.0-Pt1", nil, {}
|
|
383
|
+
).and_return item
|
|
335
384
|
bib = @db.fetch "OASIS amqp-core-types-v1.0-Pt1"
|
|
336
|
-
expect(bib).to be_instance_of
|
|
385
|
+
expect(bib).to be_instance_of Relaton::Oasis::ItemData
|
|
337
386
|
end
|
|
338
387
|
|
|
339
388
|
it "get BIPM reference" do
|
|
340
|
-
require "
|
|
341
|
-
docid =
|
|
342
|
-
|
|
343
|
-
|
|
389
|
+
require "relaton/bipm"
|
|
390
|
+
docid = Relaton::Bib::Docidentifier.new(
|
|
391
|
+
content: "BIPM Metrologia 29 6 373", type: "BIPM",
|
|
392
|
+
)
|
|
393
|
+
item = Relaton::Bipm::ItemData.new docidentifier: [docid]
|
|
394
|
+
expect(Relaton::Bipm::Bibliography).to receive(:get).with(
|
|
395
|
+
"BIPM Metrologia 29 6 373", nil, {}
|
|
396
|
+
).and_return item
|
|
344
397
|
bib = @db.fetch "BIPM Metrologia 29 6 373"
|
|
345
|
-
expect(bib).to be_instance_of
|
|
346
|
-
expect(bib.docidentifier.first.
|
|
398
|
+
expect(bib).to be_instance_of Relaton::Bipm::ItemData
|
|
399
|
+
expect(bib.docidentifier.first.content).to eq "BIPM Metrologia 29 6 373"
|
|
347
400
|
end
|
|
348
401
|
|
|
349
402
|
it "get DOI reference", vcr: "doi_10_6028_nist_ir_8245" do
|
|
350
403
|
bib = @db.fetch "doi:10.6028/nist.ir.8245"
|
|
351
|
-
expect(bib).to be_instance_of
|
|
404
|
+
expect(bib).to be_instance_of Relaton::Bib::ItemData
|
|
352
405
|
end
|
|
353
406
|
|
|
354
407
|
it "get JIS reference" do
|
|
355
|
-
require "
|
|
356
|
-
docid =
|
|
357
|
-
item =
|
|
358
|
-
expect(
|
|
408
|
+
require "relaton/jis"
|
|
409
|
+
docid = Relaton::Bib::Docidentifier.new(content: "JIS X 0001", type: "JIS")
|
|
410
|
+
item = Relaton::Jis::ItemData.new docidentifier: [docid]
|
|
411
|
+
expect(Relaton::Jis::Bibliography).to receive(:get).with("JIS X 0001", nil,
|
|
412
|
+
{}).and_return item
|
|
359
413
|
bib = @db.fetch "JIS X 0001"
|
|
360
|
-
expect(bib).to be_instance_of
|
|
361
|
-
expect(bib.docidentifier.first.
|
|
414
|
+
expect(bib).to be_instance_of Relaton::Jis::ItemData
|
|
415
|
+
expect(bib.docidentifier.first.content).to eq "JIS X 0001"
|
|
362
416
|
end
|
|
363
417
|
|
|
364
418
|
it "get XSF reference" do
|
|
365
|
-
require "
|
|
366
|
-
docid =
|
|
367
|
-
item =
|
|
368
|
-
expect(
|
|
419
|
+
require "relaton/xsf"
|
|
420
|
+
docid = Relaton::Bib::Docidentifier.new(content: "XEP 0001", type: "XSF")
|
|
421
|
+
item = Relaton::Bib::ItemData.new docidentifier: [docid]
|
|
422
|
+
expect(Relaton::Xsf::Bibliography).to receive(:get).with("XEP 0001", nil,
|
|
423
|
+
{}).and_return item
|
|
369
424
|
bib = @db.fetch "XEP 0001"
|
|
370
|
-
expect(bib).to be_instance_of
|
|
371
|
-
expect(bib.docidentifier.first.
|
|
425
|
+
expect(bib).to be_instance_of Relaton::Bib::ItemData
|
|
426
|
+
expect(bib.docidentifier.first.content).to eq "XEP 0001"
|
|
372
427
|
end
|
|
373
428
|
|
|
374
429
|
it "get ETSI reference" do
|
|
375
|
-
require "
|
|
376
|
-
docid =
|
|
377
|
-
|
|
378
|
-
|
|
430
|
+
require "relaton/etsi"
|
|
431
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ETSI EN 300 175-8",
|
|
432
|
+
type: "ETSI")
|
|
433
|
+
item = Relaton::Etsi::ItemData.new docidentifier: [docid]
|
|
434
|
+
expect(Relaton::Etsi::Bibliography).to receive(:get).with(
|
|
435
|
+
"ETSI EN 300 175-8", nil, {}
|
|
436
|
+
).and_return item
|
|
379
437
|
bib = @db.fetch "ETSI EN 300 175-8"
|
|
380
|
-
expect(bib).to be_instance_of
|
|
381
|
-
expect(bib.docidentifier.first.
|
|
438
|
+
expect(bib).to be_instance_of Relaton::Etsi::ItemData
|
|
439
|
+
expect(bib.docidentifier.first.content).to eq "ETSI EN 300 175-8"
|
|
382
440
|
end
|
|
383
441
|
|
|
384
442
|
it "get ISBN reference" do
|
|
385
|
-
require "
|
|
386
|
-
docid =
|
|
387
|
-
|
|
388
|
-
|
|
443
|
+
require "relaton/isbn"
|
|
444
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ISBN 978-0-580-50101-4",
|
|
445
|
+
type: "ISBN")
|
|
446
|
+
item = Relaton::Bib::ItemData.new docidentifier: [docid]
|
|
447
|
+
expect(Relaton::Isbn::OpenLibrary).to receive(:get).with(
|
|
448
|
+
"ISBN 978-0-580-50101-4", nil, {}
|
|
449
|
+
).and_return item
|
|
389
450
|
bib = @db.fetch "ISBN 978-0-580-50101-4"
|
|
390
|
-
expect(bib).to be_instance_of
|
|
391
|
-
expect(bib.docidentifier.first.
|
|
451
|
+
expect(bib).to be_instance_of Relaton::Bib::ItemData
|
|
452
|
+
expect(bib.docidentifier.first.content).to eq "ISBN 978-0-580-50101-4"
|
|
392
453
|
end
|
|
393
454
|
|
|
394
455
|
it "get PLATEAU reference" do
|
|
395
456
|
require "relaton/plateau"
|
|
396
|
-
docid =
|
|
397
|
-
|
|
398
|
-
|
|
457
|
+
docid = Relaton::Bib::Docidentifier.new(content: "PLATEAU Hanbook #01",
|
|
458
|
+
type: "PLATEAU")
|
|
459
|
+
item = Relaton::Plateau::ItemData.new docidentifier: [docid]
|
|
460
|
+
expect(Relaton::Plateau::Bibliography).to receive(:get).with(
|
|
461
|
+
"PLATEAU Hanbook #01", nil, {}
|
|
462
|
+
).and_return item
|
|
399
463
|
bib = @db.fetch "PLATEAU Hanbook #01"
|
|
400
|
-
expect(bib).to be_instance_of Relaton::Plateau::
|
|
401
|
-
expect(bib.docidentifier.first.
|
|
464
|
+
expect(bib).to be_instance_of Relaton::Plateau::ItemData
|
|
465
|
+
expect(bib.docidentifier.first.content).to eq "PLATEAU Hanbook #01"
|
|
402
466
|
end
|
|
403
467
|
|
|
404
468
|
context "get combined documents" do
|
|
@@ -406,99 +470,197 @@ RSpec.describe Relaton::Db do
|
|
|
406
470
|
it "included" do
|
|
407
471
|
VCR.use_cassette "iso_combined_included" do
|
|
408
472
|
bib = @db.fetch "ISO 19115-1:2014 + Amd 1"
|
|
409
|
-
expect(bib.docidentifier[0].
|
|
473
|
+
expect(bib.docidentifier[0].content)
|
|
474
|
+
.to eq "ISO 19115-1:2014 + Amd 1"
|
|
410
475
|
expect(bib.relation[0].type).to eq "updates"
|
|
411
|
-
|
|
476
|
+
rel0 = bib.relation[0].bibitem
|
|
477
|
+
expect(rel0.docidentifier[0].content)
|
|
478
|
+
.to eq "ISO 19115-1:2014"
|
|
412
479
|
expect(bib.relation[1].type).to eq "derivedFrom"
|
|
413
480
|
expect(bib.relation[1].description).to be_nil
|
|
414
|
-
|
|
481
|
+
rel1 = bib.relation[1].bibitem
|
|
482
|
+
expect(rel1.docidentifier[0].content)
|
|
483
|
+
.to eq "ISO 19115-1:2014/Amd 1:2018"
|
|
415
484
|
end
|
|
416
485
|
end
|
|
417
486
|
|
|
418
487
|
it "applied" do
|
|
419
488
|
VCR.use_cassette "iso_combined_applied" do
|
|
420
489
|
bib = @db.fetch "ISO 19115-1:2014, Amd 1"
|
|
421
|
-
expect(bib.docidentifier[0].
|
|
490
|
+
expect(bib.docidentifier[0].content)
|
|
491
|
+
.to eq "ISO 19115-1:2014, Amd 1"
|
|
422
492
|
expect(bib.relation[0].type).to eq "updates"
|
|
423
|
-
|
|
493
|
+
rel0 = bib.relation[0].bibitem
|
|
494
|
+
expect(rel0.docidentifier[0].content)
|
|
495
|
+
.to eq "ISO 19115-1:2014"
|
|
424
496
|
expect(bib.relation[1].type).to eq "complements"
|
|
425
|
-
expect(bib.relation[1].description.content)
|
|
426
|
-
|
|
497
|
+
expect(bib.relation[1].description.content)
|
|
498
|
+
.to eq "amendment"
|
|
499
|
+
rel1 = bib.relation[1].bibitem
|
|
500
|
+
expect(rel1.docidentifier[0].content)
|
|
501
|
+
.to eq "ISO 19115-1:2014/Amd 1:2018"
|
|
427
502
|
end
|
|
428
503
|
end
|
|
429
504
|
end
|
|
430
505
|
|
|
431
506
|
context "IEC" do
|
|
432
507
|
it "included" do
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
508
|
+
require "relaton/iec"
|
|
509
|
+
docid = Relaton::Iec::Docidentifier.new(
|
|
510
|
+
content: "IEC 60027-1", type: "IEC",
|
|
511
|
+
)
|
|
512
|
+
item = Relaton::Iec::ItemData.new(
|
|
513
|
+
docidentifier: [docid],
|
|
514
|
+
)
|
|
515
|
+
expect(Relaton::Iec::Bibliography).to receive(:get)
|
|
516
|
+
.with("IEC 60027-1", nil, {}).and_return item
|
|
517
|
+
docid1 = Relaton::Iec::Docidentifier.new(
|
|
518
|
+
content: "IEC 60027-1/AMD1:1997", type: "IEC",
|
|
519
|
+
)
|
|
520
|
+
item1 = Relaton::Iec::ItemData.new(
|
|
521
|
+
docidentifier: [docid1],
|
|
522
|
+
)
|
|
523
|
+
expect(Relaton::Iec::Bibliography).to receive(:get)
|
|
524
|
+
.with("IEC 60027-1/Amd 1", nil, {})
|
|
525
|
+
.and_return item1
|
|
526
|
+
docid2 = Relaton::Iec::Docidentifier.new(
|
|
527
|
+
content: "IEC 60027-1/AMD2:2005", type: "IEC",
|
|
528
|
+
)
|
|
529
|
+
item2 = Relaton::Iec::ItemData.new(
|
|
530
|
+
docidentifier: [docid2],
|
|
531
|
+
)
|
|
532
|
+
expect(Relaton::Iec::Bibliography).to receive(:get)
|
|
533
|
+
.with("IEC 60027-1/Amd 2", nil, {})
|
|
534
|
+
.and_return item2
|
|
439
535
|
bib = @db.fetch "IEC 60027-1, Amd 1, Amd 2"
|
|
440
|
-
expect(bib.docidentifier[0].
|
|
536
|
+
expect(bib.docidentifier[0].content)
|
|
537
|
+
.to eq "IEC 60027-1, Amd 1, Amd 2"
|
|
441
538
|
expect(bib.relation[0].type).to eq "updates"
|
|
442
|
-
|
|
539
|
+
rel0 = bib.relation[0].bibitem
|
|
540
|
+
expect(rel0.docidentifier[0].content)
|
|
541
|
+
.to eq "IEC 60027-1"
|
|
443
542
|
expect(bib.relation[1].type).to eq "complements"
|
|
444
|
-
expect(bib.relation[1].description.content)
|
|
445
|
-
|
|
543
|
+
expect(bib.relation[1].description.content)
|
|
544
|
+
.to eq "amendment"
|
|
545
|
+
rel1 = bib.relation[1].bibitem
|
|
546
|
+
expect(rel1.docidentifier[0].content)
|
|
547
|
+
.to eq "IEC 60027-1/AMD1:1997"
|
|
446
548
|
expect(bib.relation[2].type).to eq "complements"
|
|
447
|
-
expect(bib.relation[2].description.content)
|
|
448
|
-
|
|
549
|
+
expect(bib.relation[2].description.content)
|
|
550
|
+
.to eq "amendment"
|
|
551
|
+
rel2 = bib.relation[2].bibitem
|
|
552
|
+
expect(rel2.docidentifier[0].content)
|
|
553
|
+
.to eq "IEC 60027-1/AMD2:2005"
|
|
449
554
|
end
|
|
450
555
|
end
|
|
451
556
|
|
|
452
557
|
context "ITU" do
|
|
453
558
|
it "included" do
|
|
454
|
-
require "
|
|
455
|
-
docid =
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
559
|
+
require "relaton/itu"
|
|
560
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ITU-T G.989.2",
|
|
561
|
+
type: "ITU")
|
|
562
|
+
org = Relaton::Bib::Organization.new(
|
|
563
|
+
name: [Relaton::Bib::TypedLocalizedString.new(
|
|
564
|
+
content: "International Telecommunication Union",
|
|
565
|
+
)],
|
|
566
|
+
abbreviation: Relaton::Bib::LocalizedString.new(content: "ITU-T"),
|
|
567
|
+
subdivision: [Relaton::Bib::Subdivision.new(
|
|
568
|
+
type: "technical-committee",
|
|
569
|
+
subtype: "study-group",
|
|
570
|
+
name: [Relaton::Bib::TypedLocalizedString.new(content: "Group")],
|
|
571
|
+
)],
|
|
572
|
+
)
|
|
573
|
+
role = Relaton::Bib::Contributor::Role.new(
|
|
574
|
+
type: "author",
|
|
575
|
+
description: [Relaton::Bib::LocalizedMarkedUpString.new(
|
|
576
|
+
content: "committee",
|
|
577
|
+
)],
|
|
578
|
+
)
|
|
579
|
+
contrib = Relaton::Bib::Contributor.new(organization: org, role: [role])
|
|
580
|
+
item = Relaton::Itu::ItemData.new(
|
|
581
|
+
docidentifier: [docid], contributor: [contrib],
|
|
582
|
+
)
|
|
583
|
+
expect(Relaton::Itu::Bibliography).to receive(:get).with(
|
|
584
|
+
"ITU-T G.989.2", nil, {}
|
|
585
|
+
).and_return item
|
|
586
|
+
docid1 = Relaton::Bib::Docidentifier.new(
|
|
587
|
+
content: "ITU-T G.989.2 Amd 1", type: "ITU",
|
|
588
|
+
)
|
|
589
|
+
item1 = Relaton::Itu::ItemData.new(
|
|
590
|
+
docidentifier: [docid1], contributor: [contrib],
|
|
591
|
+
)
|
|
592
|
+
expect(Relaton::Itu::Bibliography).to receive(:get).with(
|
|
593
|
+
"ITU-T G.989.2 Amd 1", nil, {}
|
|
594
|
+
).and_return item1
|
|
595
|
+
docid2 = Relaton::Bib::Docidentifier.new(
|
|
596
|
+
content: "ITU-T G.989.2 Amd 2", type: "ITU",
|
|
597
|
+
)
|
|
598
|
+
item2 = Relaton::Itu::ItemData.new(
|
|
599
|
+
docidentifier: [docid2], contributor: [contrib],
|
|
600
|
+
)
|
|
601
|
+
expect(Relaton::Itu::Bibliography).to receive(:get).with(
|
|
602
|
+
"ITU-T G.989.2 Amd 2", nil, {}
|
|
603
|
+
).and_return item2
|
|
466
604
|
bib = @db.fetch "ITU-T G.989.2, Amd 1, Amd 2"
|
|
467
|
-
expect(bib.docidentifier[0].
|
|
605
|
+
expect(bib.docidentifier[0].content)
|
|
606
|
+
.to eq "ITU-T G.989.2, Amd 1, Amd 2"
|
|
468
607
|
expect(bib.relation[0].type).to eq "updates"
|
|
469
|
-
|
|
608
|
+
rel0 = bib.relation[0].bibitem
|
|
609
|
+
expect(rel0.docidentifier[0].content)
|
|
610
|
+
.to eq "ITU-T G.989.2"
|
|
470
611
|
expect(bib.relation[1].type).to eq "complements"
|
|
471
|
-
expect(bib.relation[1].description.content)
|
|
472
|
-
|
|
612
|
+
expect(bib.relation[1].description.content)
|
|
613
|
+
.to eq "amendment"
|
|
614
|
+
rel1 = bib.relation[1].bibitem
|
|
615
|
+
expect(rel1.docidentifier[0].content)
|
|
616
|
+
.to eq "ITU-T G.989.2 Amd 1"
|
|
473
617
|
expect(bib.relation[2].type).to eq "complements"
|
|
474
|
-
expect(bib.relation[2].description.content)
|
|
475
|
-
|
|
618
|
+
expect(bib.relation[2].description.content)
|
|
619
|
+
.to eq "amendment"
|
|
620
|
+
rel2 = bib.relation[2].bibitem
|
|
621
|
+
expect(rel2.docidentifier[0].content)
|
|
622
|
+
.to eq "ITU-T G.989.2 Amd 2"
|
|
476
623
|
end
|
|
477
624
|
end
|
|
478
625
|
|
|
479
626
|
context "NIST" do
|
|
480
627
|
it "included" do
|
|
481
628
|
# VCR.use_cassette "nist_combined_included" do
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
629
|
+
require "relaton/nist"
|
|
630
|
+
doci = Relaton::Bib::Docidentifier.new(content: "SP 800-38A",
|
|
631
|
+
type: "NIST")
|
|
632
|
+
item = Relaton::Nist::ItemData.new docidentifier: [doci]
|
|
633
|
+
expect(Relaton::Nist::Bibliography).to receive(:get).with(
|
|
634
|
+
"NIST SP 800-38A", nil, {}
|
|
635
|
+
).and_return item
|
|
636
|
+
docid1 = Relaton::Bib::Docidentifier.new(content: "SP 800-38A-Add",
|
|
637
|
+
type: "NIST")
|
|
638
|
+
item1 = Relaton::Nist::ItemData.new docidentifier: [docid1]
|
|
639
|
+
expect(Relaton::Nist::Bibliography).to receive(:get).with(
|
|
640
|
+
"NIST SP 800-38A/Add", nil, {}
|
|
641
|
+
).and_return item1
|
|
488
642
|
bib = @db.fetch "NIST SP 800-38A, Add"
|
|
489
|
-
expect(bib.docidentifier[0].
|
|
643
|
+
expect(bib.docidentifier[0].content).to eq "NIST SP 800-38A, Add"
|
|
490
644
|
expect(bib.relation[0].type).to eq "updates"
|
|
491
|
-
|
|
645
|
+
rel0 = bib.relation[0].bibitem
|
|
646
|
+
expect(rel0.docidentifier[0].content)
|
|
647
|
+
.to eq "SP 800-38A"
|
|
492
648
|
expect(bib.relation[1].type).to eq "complements"
|
|
493
|
-
expect(bib.relation[1].description.content)
|
|
494
|
-
|
|
649
|
+
expect(bib.relation[1].description.content)
|
|
650
|
+
.to eq "amendment"
|
|
651
|
+
rel1 = bib.relation[1].bibitem
|
|
652
|
+
expect(rel1.docidentifier[0].content)
|
|
653
|
+
.to eq "SP 800-38A-Add"
|
|
495
654
|
# end
|
|
496
655
|
end
|
|
497
656
|
end
|
|
498
657
|
end
|
|
499
658
|
|
|
500
659
|
context "version control" do
|
|
501
|
-
before(:each)
|
|
660
|
+
before(:each) do
|
|
661
|
+
@db.save_entry "iso(test_key)",
|
|
662
|
+
"<bibitem><title>test_value</title></bibitem>"
|
|
663
|
+
end
|
|
502
664
|
|
|
503
665
|
it "shoudn't clear cache if version isn't changed" do
|
|
504
666
|
testcache = @db.instance_variable_get :@db
|
|
@@ -508,11 +670,16 @@ RSpec.describe Relaton::Db do
|
|
|
508
670
|
end
|
|
509
671
|
|
|
510
672
|
it "should clear cache if version is changed" do
|
|
511
|
-
expect(File.read("testcache/iso/version",
|
|
512
|
-
|
|
673
|
+
expect(File.read("testcache/iso/version",
|
|
674
|
+
encoding: "UTF-8")).not_to eq "new_version"
|
|
675
|
+
expect(File.read("testcache2/iso/version",
|
|
676
|
+
encoding: "UTF-8")).not_to eq "new_version"
|
|
513
677
|
processor = double "processor", short: :relaton_iso
|
|
514
|
-
expect(processor).to receive(:grammar_hash)
|
|
515
|
-
|
|
678
|
+
expect(processor).to receive(:grammar_hash)
|
|
679
|
+
.and_return("new_version").exactly(2).times
|
|
680
|
+
expect(Relaton::Registry.instance)
|
|
681
|
+
.to receive(:by_type)
|
|
682
|
+
.and_return(processor).exactly(2).times
|
|
516
683
|
Relaton::Db.new "testcache", "testcache2"
|
|
517
684
|
expect(File.exist?("testcache/iso/version")).to eq false
|
|
518
685
|
expect(File.exist?("testcache2/iso/version")).to eq false
|
|
@@ -536,19 +703,20 @@ RSpec.describe Relaton::Db do
|
|
|
536
703
|
it "get document" do
|
|
537
704
|
VCR.use_cassette "api_relaton_org" do
|
|
538
705
|
bib = @db.fetch "ISO 19115-2", "2019"
|
|
539
|
-
expect(bib).to be_instance_of
|
|
706
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
540
707
|
end
|
|
541
708
|
end
|
|
542
709
|
|
|
543
710
|
it "if unavailable then get document directly" do
|
|
544
|
-
expect(Net::HTTP).to receive(:get_response)
|
|
711
|
+
expect(Net::HTTP).to receive(:get_response)
|
|
712
|
+
.and_wrap_original do |m, *args|
|
|
545
713
|
raise Errno::ECONNREFUSED if args[0].host == "api.relaton.org"
|
|
546
714
|
|
|
547
715
|
m.call(*args)
|
|
548
716
|
end.at_least :once
|
|
549
717
|
VCR.use_cassette "api_relaton_org_unavailable" do
|
|
550
718
|
bib = @db.fetch "ISO 19115-2", "2019"
|
|
551
|
-
expect(bib).to be_instance_of
|
|
719
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
552
720
|
end
|
|
553
721
|
end
|
|
554
722
|
end
|