relaton 1.15.0 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -0
  3. data/.github/workflows/release.yml +3 -2
  4. data/docs/README.adoc +1 -3
  5. data/lib/relaton/db.rb +4 -1
  6. data/lib/relaton/registry.rb +1 -1
  7. data/lib/relaton/version.rb +1 -1
  8. data/relaton.gemspec +2 -1
  9. data/spec/relaton/db_spec.rb +19 -24
  10. data/spec/relaton/registry_spec.rb +4 -0
  11. data/spec/relaton_spec.rb +121 -98
  12. data/spec/spec_helper.rb +2 -1
  13. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +46 -89
  14. data/spec/vcr_cassetes/api_relaton_org.yml +76 -11
  15. data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +2190 -25
  16. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +4007 -59
  17. data/spec/vcr_cassetes/cie_001_1980.yml +57 -70
  18. data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +60 -22
  19. data/spec/vcr_cassetes/ecma_6.yml +294 -151
  20. data/spec/vcr_cassetes/en_10160_1999.yml +12344 -36
  21. data/spec/vcr_cassetes/ieee_528_2019.yml +61 -13
  22. data/spec/vcr_cassetes/iso_111111119115_1.yml +30 -12
  23. data/spec/vcr_cassetes/iso_19115_1.yml +2461 -25
  24. data/spec/vcr_cassetes/iso_19115_1_2.yml +4649 -49
  25. data/spec/vcr_cassetes/iso_19115_all_parts.yml +2693 -25
  26. data/spec/vcr_cassetes/iso_19133_2005.yml +2323 -26
  27. data/spec/vcr_cassetes/iso_combined_applied.yml +4342 -50
  28. data/spec/vcr_cassetes/iso_combined_included.yml +4339 -48
  29. data/spec/vcr_cassetes/iso_dis.yml +1892 -25
  30. data/spec/vcr_cassetes/ogc_19_025r1.yml +51 -12
  31. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +1094 -9
  32. data/spec/vcr_cassetes/rfc_8341.yml +69 -136
  33. metadata +22 -24
  34. data/spec/vcr_cassetes/async_fetch.yml +0 -4412
  35. data/spec/vcr_cassetes/bipm_i18n_async_fetch.yml +0 -618
  36. data/spec/vcr_cassetes/bipm_metrologia_29_6_373.yml +0 -294
  37. data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +0 -163
  38. data/spec/vcr_cassetes/fisp_140.yml +0 -48
  39. data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -38
  40. data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +0 -105
  41. data/spec/vcr_cassetes/iec_60050_102_2007.yml +0 -290
  42. data/spec/vcr_cassetes/iec_combined_included.yml +0 -960
  43. data/spec/vcr_cassetes/iho_b_11.yml +0 -74
  44. data/spec/vcr_cassetes/itu_combined_included.yml +0 -1348
  45. data/spec/vcr_cassetes/oasis_amqp_core_types_v1_0_pt1.yml +0 -84
  46. data/spec/vcr_cassetes/sp_800_38b.yml +0 -48
  47. data/spec/vcr_cassetes/threads_from_env.yml +0 -412
  48. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +0 -814
  49. data/spec/vcr_cassetes/w3c_json_ld11.yml +0 -233
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5881725c3b42ac5fa5a25c1bf29f85f864561ea7328bfb2d1b842cd9f5ad9944
4
- data.tar.gz: a712d45a2e065e75c98e0cb35b282325cb0d76eab0f3d8f9ecf39c468c4a4ba0
3
+ metadata.gz: b6254d1d82a460fa2a410054f3c8dc2e924d00f71ec555691109407c8cf0921a
4
+ data.tar.gz: c75c01f97ba34e83b71dc17dd3ed15f80dd619fe31c98f3dd592e3f7616ecf28
5
5
  SHA512:
6
- metadata.gz: 3b05040fb095e90626e9653c519973e0f7888d98b8ce9a83bc4388db63c6dda903ee691d5a45aba00512395bcbbc8fae05e1077d9fc79efa2376e2181ea9a0a1
7
- data.tar.gz: 12845e1d6eff0692893a65c64060011f7f99dd53dfc7ba3e313130c8af023e4324431a49cf182c498bc96044828c0555f005647ec7a6b3d548a15da2a0e7fafa
6
+ metadata.gz: a86a05f6af47607c6287f090522a3cf865d669076fb199e9a061db0604036c1ad34b46e6625fe0eafb9d76547f030e27ce6e10eae41bebd58ee4c0ae871b0038
7
+ data.tar.gz: dc68c7c8db23fe91c6968ed3443dba32f683c5f8856bd12d84e1a1b278651a680fe0c1ef6a44986891f9e24ca0864443e426f578bb26f1333f646fe8326bdb13
@@ -5,6 +5,7 @@ name: rake
5
5
  on:
6
6
  push:
7
7
  branches: [ master, main ]
8
+ tags: [ v* ]
8
9
  pull_request:
9
10
 
10
11
  jobs:
@@ -10,8 +10,9 @@ on:
10
10
  Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
11
  required: true
12
12
  default: 'skip'
13
- push:
14
- tags: [ v* ]
13
+ repository_dispatch:
14
+ types: [ do-release ]
15
+
15
16
 
16
17
  jobs:
17
18
  release:
data/docs/README.adoc CHANGED
@@ -1,9 +1,7 @@
1
1
  = Relaton
2
2
 
3
3
  image:https://img.shields.io/gem/v/relaton.svg["Gem Version", link="https://rubygems.org/gems/relaton"]
4
- image:https://github.com/relaton/relaton/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton/actions?workflow=macos"]
5
- image:https://github.com/relaton/relaton/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton/actions?workflow=windows"]
6
- image:https://github.com/relaton/relaton/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton/actions?workflow=ubuntu"]
4
+ image:https://github.com/relaton/relaton/workflows/rake/badge.svg["Build Status", link="https://github.com/relaton/relaton/actions?workflow=rake"]
7
5
  image:https://codeclimate.com/github/relaton/relaton/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/relaton/relaton.svg["Pull Requests", link="https://github.com/relaton/relaton/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/relaton/relaton/latest.svg["Commits since latest",link="https://github.com/relaton/relaton/releases"]
data/lib/relaton/db.rb CHANGED
@@ -27,6 +27,9 @@ module Relaton
27
27
  def clear
28
28
  @db&.clear
29
29
  @local_db&.clear
30
+ @registry.processors.each_value do |p|
31
+ p.remove_index_file if p.respond_to? :remove_index_file
32
+ end
30
33
  end
31
34
 
32
35
  ##
@@ -110,7 +113,7 @@ module Relaton
110
113
  Util.log "[relaton] ERROR: #{args[0]} -- #{e.message}", :error
111
114
  args[3].call nil
112
115
  end
113
- @queues[stdclass] = { queue: Queue.new, workers_pool: wp }
116
+ @queues[stdclass] = { queue: SizedQueue.new(threads * 2), workers_pool: wp }
114
117
  Thread.new { process_queue @queues[stdclass] }
115
118
  end
116
119
  @queues[stdclass][:queue] << [ref, year, opts, block]
@@ -9,7 +9,7 @@ module Relaton
9
9
  relaton_gb relaton_iec relaton_ietf relaton_iso relaton_itu relaton_nist
10
10
  relaton_ogc relaton_calconnect relaton_omg relaton_un relaton_w3c
11
11
  relaton_ieee relaton_iho relaton_bipm relaton_ecma relaton_cie relaton_bsi
12
- relaton_cen relaton_iana relaton_3gpp relaton_oasis relaton_doi
12
+ relaton_cen relaton_iana relaton_3gpp relaton_oasis relaton_doi relaton_jis
13
13
  ].freeze
14
14
 
15
15
  include Singleton
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.15.0".freeze
2
+ VERSION = "1.15.2".freeze
3
3
  end
data/relaton.gemspec CHANGED
@@ -43,8 +43,9 @@ Gem::Specification.new do |spec|
43
43
  spec.add_dependency "relaton-ieee", "~> 1.14.0"
44
44
  spec.add_dependency "relaton-ietf", "~> 1.14.0"
45
45
  spec.add_dependency "relaton-iho", "~> 1.14.0"
46
- spec.add_dependency "relaton-iso", "~> 1.15.0"
46
+ spec.add_dependency "relaton-iso", "~> 1.15.3"
47
47
  spec.add_dependency "relaton-itu", "~> 1.14.0"
48
+ spec.add_dependency "relaton-jis", "~> 1.14.0"
48
49
  spec.add_dependency "relaton-nist", "~> 1.14.0"
49
50
  spec.add_dependency "relaton-oasis", "~> 1.14.0"
50
51
  spec.add_dependency "relaton-ogc", "~> 1.14.0"
@@ -8,6 +8,7 @@ RSpec.describe Relaton::Db do
8
8
  it "create bibitem from YAML content" do
9
9
  h = { "docid" => [{ "id" => "ISO 123", type: "ISO", "primary" => true }] }
10
10
  expect(YAML).to receive(:safe_load).with(:content).and_return h
11
+ allow(YAML).to receive(:safe_load).and_call_original
11
12
  item = subject.send :search_edition_year, "iso/item.yaml", :content, nil, nil
12
13
  expect(item).to be_instance_of RelatonIsoBib::IsoBibliographicItem
13
14
  end
@@ -165,10 +166,11 @@ RSpec.describe Relaton::Db do
165
166
 
166
167
  it "doesn't use cache" do
167
168
  db = Relaton::Db.new nil, nil
168
- VCR.use_cassette "iso_19115_1" do
169
- bib = db.fetch("ISO 19115-1", nil, {})
170
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
171
- end
169
+ docid = RelatonBib::DocumentIdentifier.new id: "ISO 19115-1", type: "ISO"
170
+ item = RelatonIsoBib::IsoBibliographicItem.new docid: [docid]
171
+ expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 19115-1", nil, {}).and_return item
172
+ bib = db.fetch("ISO 19115-1", nil, {})
173
+ expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
172
174
  end
173
175
 
174
176
  it "fetch when no local db" do
@@ -203,33 +205,27 @@ RSpec.describe Relaton::Db do
203
205
  "ITU-T Y.1911", "ITU-T Y.2012", "ITU-T Y.2206", "ITU-T O.172",
204
206
  "ITU-T G.780/Y.1351", "ITU-T G.711", "ITU-T G.1011"]
205
207
  results = []
206
- VCR.use_cassette "async_fetch", match_requests_on: %i[method uri body] do
207
- refs.each do |ref|
208
- db.fetch_async(ref) { |r| queue << [r, ref] }
209
- end
210
- Timeout.timeout(60) { refs.size.times { results << queue.pop } }
208
+ refs.each do |ref|
209
+ expect(db).to receive(:fetch).with(ref, nil, {}).and_return :result
210
+ db.fetch_async(ref) { |r| queue << [r, ref] }
211
211
  end
212
+ Timeout.timeout(60) { refs.size.times { results << queue.pop } }
212
213
  results.each do |result|
213
- expect(result[0]).to be_instance_of RelatonItu::ItuBibliographicItem
214
+ expect(result[0]).to be :result
214
215
  end
215
216
  end
216
217
 
217
218
  it "BIPM i18n" do
218
- expect(File).to receive(:exist?).with(/index\.yaml/).and_return false
219
- allow(File).to receive(:exist?).and_call_original
220
- # refs = ["CGPM Resolution 1889-00", "CGPM Résolution 1889-00",
221
- # "CGPM Réunion 9", "CGPM Meeting 9"]
222
219
  refs = ["CGPM -- Resolution (1889)", "CGPM -- Résolution (1889)",
223
220
  "CGPM -- Réunion 9 (1948)", "CGPM -- Meeting 9 (1948)"]
224
221
  results = []
225
- VCR.use_cassette "bipm_i18n_async_fetch", match_requests_on: %i[method uri body] do
226
- refs.each do |ref|
227
- db.fetch_async(ref) { |r| queue << [r, ref] }
228
- end
229
- Timeout.timeout(60) { refs.size.times { results << queue.pop } }
222
+ refs.each do |ref|
223
+ expect(db).to receive(:fetch).with(ref, nil, {}).and_return :result
224
+ db.fetch_async(ref) { |r| queue << [r, ref] }
230
225
  end
226
+ Timeout.timeout(60) { refs.size.times { results << queue.pop } }
231
227
  results.each do |result|
232
- expect(result[0]).to be_instance_of RelatonBipm::BipmBibliographicItem
228
+ expect(result[0]).to be :result
233
229
  end
234
230
  end
235
231
 
@@ -262,10 +258,9 @@ RSpec.describe Relaton::Db do
262
258
  expect(ENV).to receive(:[]).with("RELATON_FETCH_PARALLEL").and_return(1)
263
259
  allow(ENV).to receive(:[]).and_call_original
264
260
  expect(Relaton::WorkersPool).to receive(:new).with(1).and_call_original
265
- VCR.use_cassette "threads_from_env" do
266
- db.fetch_async("ITU-T G.993.5") { |r| queue << r }
267
- Timeout.timeout(50) { queue.pop }
268
- end
261
+ expect(db).to receive(:fetch).with("ITU-T G.993.5", nil, {})
262
+ db.fetch_async("ITU-T G.993.5") { |r| queue << r }
263
+ Timeout.timeout(50) { queue.pop }
269
264
  end
270
265
  end
271
266
  end
@@ -105,6 +105,10 @@ RSpec.describe Relaton::Registry do
105
105
  expect(Relaton::Registry.instance.by_type("DOI")).to be_instance_of RelatonDoi::Processor
106
106
  expect(Relaton::Registry.instance.processor_by_ref("doi:10.1000/182")).to be_instance_of RelatonDoi::Processor
107
107
  end
108
+
109
+ it "JIS" do
110
+ expect(Relaton::Registry.instance.by_type("JIS")).to be_instance_of RelatonJis::Processor
111
+ end
108
112
  end
109
113
 
110
114
  it "find processot by dataset" do
data/spec/relaton_spec.rb CHANGED
@@ -12,20 +12,11 @@ RSpec.describe Relaton::Db do
12
12
 
13
13
  context "gets an ISO reference" do
14
14
  it "and caches it" do
15
- VCR.use_cassette "iso_19115_1" do
16
- bib = @db.fetch("ISO 19115-1", nil, {})
17
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
18
- expect(bib.to_xml(bibdata: true)).to include "<project-number part=\"1\">" \
19
- "ISO 19115</project-number>"
20
- expect(File.exist?("testcache")).to be true
21
- expect(File.exist?("testcache2")).to be true
22
- testcache = Relaton::DbCache.new "testcache"
23
- expect(testcache["ISO(ISO 19115-1)"]).to include "<project-number part=\"1\">" \
24
- "ISO 19115</project-number>"
25
- testcache = Relaton::DbCache.new "testcache2"
26
- expect(testcache["ISO(ISO 19115-1)"]).to include "<project-number part=\"1\">" \
27
- "ISO 19115</project-number>"
28
- end
15
+ docid = RelatonBib::DocumentIdentifier.new(id: "ISO 19115-1", type: "ISO")
16
+ item = RelatonIsoBib::IsoBibliographicItem.new docid: [docid], fetched: Date.today.to_s
17
+ expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 19115-1", nil, {}).and_return item
18
+ bib = @db.fetch("ISO 19115-1", nil, {})
19
+ expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
29
20
  bib = @db.fetch("ISO 19115-1", nil, {})
30
21
  expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
31
22
  end
@@ -34,8 +25,9 @@ RSpec.describe Relaton::Db do
34
25
  VCR.use_cassette "iso_19133_2005" do
35
26
  bib = @db.fetch("ISO 19133:2005")
36
27
  expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
37
- expect(bib.to_xml).to include '<bibitem id="ISO19133-2005" ' \
38
- 'type="standard" schema-version="v1.2.1">'
28
+ xml = bib.to_xml
29
+ expect(xml).to include 'id="ISO19133-2005"'
30
+ expect(xml).to include 'type="standard"'
39
31
  testcache = Relaton::DbCache.new "testcache"
40
32
  expect(
41
33
  testcache.valid_entry?("ISO(ISO 19133:2005)", Date.today.year.to_s),
@@ -68,41 +60,40 @@ RSpec.describe Relaton::Db do
68
60
  end
69
61
 
70
62
  context "IEC" do
63
+ before do
64
+ docid = RelatonBib::DocumentIdentifier.new(id: "IEC 60050-102:2007", type: "IEC")
65
+ item = RelatonIec::IecBibliographicItem.new docid: [docid]
66
+ expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60050-102:2007", nil, {}).and_return item
67
+ end
68
+
71
69
  it "get by reference" do
72
- VCR.use_cassette "iec_60050_102_2007" do
73
- bib = @db.fetch "IEC 60050-102:2007"
74
- expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
75
- end
70
+ bib = @db.fetch "IEC 60050-102:2007"
71
+ expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
76
72
  end
77
73
 
78
74
  it "get by URN" do
79
- VCR.use_cassette "iec_60050_102_2007" do
80
- bib = @db.fetch "urn:iec:std:iec:60050-102:2007:::"
81
- expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
82
- end
75
+ bib = @db.fetch "urn:iec:std:iec:60050-102:2007:::"
76
+ expect(bib.docidentifier[0].id).to eq "IEC 60050-102:2007"
83
77
  end
84
78
  end
85
79
 
86
80
  context "NIST references" do
87
- before(:each) do
88
- nist_fr = /\.relaton\/nist\/pubs-export\.zip/
89
- expect(File).to receive(:exist?).with(nist_fr).and_return false
90
- expect(File).to receive(:exist?).and_call_original.at_least :once
91
- # expect(FileUtils).to receive(:mv).with kind_of(String), nist_fr
92
- end
93
-
94
81
  it "gets FISP" do
95
- VCR.use_cassette "fisp_140" do
96
- bib = @db.fetch "NIST FIPS 140"
97
- expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
98
- end
82
+ docid = RelatonBib::DocumentIdentifier.new(id: "NIST FIPS 140", type: "NIST")
83
+ item = RelatonNist::NistBibliographicItem.new docid: [docid]
84
+ expect(RelatonNist::NistBibliography).to receive(:get).with("NIST FIPS 140", nil, {}).and_return item
85
+ bib = @db.fetch "NIST FIPS 140"
86
+ expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
87
+ expect(bib.docidentifier[0].id).to eq "NIST FIPS 140"
99
88
  end
100
89
 
101
90
  it "gets SP" do
102
- VCR.use_cassette "sp_800_38b" do
103
- bib = @db.fetch "NIST SP 800-38B"
104
- expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
105
- end
91
+ docid = RelatonBib::DocumentIdentifier.new(id: "NIST SP 800-38B", type: "NIST")
92
+ item = RelatonNist::NistBibliographicItem.new docid: [docid]
93
+ expect(RelatonNist::NistBibliography).to receive(:get).with("NIST SP 800-38B", nil, {}).and_return item
94
+ bib = @db.fetch "NIST SP 800-38B"
95
+ expect(bib).to be_instance_of RelatonNist::NistBibliographicItem
96
+ expect(bib.docidentifier[0].id).to eq "NIST SP 800-38B"
106
97
  end
107
98
  end
108
99
 
@@ -191,7 +182,7 @@ RSpec.describe Relaton::Db do
191
182
  VCR.use_cassette "rfc_8341" do
192
183
  bib = @db.fetch "RFC 8341", nil, {}
193
184
  expect(bib).to be_instance_of RelatonIetf::IetfBibliographicItem
194
- expect(bib.to_xml).to include "<bibitem id=\"RFC8341\" type=\"standard\" schema-version=\"v1.2.1\">"
185
+ expect(bib.to_xml).to match(/<bibitem id="RFC8341" type="standard" schema-version="v[\d.]+">/)
195
186
  expect(File.exist?("testcache")).to be true
196
187
  expect(File.exist?("testcache2")).to be true
197
188
  testcache = Relaton::DbCache.new "testcache"
@@ -244,17 +235,21 @@ RSpec.describe Relaton::Db do
244
235
  end
245
236
 
246
237
  it "get UN reference" do
247
- VCR.use_cassette "un_rtade_cefact_2004_32" do
248
- bib = @db.fetch "UN TRADE/CEFACT/2004/32", nil, {}
249
- expect(bib).to be_instance_of RelatonUn::UnBibliographicItem
250
- end
238
+ docid = RelatonBib::DocumentIdentifier.new(id: "UN TRADE/CEFACT/2004/32", type: "UN")
239
+ item = RelatonUn::UnBibliographicItem.new docid: [docid], session: RelatonUn::Session.new(session_number: "1")
240
+ expect(RelatonUn::UnBibliography).to receive(:get).with("UN TRADE/CEFACT/2004/32", nil, {}).and_return item
241
+ bib = @db.fetch "UN TRADE/CEFACT/2004/32", nil, {}
242
+ expect(bib).to be_instance_of RelatonUn::UnBibliographicItem
243
+ expect(bib.docidentifier.first.id).to eq "UN TRADE/CEFACT/2004/32"
251
244
  end
252
245
 
253
246
  it "get W3C reference" do
254
- VCR.use_cassette "w3c_json_ld11" do
255
- bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
256
- expect(bib).to be_instance_of RelatonW3c::W3cBibliographicItem
257
- end
247
+ docid = RelatonBib::DocumentIdentifier.new(id: "W3C REC-json-ld11-20200716", type: "W3C")
248
+ item = RelatonW3c::W3cBibliographicItem.new docid: [docid]
249
+ expect(RelatonW3c::W3cBibliography).to receive(:get).with("W3C REC-json-ld11-20200716", nil, {}).and_return item
250
+ bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
251
+ expect(bib).to be_instance_of RelatonW3c::W3cBibliographicItem
252
+ expect(bib.docidentifier.first.id).to eq "W3C REC-json-ld11-20200716"
258
253
  end
259
254
 
260
255
  it "get IEEE reference" do
@@ -265,10 +260,12 @@ RSpec.describe Relaton::Db do
265
260
  end
266
261
 
267
262
  it "get IHO reference" do
268
- VCR.use_cassette "iho_b_11" do
269
- bib = @db.fetch "IHO B-11"
270
- expect(bib).to be_instance_of RelatonIho::IhoBibliographicItem
271
- end
263
+ docid = RelatonBib::DocumentIdentifier.new(id: "IHO B-11", type: "IHO")
264
+ item = RelatonIho::IhoBibliographicItem.new docid: [docid]
265
+ expect(RelatonIho::IhoBibliography).to receive(:get).with("IHO B-11", nil, {}).and_return item
266
+ bib = @db.fetch "IHO B-11"
267
+ expect(bib).to be_instance_of RelatonIho::IhoBibliographicItem
268
+ expect(bib.docidentifier.first.id).to eq "IHO B-11"
272
269
  end
273
270
 
274
271
  it "get ECMA reference" do
@@ -286,10 +283,11 @@ RSpec.describe Relaton::Db do
286
283
  end
287
284
 
288
285
  it "get BSI reference" do
289
- VCR.use_cassette "bsi_bs_en_iso_8848" do
290
- bib = @db.fetch "BSI BS EN ISO 8848"
291
- expect(bib).to be_instance_of RelatonBsi::BsiBibliographicItem
292
- end
286
+ docid = RelatonBib::DocumentIdentifier.new(id: "BSI BS EN ISO 8848", type: "BSI")
287
+ item = RelatonBsi::BsiBibliographicItem.new docid: [docid]
288
+ expect(RelatonBsi::BsiBibliography).to receive(:get).with("BSI BS EN ISO 8848", nil, {}).and_return item
289
+ bib = @db.fetch "BSI BS EN ISO 8848"
290
+ expect(bib).to be_instance_of RelatonBsi::BsiBibliographicItem
293
291
  end
294
292
 
295
293
  it "get CEN reference" do
@@ -300,10 +298,11 @@ RSpec.describe Relaton::Db do
300
298
  end
301
299
 
302
300
  it "get IANA reference" do
303
- VCR.use_cassette "iana_service_names_port_numbers" do
304
- bib = @db.fetch "IANA service-names-port-numbers"
305
- expect(bib).to be_instance_of RelatonIana::IanaBibliographicItem
306
- end
301
+ docid = RelatonBib::DocumentIdentifier.new(id: "IANA service-names-port-numbers", type: "IANA")
302
+ item = RelatonIana::IanaBibliographicItem.new docid: [docid]
303
+ expect(RelatonIana::IanaBibliography).to receive(:get).with("IANA service-names-port-numbers", nil, {}).and_return item
304
+ bib = @db.fetch "IANA service-names-port-numbers"
305
+ expect(bib).to be_instance_of RelatonIana::IanaBibliographicItem
307
306
  end
308
307
 
309
308
  it "get 3GPP reference" do
@@ -314,15 +313,20 @@ RSpec.describe Relaton::Db do
314
313
  end
315
314
 
316
315
  it "get OASIS reference" do
317
- VCR.use_cassette "oasis_amqp_core_types_v1_0_pt1" do
318
- bib = @db.fetch "OASIS amqp-core-types-v1.0-Pt1"
319
- expect(bib).to be_instance_of RelatonOasis::OasisBibliographicItem
320
- end
316
+ docid = RelatonBib::DocumentIdentifier.new(id: "OASIS amqp-core-types-v1.0-Pt1", type: "OASIS")
317
+ item = RelatonOasis::OasisBibliographicItem.new docid: [docid]
318
+ expect(RelatonOasis::OasisBibliography).to receive(:get).with("OASIS amqp-core-types-v1.0-Pt1", nil, {}).and_return item
319
+ bib = @db.fetch "OASIS amqp-core-types-v1.0-Pt1"
320
+ expect(bib).to be_instance_of RelatonOasis::OasisBibliographicItem
321
321
  end
322
322
 
323
- it "get BIPM reference", vcr: "bipm_metrologia_29_6_373" do
323
+ it "get BIPM reference" do
324
+ docid = RelatonBib::DocumentIdentifier.new(id: "BIPM Metrologia 29 6 373", type: "BIPM")
325
+ item = RelatonBipm::BipmBibliographicItem.new docid: [docid]
326
+ expect(RelatonBipm::BipmBibliography).to receive(:get).with("BIPM Metrologia 29 6 373", nil, {}).and_return item
324
327
  bib = @db.fetch "BIPM Metrologia 29 6 373"
325
328
  expect(bib).to be_instance_of RelatonBipm::BipmBibliographicItem
329
+ expect(bib.docidentifier.first.id).to eq "BIPM Metrologia 29 6 373"
326
330
  end
327
331
 
328
332
  it "get DOI reference", vcr: "doi_10_6028_nist_ir_8245" do
@@ -359,49 +363,68 @@ RSpec.describe Relaton::Db do
359
363
 
360
364
  context "IEC" do
361
365
  it "included" do
362
- VCR.use_cassette "iec_combined_included" do
363
- bib = @db.fetch "IEC 60027-1, Amd 1, Amd 2"
364
- expect(bib.docidentifier[0].id).to eq "IEC 60027-1, Amd 1, Amd 2"
365
- expect(bib.relation[0].type).to eq "updates"
366
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "IEC 60027-1"
367
- expect(bib.relation[1].type).to eq "complements"
368
- expect(bib.relation[1].description.content).to eq "amendment"
369
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD1:1997"
370
- expect(bib.relation[2].type).to eq "complements"
371
- expect(bib.relation[2].description.content).to eq "amendment"
372
- expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD2:2005"
373
- end
366
+ item = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1", type: "IEC")]
367
+ expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1", nil, {}).and_return item
368
+ item1 = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1/AMD1:1997", type: "IEC")]
369
+ expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1/Amd 1", nil, {}).and_return item1
370
+ item2 = RelatonIec::IecBibliographicItem.new docid: [RelatonBib::DocumentIdentifier.new(id: "IEC 60027-1/AMD2:2005", type: "IEC")]
371
+ expect(RelatonIec::IecBibliography).to receive(:get).with("IEC 60027-1/Amd 2", nil, {}).and_return item2
372
+ bib = @db.fetch "IEC 60027-1, Amd 1, Amd 2"
373
+ expect(bib.docidentifier[0].id).to eq "IEC 60027-1, Amd 1, Amd 2"
374
+ expect(bib.relation[0].type).to eq "updates"
375
+ expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "IEC 60027-1"
376
+ expect(bib.relation[1].type).to eq "complements"
377
+ expect(bib.relation[1].description.content).to eq "amendment"
378
+ expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD1:1997"
379
+ expect(bib.relation[2].type).to eq "complements"
380
+ expect(bib.relation[2].description.content).to eq "amendment"
381
+ expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "IEC 60027-1/AMD2:2005"
374
382
  end
375
383
  end
376
384
 
377
385
  context "ITU" do
378
386
  it "included" do
379
- VCR.use_cassette "itu_combined_included" do
380
- bib = @db.fetch "ITU-T G.989.2, Amd 1, Amd 2"
381
- expect(bib.docidentifier[0].id).to eq "ITU-T G.989.2, Amd 1, Amd 2"
382
- expect(bib.relation[0].type).to eq "updates"
383
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2"
384
- expect(bib.relation[1].type).to eq "complements"
385
- expect(bib.relation[1].description.content).to eq "amendment"
386
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2 Amd 1"
387
- expect(bib.relation[2].type).to eq "complements"
388
- expect(bib.relation[2].description.content).to eq "amendment"
389
- expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2 Amd 2"
390
- end
387
+ docid = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2", type: "ITU")
388
+ group = RelatonItu::ItuGroup.new(name: "Group")
389
+ ed = RelatonItu::EditorialGroup.new(bureau: "Bureau", group: group)
390
+ item = RelatonItu::ItuBibliographicItem.new docid: [docid], editorialgroup: ed
391
+ expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2", nil, {}).and_return item
392
+ docid1 = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2 Amd 1", type: "ITU")
393
+ item1 = RelatonItu::ItuBibliographicItem.new docid: [docid1], editorialgroup: ed
394
+ expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2 Amd 1", nil, {}).and_return item1
395
+ docid2 = RelatonBib::DocumentIdentifier.new(id: "ITU-T G.989.2 Amd 2", type: "ITU")
396
+ item2 = RelatonItu::ItuBibliographicItem.new docid: [docid2], editorialgroup: ed
397
+ expect(RelatonItu::ItuBibliography).to receive(:get).with("ITU-T G.989.2 Amd 2", nil, {}).and_return item2
398
+ bib = @db.fetch "ITU-T G.989.2, Amd 1, Amd 2"
399
+ expect(bib.docidentifier[0].id).to eq "ITU-T G.989.2, Amd 1, Amd 2"
400
+ expect(bib.relation[0].type).to eq "updates"
401
+ expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2"
402
+ expect(bib.relation[1].type).to eq "complements"
403
+ expect(bib.relation[1].description.content).to eq "amendment"
404
+ expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2 Amd 1"
405
+ expect(bib.relation[2].type).to eq "complements"
406
+ expect(bib.relation[2].description.content).to eq "amendment"
407
+ expect(bib.relation[2].bibitem.docidentifier[0].id).to eq "ITU-T G.989.2 Amd 2"
391
408
  end
392
409
  end
393
410
 
394
411
  context "NIST" do
395
412
  it "included" do
396
- VCR.use_cassette "nist_combined_included" do
397
- bib = @db.fetch "NIST SP 800-38A, Add"
398
- expect(bib.docidentifier[0].id).to eq "NIST SP 800-38A, Add"
399
- expect(bib.relation[0].type).to eq "updates"
400
- expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "SP 800-38A"
401
- expect(bib.relation[1].type).to eq "complements"
402
- expect(bib.relation[1].description.content).to eq "amendment"
403
- expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "SP 800-38A-Add"
404
- end
413
+ # VCR.use_cassette "nist_combined_included" do
414
+ doci = RelatonBib::DocumentIdentifier.new(id: "SP 800-38A", type: "NIST")
415
+ item = RelatonNist::NistBibliographicItem.new docid: [doci]
416
+ expect(RelatonNist::NistBibliography).to receive(:get).with("NIST SP 800-38A", nil, {}).and_return item
417
+ docid1 = RelatonBib::DocumentIdentifier.new(id: "SP 800-38A-Add", type: "NIST")
418
+ item1 = RelatonNist::NistBibliographicItem.new docid: [docid1]
419
+ expect(RelatonNist::NistBibliography).to receive(:get).with("NIST SP 800-38A/Add", nil, {}).and_return item1
420
+ bib = @db.fetch "NIST SP 800-38A, Add"
421
+ expect(bib.docidentifier[0].id).to eq "NIST SP 800-38A, Add"
422
+ expect(bib.relation[0].type).to eq "updates"
423
+ expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "SP 800-38A"
424
+ 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 "SP 800-38A-Add"
427
+ # end
405
428
  end
406
429
  end
407
430
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/setup"
3
+ # require "bundler/setup"
4
4
  require "fileutils"
5
5
  require "rspec/matchers"
6
6
  require "equivalent-xml"
@@ -14,6 +14,7 @@ VCR.configure do |c|
14
14
  re_record_interval: 7 * 24 * 3600,
15
15
  record: :once,
16
16
  allow_playback_repeats: true,
17
+ preserve_exact_body_bytes: true,
17
18
  }
18
19
  c.hook_into :webmock
19
20
  c.configure_rspec_metadata!