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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CLAUDE.md +4 -2
  4. data/Rakefile +1 -1
  5. data/bin/rspec +1 -2
  6. data/docs/README.adoc +93 -86
  7. data/lib/relaton/config.rb +2 -3
  8. data/lib/relaton/db.rb +57 -39
  9. data/lib/relaton/db_cache.rb +3 -2
  10. data/lib/relaton/registry.rb +23 -30
  11. data/lib/relaton/util.rb +2 -1
  12. data/lib/relaton/version.rb +1 -1
  13. data/lib/relaton/workers_pool.rb +1 -1
  14. data/lib/relaton.rb +6 -7
  15. data/relaton.gemspec +31 -31
  16. data/spec/relaton/db_cache_spec.rb +1 -1
  17. data/spec/relaton/db_spec.rb +84 -46
  18. data/spec/relaton/registry_spec.rb +43 -41
  19. data/spec/relaton/util_spec.rb +1 -0
  20. data/spec/relaton_spec.rb +345 -163
  21. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +12595 -13226
  22. data/spec/vcr_cassetes/api_relaton_org.yml +7 -7
  23. data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +76 -78
  24. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +48 -42
  25. data/spec/vcr_cassetes/cie_001_1980.yml +302 -262
  26. data/spec/vcr_cassetes/cipm_meeting_43.yml +1380 -1370
  27. data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +3 -3
  28. data/spec/vcr_cassetes/ecma_6.yml +182 -238
  29. data/spec/vcr_cassetes/en_10160_1999.yml +13083 -13122
  30. data/spec/vcr_cassetes/gb_t_20223_2006.yml +9 -9
  31. data/spec/vcr_cassetes/ieee_528_2019.yml +2633 -2411
  32. data/spec/vcr_cassetes/iso_19115_1.yml +13692 -13957
  33. data/spec/vcr_cassetes/iso_19115_1_2.yml +235 -244
  34. data/spec/vcr_cassetes/iso_19115_1_std.yml +13690 -13955
  35. data/spec/vcr_cassetes/iso_19115_all_parts.yml +161 -168
  36. data/spec/vcr_cassetes/iso_19133_2005.yml +83 -79
  37. data/spec/vcr_cassetes/iso_combined_applied.yml +239 -238
  38. data/spec/vcr_cassetes/iso_combined_included.yml +240 -239
  39. data/spec/vcr_cassetes/iso_dis.yml +87 -88
  40. data/spec/vcr_cassetes/ogc_19_025r1.yml +248 -243
  41. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +268 -1513
  42. data/spec/vcr_cassetes/rfc_8341.yml +1090 -1086
  43. metadata +62 -80
  44. data/lib/relaton/processor.rb +0 -46
  45. 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 have a recognised prefix/,
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 = RelatonBib::DocumentIdentifier.new(id: "ISO 19115-1", type: "ISO")
25
- item = RelatonIsoBib::IsoBibliographicItem.new docid: [docid], fetched: Date.today.to_s
26
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 19115-1", nil, {}).and_return item
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 RelatonIsoBib::IsoBibliographicItem
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 RelatonIsoBib::IsoBibliographicItem
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 RelatonIsoBib::IsoBibliographicItem
40
+ expect(bib).to be_instance_of Relaton::Iso::ItemData
37
41
  xml = bib.to_xml
38
- expect(xml).to include 'id="ISO19133-2005"'
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].id).to eq "ISO 19115 (all parts)"
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].id).to eq "ISO 19115 (all parts)"
62
+ expect(bib.docidentifier[0].content).to eq "ISO 19115 (all parts)"
59
63
  end
60
64
  end
61
65
  end
@@ -63,46 +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].id).to eq "ISO/DIS 14460"
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
- docid = RelatonBib::DocumentIdentifier.new(id: "IEC 60050-102:2007", type: "IEC")
74
- item = RelatonIec::IecBibliographicItem.new docid: [docid]
75
- expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60050-102:2007", nil, {}).and_return item
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
76
83
  end
77
84
 
78
85
  it "get by reference" do
79
86
  bib = @db.fetch "IEC 60050-102:2007"
80
- expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
87
+ expect(bib.docidentifier[0].content).to eq "IEC 60050-102:2007"
81
88
  end
82
89
 
83
90
  it "get by URN" do
84
91
  bib = @db.fetch "urn:iec:std:iec:60050-102:2007:::"
85
- expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
92
+ expect(bib.docidentifier[0].content).to eq "IEC 60050-102:2007"
86
93
  end
87
94
  end
88
95
 
89
96
  context "NIST references" do
90
97
  it "gets FISP" do
91
- docid = RelatonBib::DocumentIdentifier.new(id: "NIST FIPS 140", type: "NIST")
92
- item = RelatonNist::NistBibliographicItem.new docid: [docid]
93
- expect(RelatonNist::NistBibliography).to receive(:get).with("NIST FIPS 140", nil, {}).and_return item
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
94
105
  bib = @db.fetch "NIST FIPS 140"
95
- expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
96
- expect(bib.docidentifier[0].id).to eq "NIST FIPS 140"
106
+ expect(bib).to be_instance_of Relaton::Nist::ItemData
107
+ expect(bib.docidentifier[0].content).to eq "NIST FIPS 140"
97
108
  end
98
109
 
99
110
  it "gets SP" do
100
- docid = RelatonBib::DocumentIdentifier.new(id: "NIST SP 800-38B", type: "NIST")
101
- item = RelatonNist::NistBibliographicItem.new docid: [docid]
102
- expect(RelatonNist::NistBibliography).to receive(:get).with("NIST SP 800-38B", nil, {}).and_return item
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
103
118
  bib = @db.fetch "NIST SP 800-38B"
104
- expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
105
- expect(bib.docidentifier[0].id).to eq "NIST SP 800-38B"
119
+ expect(bib).to be_instance_of Relaton::Nist::ItemData
120
+ expect(bib.docidentifier[0].content).to eq "NIST SP 800-38B"
106
121
  end
107
122
  end
108
123
 
@@ -149,19 +164,19 @@ RSpec.describe Relaton::Db do
149
164
  it "and cache it" do
150
165
  VCR.use_cassette "gb_t_20223_2006" do
151
166
  bib = @db.fetch "CN(GB/T 20223)", "2006", {}
152
- expect(bib).to be_instance_of RelatonGb::GbBibliographicItem
167
+ expect(bib).to be_instance_of Relaton::Gb::ItemData
153
168
  expect(bib.to_xml(bibdata: true)).to include <<~XML
154
- <project-number>GB/T 20223</project-number>
169
+ <project-number origyr="2006">GB/T 20223-2006</project-number>
155
170
  XML
156
171
  expect(File.exist?("testcache")).to be true
157
172
  expect(File.exist?("testcache2")).to be true
158
173
  testcache = Relaton::DbCache.new "testcache"
159
174
  expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
160
- <project-number>GB/T 20223</project-number>
175
+ <project-number origyr="2006">GB/T 20223-2006</project-number>
161
176
  XML
162
177
  testcache = Relaton::DbCache.new "testcache2"
163
178
  expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
164
- <project-number>GB/T 20223</project-number>
179
+ <project-number origyr="2006">GB/T 20223-2006</project-number>
165
180
  XML
166
181
  end
167
182
  end
@@ -169,19 +184,19 @@ RSpec.describe Relaton::Db do
169
184
  it "with year" do
170
185
  VCR.use_cassette "gb_t_20223_2006" do
171
186
  bib = @db.fetch "CN(GB/T 20223-2006)", nil, {}
172
- expect(bib).to be_instance_of RelatonGb::GbBibliographicItem
187
+ expect(bib).to be_instance_of Relaton::Gb::ItemData
173
188
  expect(bib.to_xml(bibdata: true)).to include <<~XML
174
- <project-number>GB/T 20223</project-number>
189
+ <project-number origyr="2006">GB/T 20223-2006</project-number>
175
190
  XML
176
191
  expect(File.exist?("testcache")).to be true
177
192
  expect(File.exist?("testcache2")).to be true
178
193
  testcache = Relaton::DbCache.new "testcache"
179
194
  expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
180
- <project-number>GB/T 20223</project-number>
195
+ <project-number origyr="2006">GB/T 20223-2006</project-number>
181
196
  XML
182
197
  testcache = Relaton::DbCache.new "testcache2"
183
198
  expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
184
- <project-number>GB/T 20223</project-number>
199
+ <project-number origyr="2006">GB/T 20223-2006</project-number>
185
200
  XML
186
201
  end
187
202
  end
@@ -190,8 +205,10 @@ RSpec.describe Relaton::Db do
190
205
  it "get RFC reference and cache it" do
191
206
  VCR.use_cassette "rfc_8341" do
192
207
  bib = @db.fetch "RFC 8341", nil, {}
193
- expect(bib).to be_instance_of RelatonIetf::IetfBibliographicItem
194
- expect(bib.to_xml).to match(/<bibitem id="RFC8341" type="standard" schema-version="v[\d.]+">/)
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
+ )
195
212
  expect(File.exist?("testcache")).to be true
196
213
  expect(File.exist?("testcache2")).to be true
197
214
  testcache = Relaton::DbCache.new "testcache"
@@ -214,178 +231,238 @@ RSpec.describe Relaton::Db do
214
231
  .at_most :once
215
232
  allow(File).to receive(:write).and_call_original
216
233
  VCR.use_cassette "ogc_19_025r1" do
217
- expect(File).to receive(:exist?).with("/Users/andrej/.relaton/ogc/bibliography.json").and_return(false).at_most :once
218
- expect(File).to receive(:exist?).with("/Users/andrej/.relaton/ogc/etag.txt").and_return(false).at_most :once
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
219
240
  allow(File).to receive(:exist?).and_call_original
220
241
  bib = @db.fetch "OGC 19-025r1", nil, {}
221
- expect(bib).to be_instance_of RelatonOgc::OgcBibliographicItem
242
+ expect(bib).to be_instance_of Relaton::Ogc::ItemData
222
243
  end
223
244
  end
224
245
 
225
246
  it "get Calconnect refrence and cache it" do
226
247
  VCR.use_cassette "cc_dir_10005_2019", match_requests_on: [:path] do
227
248
  bib = @db.fetch "CC/DIR 10005:2019", nil, {}
228
- expect(bib).to be_instance_of RelatonCalconnect::CcBibliographicItem
249
+ expect(bib).to be_instance_of Relaton::Calconnect::ItemData
229
250
  end
230
251
  end
231
252
 
232
253
  it "get OMG reference" do
233
254
  VCR.use_cassette "omg_ami4ccm_1_0" do
234
255
  bib = @db.fetch "OMG AMI4CCM 1.0", nil, {}
235
- expect(bib).to be_instance_of RelatonOmg::OmgBibliographicItem
256
+ expect(bib).to be_instance_of Relaton::Bib::ItemData
236
257
  end
237
258
  end
238
259
 
239
260
  # it "get UN reference" do
240
- # docid = RelatonBib::DocumentIdentifier.new(id: "UN TRADE/CEFACT/2004/32", type: "UN")
241
- # item = RelatonUn::UnBibliographicItem.new docid: [docid], session: RelatonUn::Session.new(session_number: "1")
242
- # expect(RelatonUn::UnBibliography).to receive(:get).with("UN TRADE/CEFACT/2004/32", nil, {}).and_return item
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
243
271
  # bib = @db.fetch "UN TRADE/CEFACT/2004/32", nil, {}
244
- # expect(bib).to be_instance_of RelatonUn::UnBibliographicItem
245
- # expect(bib.docidentifier.first.id).to eq "UN TRADE/CEFACT/2004/32"
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"
246
277
  # end
247
278
 
248
279
  it "get W3C reference" do
249
- docid = RelatonBib::DocumentIdentifier.new(id: "W3C REC-json-ld11-20200716", type: "W3C")
250
- item = RelatonW3c::W3cBibliographicItem.new docid: [docid]
251
- expect(RelatonW3c::W3cBibliography).to receive(:get).with("W3C REC-json-ld11-20200716", nil, {}).and_return item
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
252
288
  bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
253
- expect(bib).to be_instance_of RelatonW3c::W3cBibliographicItem
254
- expect(bib.docidentifier.first.id).to eq "W3C REC-json-ld11-20200716"
289
+ expect(bib).to be_instance_of Relaton::W3c::ItemData
290
+ expect(bib.docidentifier.first.content).to eq "W3C REC-json-ld11-20200716"
255
291
  end
256
292
 
257
293
  it "get CCSDS reference" do
258
- docid = RelatonBib::DocumentIdentifier.new id: "CCSDS 230.2-G-1", type: "CCSDS"
259
- item = RelatonCcsds::BibliographicItem.new docid: [docid]
260
- expect(RelatonCcsds::Bibliography).to receive(:get).with("CCSDS 230.2-G-1", nil, {}).and_return item
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
261
301
  bib = @db.fetch "CCSDS 230.2-G-1", nil, {}
262
- expect(bib).to be_instance_of RelatonCcsds::BibliographicItem
263
- expect(bib.docidentifier.first.id).to eq "CCSDS 230.2-G-1"
302
+ expect(bib).to be_instance_of Relaton::Ccsds::ItemData
303
+ expect(bib.docidentifier.first.content).to eq "CCSDS 230.2-G-1"
264
304
  end
265
305
 
266
306
  it "get IEEE reference", vcr: "ieee_528_2019" do
267
307
  bib = @db.fetch "IEEE Std 528-2019"
268
- expect(bib).to be_instance_of RelatonIeee::IeeeBibliographicItem
308
+ expect(bib).to be_instance_of Relaton::Ieee::ItemData
269
309
  end
270
310
 
271
311
  it "get IHO reference" do
272
- docid = RelatonBib::DocumentIdentifier.new(id: "IHO B-11", type: "IHO")
273
- item = RelatonIho::IhoBibliographicItem.new docid: [docid]
274
- expect(RelatonIho::IhoBibliography).to receive(:get).with("IHO B-11", nil, {}).and_return item
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
275
317
  bib = @db.fetch "IHO B-11"
276
- expect(bib).to be_instance_of RelatonIho::IhoBibliographicItem
277
- expect(bib.docidentifier.first.id).to eq "IHO B-11"
318
+ expect(bib).to be_instance_of Relaton::Iho::ItemData
319
+ expect(bib.docidentifier.first.content).to eq "IHO B-11"
278
320
  end
279
321
 
280
322
  it "get ECMA reference" do
281
323
  VCR.use_cassette "ecma_6" do
282
324
  bib = @db.fetch "ECMA-6"
283
- expect(bib).to be_instance_of RelatonEcma::BibliographicItem
325
+ expect(bib).to be_instance_of Relaton::Ecma::ItemData
284
326
  end
285
327
  end
286
328
 
287
329
  it "get CIE reference" do
288
330
  VCR.use_cassette "cie_001_1980" do
289
331
  bib = @db.fetch "CIE 001-1980"
290
- expect(bib).to be_instance_of RelatonCie::BibliographicItem
332
+ expect(bib).to be_instance_of Relaton::Cie::ItemData
291
333
  end
292
334
  end
293
335
 
294
336
  it "get BSI reference" do
295
- docid = RelatonBib::DocumentIdentifier.new(id: "BSI BS EN ISO 8848", type: "BSI")
296
- item = RelatonBsi::BsiBibliographicItem.new docid: [docid]
297
- expect(RelatonBsi::BsiBibliography).to receive(:get).with("BSI BS EN ISO 8848", nil, {}).and_return item
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
298
344
  bib = @db.fetch "BSI BS EN ISO 8848"
299
- expect(bib).to be_instance_of RelatonBsi::BsiBibliographicItem
345
+ expect(bib).to be_instance_of Relaton::Bsi::ItemData
300
346
  end
301
347
 
302
348
  it "get CEN reference" do
303
349
  VCR.use_cassette "en_10160_1999" do
304
350
  bib = @db.fetch "EN 10160:1999"
305
- expect(bib).to be_instance_of RelatonCen::BibliographicItem
351
+ expect(bib).to be_instance_of Relaton::Cen::ItemData
306
352
  end
307
353
  end
308
354
 
309
355
  it "get IANA reference" do
310
- docid = RelatonBib::DocumentIdentifier.new(id: "IANA service-names-port-numbers", type: "IANA")
311
- item = RelatonIana::IanaBibliographicItem.new docid: [docid]
312
- expect(RelatonIana::IanaBibliography).to receive(:get).with("IANA service-names-port-numbers", nil, {}).and_return item
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
313
364
  bib = @db.fetch "IANA service-names-port-numbers"
314
- expect(bib).to be_instance_of RelatonIana::IanaBibliographicItem
365
+ expect(bib).to be_instance_of Relaton::Iana::ItemData
315
366
  end
316
367
 
317
368
  it "get 3GPP reference" do
318
369
  VCR.use_cassette "3gpp_tr_00_01u_umts_3_0_0" do
319
370
  bib = @db.fetch "3GPP TR 00.01U:UMTS/3.0.0"
320
- expect(bib).to be_instance_of Relaton3gpp::BibliographicItem
371
+ expect(bib).to be_instance_of Relaton::ThreeGpp::ItemData
321
372
  end
322
373
  end
323
374
 
324
375
  it "get OASIS reference" do
325
- docid = RelatonBib::DocumentIdentifier.new(id: "OASIS amqp-core-types-v1.0-Pt1", type: "OASIS")
326
- item = RelatonOasis::OasisBibliographicItem.new docid: [docid]
327
- expect(RelatonOasis::OasisBibliography).to receive(:get).with("OASIS amqp-core-types-v1.0-Pt1", nil, {}).and_return item
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
328
384
  bib = @db.fetch "OASIS amqp-core-types-v1.0-Pt1"
329
- expect(bib).to be_instance_of RelatonOasis::OasisBibliographicItem
385
+ expect(bib).to be_instance_of Relaton::Oasis::ItemData
330
386
  end
331
387
 
332
388
  it "get BIPM reference" do
333
- docid = RelatonBib::DocumentIdentifier.new(id: "BIPM Metrologia 29 6 373", type: "BIPM")
334
- item = RelatonBipm::BipmBibliographicItem.new docid: [docid]
335
- expect(RelatonBipm::BipmBibliography).to receive(:get).with("BIPM Metrologia 29 6 373", nil, {}).and_return item
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
336
397
  bib = @db.fetch "BIPM Metrologia 29 6 373"
337
- expect(bib).to be_instance_of RelatonBipm::BipmBibliographicItem
338
- expect(bib.docidentifier.first.id).to eq "BIPM Metrologia 29 6 373"
398
+ expect(bib).to be_instance_of Relaton::Bipm::ItemData
399
+ expect(bib.docidentifier.first.content).to eq "BIPM Metrologia 29 6 373"
339
400
  end
340
401
 
341
402
  it "get DOI reference", vcr: "doi_10_6028_nist_ir_8245" do
342
403
  bib = @db.fetch "doi:10.6028/nist.ir.8245"
343
- expect(bib).to be_instance_of RelatonBib::BibliographicItem
404
+ expect(bib).to be_instance_of Relaton::Bib::ItemData
344
405
  end
345
406
 
346
407
  it "get JIS reference" do
347
- docid = RelatonBib::DocumentIdentifier.new(id: "JIS X 0001", type: "JIS")
348
- item = RelatonJis::BibliographicItem.new docid: [docid]
349
- expect(RelatonJis::Bibliography).to receive(:get).with("JIS X 0001", nil, {}).and_return item
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
350
413
  bib = @db.fetch "JIS X 0001"
351
- expect(bib).to be_instance_of RelatonJis::BibliographicItem
352
- expect(bib.docidentifier.first.id).to eq "JIS X 0001"
414
+ expect(bib).to be_instance_of Relaton::Jis::ItemData
415
+ expect(bib.docidentifier.first.content).to eq "JIS X 0001"
353
416
  end
354
417
 
355
418
  it "get XSF reference" do
356
- docid = RelatonBib::DocumentIdentifier.new(id: "XEP 0001", type: "XSF")
357
- item = RelatonXsf::BibliographicItem.new docid: [docid]
358
- expect(RelatonXsf::Bibliography).to receive(:get).with("XEP 0001", nil, {}).and_return item
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
359
424
  bib = @db.fetch "XEP 0001"
360
- expect(bib).to be_instance_of RelatonXsf::BibliographicItem
361
- expect(bib.docidentifier.first.id).to eq "XEP 0001"
425
+ expect(bib).to be_instance_of Relaton::Bib::ItemData
426
+ expect(bib.docidentifier.first.content).to eq "XEP 0001"
362
427
  end
363
428
 
364
429
  it "get ETSI reference" do
365
- docid = RelatonBib::DocumentIdentifier.new(id: "ETSI EN 300 175-8", type: "ETSI")
366
- item = RelatonEtsi::BibliographicItem.new docid: [docid]
367
- expect(RelatonEtsi::Bibliography).to receive(:get).with("ETSI EN 300 175-8", nil, {}).and_return item
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
368
437
  bib = @db.fetch "ETSI EN 300 175-8"
369
- expect(bib).to be_instance_of RelatonEtsi::BibliographicItem
370
- expect(bib.docidentifier.first.id).to eq "ETSI EN 300 175-8"
438
+ expect(bib).to be_instance_of Relaton::Etsi::ItemData
439
+ expect(bib.docidentifier.first.content).to eq "ETSI EN 300 175-8"
371
440
  end
372
441
 
373
442
  it "get ISBN reference" do
374
- docid = RelatonBib::DocumentIdentifier.new(id: "ISBN 978-0-580-50101-4", type: "ISBN")
375
- item = RelatonBib::BibliographicItem.new docid: [docid]
376
- expect(RelatonIsbn::OpenLibrary).to receive(:get).with("ISBN 978-0-580-50101-4", nil, {}).and_return item
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
377
450
  bib = @db.fetch "ISBN 978-0-580-50101-4"
378
- expect(bib).to be_instance_of RelatonBib::BibliographicItem
379
- expect(bib.docidentifier.first.id).to eq "ISBN 978-0-580-50101-4"
451
+ expect(bib).to be_instance_of Relaton::Bib::ItemData
452
+ expect(bib.docidentifier.first.content).to eq "ISBN 978-0-580-50101-4"
380
453
  end
381
454
 
382
455
  it "get PLATEAU reference" do
383
- docid = RelatonBib::DocumentIdentifier.new(id: "PLATEAU Hanbook #01", type: "PLATEAU")
384
- item = Relaton::Plateau::BibItem.new docid: [docid]
385
- expect(Relaton::Plateau::Bibliography).to receive(:get).with("PLATEAU Hanbook #01", nil, {}).and_return item
456
+ require "relaton/plateau"
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
386
463
  bib = @db.fetch "PLATEAU Hanbook #01"
387
- expect(bib).to be_instance_of Relaton::Plateau::BibItem
388
- expect(bib.docidentifier.first.id).to eq "PLATEAU Hanbook #01"
464
+ expect(bib).to be_instance_of Relaton::Plateau::ItemData
465
+ expect(bib.docidentifier.first.content).to eq "PLATEAU Hanbook #01"
389
466
  end
390
467
 
391
468
  context "get combined documents" do
@@ -393,98 +470,197 @@ RSpec.describe Relaton::Db do
393
470
  it "included" do
394
471
  VCR.use_cassette "iso_combined_included" do
395
472
  bib = @db.fetch "ISO 19115-1:2014 + Amd 1"
396
- expect(bib.docidentifier[0].id).to eq "ISO 19115-1:2014 + Amd 1"
473
+ expect(bib.docidentifier[0].content)
474
+ .to eq "ISO 19115-1:2014 + Amd 1"
397
475
  expect(bib.relation[0].type).to eq "updates"
398
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1:2014"
476
+ rel0 = bib.relation[0].bibitem
477
+ expect(rel0.docidentifier[0].content)
478
+ .to eq "ISO 19115-1:2014"
399
479
  expect(bib.relation[1].type).to eq "derivedFrom"
400
480
  expect(bib.relation[1].description).to be_nil
401
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1:2014/Amd 1:2018"
481
+ rel1 = bib.relation[1].bibitem
482
+ expect(rel1.docidentifier[0].content)
483
+ .to eq "ISO 19115-1:2014/Amd 1:2018"
402
484
  end
403
485
  end
404
486
 
405
487
  it "applied" do
406
488
  VCR.use_cassette "iso_combined_applied" do
407
489
  bib = @db.fetch "ISO 19115-1:2014, Amd 1"
408
- expect(bib.docidentifier[0].id).to eq "ISO 19115-1:2014, Amd 1"
490
+ expect(bib.docidentifier[0].content)
491
+ .to eq "ISO 19115-1:2014, Amd 1"
409
492
  expect(bib.relation[0].type).to eq "updates"
410
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1:2014"
493
+ rel0 = bib.relation[0].bibitem
494
+ expect(rel0.docidentifier[0].content)
495
+ .to eq "ISO 19115-1:2014"
411
496
  expect(bib.relation[1].type).to eq "complements"
412
- expect(bib.relation[1].description.content).to eq "amendment"
413
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1:2014/Amd 1:2018"
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"
414
502
  end
415
503
  end
416
504
  end
417
505
 
418
506
  context "IEC" do
419
507
  it "included" do
420
- item = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1", type: "IEC")]
421
- expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1", nil, {}).and_return item
422
- item1 = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1/AMD1:1997", type: "IEC")]
423
- expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1/Amd 1", nil, {}).and_return item1
424
- item2 = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1/AMD2:2005", type: "IEC")]
425
- expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1/Amd 2", nil, {}).and_return item2
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
426
535
  bib = @db.fetch "IEC 60027-1, Amd 1, Amd 2"
427
- expect(bib.docidentifier[0].id).to eq "IEC 60027-1, Amd 1, Amd 2"
536
+ expect(bib.docidentifier[0].content)
537
+ .to eq "IEC 60027-1, Amd 1, Amd 2"
428
538
  expect(bib.relation[0].type).to eq "updates"
429
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "IEC 60027-1"
539
+ rel0 = bib.relation[0].bibitem
540
+ expect(rel0.docidentifier[0].content)
541
+ .to eq "IEC 60027-1"
430
542
  expect(bib.relation[1].type).to eq "complements"
431
- expect(bib.relation[1].description.content).to eq "amendment"
432
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD1:1997"
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"
433
548
  expect(bib.relation[2].type).to eq "complements"
434
- expect(bib.relation[2].description.content).to eq "amendment"
435
- expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD2:2005"
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"
436
554
  end
437
555
  end
438
556
 
439
557
  context "ITU" do
440
558
  it "included" do
441
- docid = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2", type: "ITU")
442
- group = RelatonItu::ItuGroup.new(name: "Group")
443
- ed = RelatonItu::EditorialGroup.new(bureau: "Bureau", group: group)
444
- item = RelatonItu::ItuBibliographicItem.new docid: [docid], editorialgroup: ed
445
- expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2", nil, {}).and_return item
446
- docid1 = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2 Amd 1", type: "ITU")
447
- item1 = RelatonItu::ItuBibliographicItem.new docid: [docid1], editorialgroup: ed
448
- expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2 Amd 1", nil, {}).and_return item1
449
- docid2 = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2 Amd 2", type: "ITU")
450
- item2 = RelatonItu::ItuBibliographicItem.new docid: [docid2], editorialgroup: ed
451
- expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2 Amd 2", nil, {}).and_return item2
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
452
604
  bib = @db.fetch "ITU-T G.989.2, Amd 1, Amd 2"
453
- expect(bib.docidentifier[0].id).to eq "ITU-T G.989.2, Amd 1, Amd 2"
605
+ expect(bib.docidentifier[0].content)
606
+ .to eq "ITU-T G.989.2, Amd 1, Amd 2"
454
607
  expect(bib.relation[0].type).to eq "updates"
455
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2"
608
+ rel0 = bib.relation[0].bibitem
609
+ expect(rel0.docidentifier[0].content)
610
+ .to eq "ITU-T G.989.2"
456
611
  expect(bib.relation[1].type).to eq "complements"
457
- expect(bib.relation[1].description.content).to eq "amendment"
458
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2 Amd 1"
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"
459
617
  expect(bib.relation[2].type).to eq "complements"
460
- expect(bib.relation[2].description.content).to eq "amendment"
461
- expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2 Amd 2"
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"
462
623
  end
463
624
  end
464
625
 
465
626
  context "NIST" do
466
627
  it "included" do
467
628
  # VCR.use_cassette "nist_combined_included" do
468
- doci = RelatonBib::DocumentIdentifier.new(id: "SP 800-38A", type: "NIST")
469
- item = RelatonNist::NistBibliographicItem.new docid: [doci]
470
- expect(RelatonNist::NistBibliography).to receive(:get).with("NIST SP 800-38A", nil, {}).and_return item
471
- docid1 = RelatonBib::DocumentIdentifier.new(id: "SP 800-38A-Add", type: "NIST")
472
- item1 = RelatonNist::NistBibliographicItem.new docid: [docid1]
473
- expect(RelatonNist::NistBibliography).to receive(:get).with("NIST SP 800-38A/Add", nil, {}).and_return item1
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
474
642
  bib = @db.fetch "NIST SP 800-38A, Add"
475
- expect(bib.docidentifier[0].id).to eq "NIST SP 800-38A, Add"
643
+ expect(bib.docidentifier[0].content).to eq "NIST SP 800-38A, Add"
476
644
  expect(bib.relation[0].type).to eq "updates"
477
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "SP 800-38A"
645
+ rel0 = bib.relation[0].bibitem
646
+ expect(rel0.docidentifier[0].content)
647
+ .to eq "SP 800-38A"
478
648
  expect(bib.relation[1].type).to eq "complements"
479
- expect(bib.relation[1].description.content).to eq "amendment"
480
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "SP 800-38A-Add"
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"
481
654
  # end
482
655
  end
483
656
  end
484
657
  end
485
658
 
486
659
  context "version control" do
487
- before(:each) { @db.save_entry "iso(test_key)", "<bibitem><title>test_value</title></bibitem>" }
660
+ before(:each) do
661
+ @db.save_entry "iso(test_key)",
662
+ "<bibitem><title>test_value</title></bibitem>"
663
+ end
488
664
 
489
665
  it "shoudn't clear cache if version isn't changed" do
490
666
  testcache = @db.instance_variable_get :@db
@@ -494,11 +670,16 @@ RSpec.describe Relaton::Db do
494
670
  end
495
671
 
496
672
  it "should clear cache if version is changed" do
497
- expect(File.read("testcache/iso/version", encoding: "UTF-8")).not_to eq "new_version"
498
- expect(File.read("testcache2/iso/version", encoding: "UTF-8")).not_to eq "new_version"
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"
499
677
  processor = double "processor", short: :relaton_iso
500
- expect(processor).to receive(:grammar_hash).and_return("new_version").exactly(2).times
501
- expect(Relaton::Registry.instance).to receive(:by_type).and_return(processor).exactly(2).times
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
502
683
  Relaton::Db.new "testcache", "testcache2"
503
684
  expect(File.exist?("testcache/iso/version")).to eq false
504
685
  expect(File.exist?("testcache2/iso/version")).to eq false
@@ -522,19 +703,20 @@ RSpec.describe Relaton::Db do
522
703
  it "get document" do
523
704
  VCR.use_cassette "api_relaton_org" do
524
705
  bib = @db.fetch "ISO 19115-2", "2019"
525
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
706
+ expect(bib).to be_instance_of Relaton::Iso::ItemData
526
707
  end
527
708
  end
528
709
 
529
710
  it "if unavailable then get document directly" do
530
- expect(Net::HTTP).to receive(:get_response).and_wrap_original do |m, *args|
711
+ expect(Net::HTTP).to receive(:get_response)
712
+ .and_wrap_original do |m, *args|
531
713
  raise Errno::ECONNREFUSED if args[0].host == "api.relaton.org"
532
714
 
533
715
  m.call(*args)
534
716
  end.at_least :once
535
717
  VCR.use_cassette "api_relaton_org_unavailable" do
536
718
  bib = @db.fetch "ISO 19115-2", "2019"
537
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
719
+ expect(bib).to be_instance_of Relaton::Iso::ItemData
538
720
  end
539
721
  end
540
722
  end