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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +0 -1
  3. data/.rubocop.yml +1 -1
  4. data/CLAUDE.md +4 -2
  5. data/Rakefile +1 -1
  6. data/bin/rspec +1 -2
  7. data/docs/README.adoc +93 -86
  8. data/lib/relaton/config.rb +2 -3
  9. data/lib/relaton/db.rb +57 -39
  10. data/lib/relaton/db_cache.rb +3 -2
  11. data/lib/relaton/registry.rb +23 -30
  12. data/lib/relaton/util.rb +2 -1
  13. data/lib/relaton/version.rb +1 -1
  14. data/lib/relaton/workers_pool.rb +1 -1
  15. data/lib/relaton.rb +6 -7
  16. data/relaton.gemspec +31 -30
  17. data/spec/relaton/db_cache_spec.rb +1 -1
  18. data/spec/relaton/db_spec.rb +84 -46
  19. data/spec/relaton/registry_spec.rb +43 -41
  20. data/spec/relaton/util_spec.rb +1 -0
  21. data/spec/relaton_spec.rb +344 -176
  22. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +12593 -13227
  23. data/spec/vcr_cassetes/api_relaton_org.yml +7 -7
  24. data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +76 -78
  25. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +46 -42
  26. data/spec/vcr_cassetes/cie_001_1980.yml +288 -248
  27. data/spec/vcr_cassetes/cipm_meeting_43.yml +1378 -1370
  28. data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +3 -3
  29. data/spec/vcr_cassetes/ecma_6.yml +168 -166
  30. data/spec/vcr_cassetes/en_10160_1999.yml +11086 -11233
  31. data/spec/vcr_cassetes/gb_t_20223_2006.yml +456 -596
  32. data/spec/vcr_cassetes/ieee_528_2019.yml +2630 -2410
  33. data/spec/vcr_cassetes/iso_19115_1.yml +13688 -13955
  34. data/spec/vcr_cassetes/iso_19115_1_2.yml +236 -245
  35. data/spec/vcr_cassetes/iso_19115_1_std.yml +13688 -13955
  36. data/spec/vcr_cassetes/iso_19115_all_parts.yml +161 -168
  37. data/spec/vcr_cassetes/iso_19133_2005.yml +83 -79
  38. data/spec/vcr_cassetes/iso_combined_applied.yml +238 -237
  39. data/spec/vcr_cassetes/iso_combined_included.yml +240 -239
  40. data/spec/vcr_cassetes/iso_dis.yml +87 -88
  41. data/spec/vcr_cassetes/ogc_19_025r1.yml +246 -245
  42. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +255 -258
  43. data/spec/vcr_cassetes/rfc_8341.yml +1088 -1090
  44. metadata +62 -66
  45. data/lib/relaton/processor.rb +0 -46
  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 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,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].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
- require "relaton_iec"
74
- docid = RelatonBib::DocumentIdentifier.new(id: "IEC 60050-102:2007", type: "IEC")
75
- item = RelatonIec::IecBibliographicItem.new docid: [docid]
76
- 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
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].id).to eq "IEC 60050-102:2007"
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].id).to eq "IEC 60050-102:2007"
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
- docid = RelatonBib::DocumentIdentifier.new(id: "NIST FIPS 140", type: "NIST")
93
- item = RelatonNist::NistBibliographicItem.new docid: [docid]
94
- 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
95
105
  bib = @db.fetch "NIST FIPS 140"
96
- expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
97
- 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"
98
108
  end
99
109
 
100
110
  it "gets SP" do
101
- docid = RelatonBib::DocumentIdentifier.new(id: "NIST SP 800-38B", type: "NIST")
102
- item = RelatonNist::NistBibliographicItem.new docid: [docid]
103
- 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
104
118
  bib = @db.fetch "NIST SP 800-38B"
105
- expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
106
- 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"
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 RelatonGb::GbBibliographicItem
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 RelatonGb::GbBibliographicItem
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 RelatonIetf::IetfBibliographicItem
195
- 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
+ )
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
- expect(File).to receive(:exist?).with("/Users/andrej/.relaton/ogc/bibliography.json").and_return(false).at_most :once
219
- 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
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 RelatonOgc::OgcBibliographicItem
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 RelatonCalconnect::CcBibliographicItem
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 RelatonOmg::OmgBibliographicItem
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(id: "UN TRADE/CEFACT/2004/32", type: "UN")
242
- # item = RelatonUn::UnBibliographicItem.new docid: [docid], session: RelatonUn::Session.new(session_number: "1")
243
- # 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
244
271
  # bib = @db.fetch "UN TRADE/CEFACT/2004/32", nil, {}
245
- # expect(bib).to be_instance_of RelatonUn::UnBibliographicItem
246
- # 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"
247
277
  # end
248
278
 
249
279
  it "get W3C reference" do
250
- require "relaton_w3c"
251
- docid = RelatonBib::DocumentIdentifier.new(id: "W3C REC-json-ld11-20200716", type: "W3C")
252
- item = RelatonW3c::W3cBibliographicItem.new docid: [docid]
253
- 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
254
288
  bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
255
- expect(bib).to be_instance_of RelatonW3c::W3cBibliographicItem
256
- 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"
257
291
  end
258
292
 
259
293
  it "get CCSDS reference" do
260
- require "relaton_ccsds"
261
- docid = RelatonBib::DocumentIdentifier.new id: "CCSDS 230.2-G-1", type: "CCSDS"
262
- item = RelatonCcsds::BibliographicItem.new docid: [docid]
263
- 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
264
301
  bib = @db.fetch "CCSDS 230.2-G-1", nil, {}
265
- expect(bib).to be_instance_of RelatonCcsds::BibliographicItem
266
- 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"
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 RelatonIeee::IeeeBibliographicItem
308
+ expect(bib).to be_instance_of Relaton::Ieee::ItemData
272
309
  end
273
310
 
274
311
  it "get IHO reference" do
275
- require "relaton_iho"
276
- docid = RelatonBib::DocumentIdentifier.new(id: "IHO B-11", type: "IHO")
277
- item = RelatonIho::IhoBibliographicItem.new docid: [docid]
278
- 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
279
317
  bib = @db.fetch "IHO B-11"
280
- expect(bib).to be_instance_of RelatonIho::IhoBibliographicItem
281
- 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"
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 RelatonEcma::BibliographicItem
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 RelatonCie::BibliographicItem
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 "relaton_bsi"
300
- docid = RelatonBib::DocumentIdentifier.new(id: "BSI BS EN ISO 8848", type: "BSI")
301
- item = RelatonBsi::BsiBibliographicItem.new docid: [docid]
302
- 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
303
344
  bib = @db.fetch "BSI BS EN ISO 8848"
304
- expect(bib).to be_instance_of RelatonBsi::BsiBibliographicItem
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 RelatonCen::BibliographicItem
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 "relaton_iana"
316
- docid = RelatonBib::DocumentIdentifier.new(id: "IANA service-names-port-numbers", type: "IANA")
317
- item = RelatonIana::IanaBibliographicItem.new docid: [docid]
318
- 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
319
364
  bib = @db.fetch "IANA service-names-port-numbers"
320
- expect(bib).to be_instance_of RelatonIana::IanaBibliographicItem
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 Relaton3gpp::BibliographicItem
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 "relaton_oasis"
332
- docid = RelatonBib::DocumentIdentifier.new(id: "OASIS amqp-core-types-v1.0-Pt1", type: "OASIS")
333
- item = RelatonOasis::OasisBibliographicItem.new docid: [docid]
334
- 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
335
384
  bib = @db.fetch "OASIS amqp-core-types-v1.0-Pt1"
336
- expect(bib).to be_instance_of RelatonOasis::OasisBibliographicItem
385
+ expect(bib).to be_instance_of Relaton::Oasis::ItemData
337
386
  end
338
387
 
339
388
  it "get BIPM reference" do
340
- require "relaton_bipm"
341
- docid = RelatonBib::DocumentIdentifier.new(id: "BIPM Metrologia 29 6 373", type: "BIPM")
342
- item = RelatonBipm::BipmBibliographicItem.new docid: [docid]
343
- 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
344
397
  bib = @db.fetch "BIPM Metrologia 29 6 373"
345
- expect(bib).to be_instance_of RelatonBipm::BipmBibliographicItem
346
- 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"
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 RelatonBib::BibliographicItem
404
+ expect(bib).to be_instance_of Relaton::Bib::ItemData
352
405
  end
353
406
 
354
407
  it "get JIS reference" do
355
- require "relaton_jis"
356
- docid = RelatonBib::DocumentIdentifier.new(id: "JIS X 0001", type: "JIS")
357
- item = RelatonJis::BibliographicItem.new docid: [docid]
358
- 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
359
413
  bib = @db.fetch "JIS X 0001"
360
- expect(bib).to be_instance_of RelatonJis::BibliographicItem
361
- 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"
362
416
  end
363
417
 
364
418
  it "get XSF reference" do
365
- require "relaton_xsf"
366
- docid = RelatonBib::DocumentIdentifier.new(id: "XEP 0001", type: "XSF")
367
- item = RelatonXsf::BibliographicItem.new docid: [docid]
368
- 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
369
424
  bib = @db.fetch "XEP 0001"
370
- expect(bib).to be_instance_of RelatonXsf::BibliographicItem
371
- 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"
372
427
  end
373
428
 
374
429
  it "get ETSI reference" do
375
- require "relaton_etsi"
376
- docid = RelatonBib::DocumentIdentifier.new(id: "ETSI EN 300 175-8", type: "ETSI")
377
- item = RelatonEtsi::BibliographicItem.new docid: [docid]
378
- 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
379
437
  bib = @db.fetch "ETSI EN 300 175-8"
380
- expect(bib).to be_instance_of RelatonEtsi::BibliographicItem
381
- 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"
382
440
  end
383
441
 
384
442
  it "get ISBN reference" do
385
- require "relaton_isbn"
386
- docid = RelatonBib::DocumentIdentifier.new(id: "ISBN 978-0-580-50101-4", type: "ISBN")
387
- item = RelatonBib::BibliographicItem.new docid: [docid]
388
- 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
389
450
  bib = @db.fetch "ISBN 978-0-580-50101-4"
390
- expect(bib).to be_instance_of RelatonBib::BibliographicItem
391
- 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"
392
453
  end
393
454
 
394
455
  it "get PLATEAU reference" do
395
456
  require "relaton/plateau"
396
- docid = RelatonBib::DocumentIdentifier.new(id: "PLATEAU Hanbook #01", type: "PLATEAU")
397
- item = Relaton::Plateau::BibItem.new docid: [docid]
398
- expect(Relaton::Plateau::Bibliography).to receive(:get).with("PLATEAU Hanbook #01", nil, {}).and_return item
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::BibItem
401
- 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"
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].id).to eq "ISO 19115-1:2014 + Amd 1"
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
- 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"
412
479
  expect(bib.relation[1].type).to eq "derivedFrom"
413
480
  expect(bib.relation[1].description).to be_nil
414
- 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"
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].id).to eq "ISO 19115-1:2014, Amd 1"
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
- 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"
424
496
  expect(bib.relation[1].type).to eq "complements"
425
- expect(bib.relation[1].description.content).to eq "amendment"
426
- 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"
427
502
  end
428
503
  end
429
504
  end
430
505
 
431
506
  context "IEC" do
432
507
  it "included" do
433
- item = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1", type: "IEC")]
434
- expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1", nil, {}).and_return item
435
- item1 = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1/AMD1:1997", type: "IEC")]
436
- expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1/Amd 1", nil, {}).and_return item1
437
- item2 = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1/AMD2:2005", type: "IEC")]
438
- 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
439
535
  bib = @db.fetch "IEC 60027-1, Amd 1, Amd 2"
440
- 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"
441
538
  expect(bib.relation[0].type).to eq "updates"
442
- 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"
443
542
  expect(bib.relation[1].type).to eq "complements"
444
- expect(bib.relation[1].description.content).to eq "amendment"
445
- 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"
446
548
  expect(bib.relation[2].type).to eq "complements"
447
- expect(bib.relation[2].description.content).to eq "amendment"
448
- 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"
449
554
  end
450
555
  end
451
556
 
452
557
  context "ITU" do
453
558
  it "included" do
454
- require "relaton_itu"
455
- docid = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2", type: "ITU")
456
- group = RelatonItu::ItuGroup.new(name: "Group")
457
- ed = RelatonItu::EditorialGroup.new(bureau: "Bureau", group: group)
458
- item = RelatonItu::ItuBibliographicItem.new docid: [docid], editorialgroup: ed
459
- expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2", nil, {}).and_return item
460
- docid1 = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2 Amd 1", type: "ITU")
461
- item1 = RelatonItu::ItuBibliographicItem.new docid: [docid1], editorialgroup: ed
462
- expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2 Amd 1", nil, {}).and_return item1
463
- docid2 = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2 Amd 2", type: "ITU")
464
- item2 = RelatonItu::ItuBibliographicItem.new docid: [docid2], editorialgroup: ed
465
- 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
466
604
  bib = @db.fetch "ITU-T G.989.2, Amd 1, Amd 2"
467
- 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"
468
607
  expect(bib.relation[0].type).to eq "updates"
469
- 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"
470
611
  expect(bib.relation[1].type).to eq "complements"
471
- expect(bib.relation[1].description.content).to eq "amendment"
472
- 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"
473
617
  expect(bib.relation[2].type).to eq "complements"
474
- expect(bib.relation[2].description.content).to eq "amendment"
475
- 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"
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
- doci = RelatonBib::DocumentIdentifier.new(id: "SP 800-38A", type: "NIST")
483
- item = RelatonNist::NistBibliographicItem.new docid: [doci]
484
- expect(RelatonNist::NistBibliography).to receive(:get).with("NIST SP 800-38A", nil, {}).and_return item
485
- docid1 = RelatonBib::DocumentIdentifier.new(id: "SP 800-38A-Add", type: "NIST")
486
- item1 = RelatonNist::NistBibliographicItem.new docid: [docid1]
487
- 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
488
642
  bib = @db.fetch "NIST SP 800-38A, Add"
489
- 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"
490
644
  expect(bib.relation[0].type).to eq "updates"
491
- 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"
492
648
  expect(bib.relation[1].type).to eq "complements"
493
- expect(bib.relation[1].description.content).to eq "amendment"
494
- 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"
495
654
  # end
496
655
  end
497
656
  end
498
657
  end
499
658
 
500
659
  context "version control" do
501
- 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
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", encoding: "UTF-8")).not_to eq "new_version"
512
- 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"
513
677
  processor = double "processor", short: :relaton_iso
514
- expect(processor).to receive(:grammar_hash).and_return("new_version").exactly(2).times
515
- 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
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 RelatonIsoBib::IsoBibliographicItem
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).and_wrap_original do |m, *args|
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 RelatonIsoBib::IsoBibliographicItem
719
+ expect(bib).to be_instance_of Relaton::Iso::ItemData
552
720
  end
553
721
  end
554
722
  end