relaton 1.17.0 → 1.17.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 161865c4183f2125b3967ecf451cfc0473253d933b3f84d35684bef6b30a94dd
4
- data.tar.gz: 678698b76ead0a46765e462622df3e4670331843e563b043e644bb2210c44414
3
+ metadata.gz: 18c8244f75e034cd05320232fae767d59e10bd6de5f2983dad701ed8ddcbef59
4
+ data.tar.gz: b384e225f15c0fb4600f8bd245e6ee4a5c2820bbaf3fc865a308972e358a3fd6
5
5
  SHA512:
6
- metadata.gz: ab8d13611095fc725320d7aa4d5ec6ef1b81ec987ce91853fc312980391e7b42f64c986ef8b47f1609a7021eef9a7bdacaf5fa6d32606a64a03801ee99029ab0
7
- data.tar.gz: 30f38ad4cb1b49c175f4616de286d2a94ff5bddf53712221fe0d915b2cb51795db2ab976c6c5cd2ca6e812e2788ad00e613d2ce9cc824067a8ab5096e6d16c72
6
+ metadata.gz: c83e2b59913fead7d8a7fee650ed739330c3f7cbccfc63eec6d9530e7ca433e3bd026f2c7a15a61735b0b2e72d4106fd7ddd6ddc9a4e3cd00be349c2c288a497
7
+ data.tar.gz: 49ff93fb5f75841a9ae70dae67c437e3b04fa29977dd96cc9a6470ad5dee4183ccf99951a8aa950551b0811a08c3b03f12eb7b3bcbcd7565b039e167fe8e1a23
@@ -10,7 +10,7 @@ module Relaton
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
12
  relaton_cen relaton_iana relaton_3gpp relaton_oasis relaton_doi relaton_jis
13
- relaton_xsf relaton_ccsds
13
+ relaton_xsf relaton_ccsds relaton_etsi relaton_isbn
14
14
  ].freeze
15
15
 
16
16
  include Singleton
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.17.0".freeze
2
+ VERSION = "1.17.2".freeze
3
3
  end
data/relaton.gemspec CHANGED
@@ -38,12 +38,14 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency "relaton-cie", "~> 1.17.0"
39
39
  spec.add_dependency "relaton-doi", "~> 1.17.0"
40
40
  spec.add_dependency "relaton-ecma", "~> 1.17.0"
41
+ spec.add_dependency "relaton-etsi", "~> 1.17.0"
41
42
  spec.add_dependency "relaton-gb", "~> 1.17.0"
42
43
  spec.add_dependency "relaton-iana", "~> 1.17.0"
43
44
  spec.add_dependency "relaton-iec", "~> 1.17.0"
44
45
  spec.add_dependency "relaton-ieee", "~> 1.17.0"
45
46
  spec.add_dependency "relaton-ietf", "~> 1.17.0"
46
47
  spec.add_dependency "relaton-iho", "~> 1.17.0"
48
+ spec.add_dependency "relaton-isbn", "~> 1.17.0"
47
49
  spec.add_dependency "relaton-iso", "~> 1.17.0"
48
50
  spec.add_dependency "relaton-itu", "~> 1.17.0"
49
51
  spec.add_dependency "relaton-jis", "~> 1.17.0"
@@ -32,4 +32,82 @@ RSpec.describe Relaton::Processor do
32
32
  expect { subject.grammar_hash }.to raise_error StandardError
33
33
  end
34
34
  end
35
+
36
+ context "flavor processors" do
37
+ before { Relaton::Registry.instance }
38
+
39
+ shared_examples "common processor methods" do |flavor, namespace, bibmodule|
40
+ let(:processor) { Relaton::Registry.instance.by_type flavor }
41
+ let(:flavor_module) { Object.const_get namespace }
42
+ let(:bibliography) { Object.const_get "#{namespace}::#{bibmodule}" }
43
+
44
+ it "get method should call get method of #{flavor}" do
45
+ expect(bibliography).to receive(:get).with("code", nil, {}).and_return :item
46
+ expect(processor.get "code", nil, {}).to eq :item
47
+ end
48
+
49
+ it "grammar_hash method should call grammar_hash method of #{flavor}" do
50
+ expect(flavor_module).to receive(:grammar_hash).and_return :hash
51
+ expect(processor.grammar_hash).to eq :hash
52
+ end
53
+ end
54
+
55
+ shared_examples "fetch_data method" do |flavor, fetcher, source|
56
+ let(:processor) { Relaton::Registry.instance.by_type flavor }
57
+ let(:fetcher_class) { Object.const_get fetcher }
58
+
59
+ it "fetch_data method should call fetch_data method of #{flavor}" do
60
+ expect(fetcher_class).to receive(:fetch).with(output: "dir", format: "bibxml").and_return :item
61
+ expect(processor.fetch_data source, output: "dir", format: "bibxml").to eq :item
62
+ end
63
+ end
64
+
65
+ shared_examples "from_xml method" do |flavor, parser|
66
+ let(:processor) { Relaton::Registry.instance.by_type flavor }
67
+ let(:parser_class) { Object.const_get parser }
68
+
69
+ it "from_xml method should call from_xml method of #{flavor}" do
70
+ expect(parser_class).to receive(:from_xml).with("xml").and_return :item
71
+ expect(processor.from_xml "xml").to eq :item
72
+ end
73
+ end
74
+
75
+ shared_examples "hash_to_bib method" do |flavor, converter, bibitem|
76
+ let(:processor) { Relaton::Registry.instance.by_type flavor }
77
+ let(:converter_class) { Object.const_get converter }
78
+ let(:bibitem_class) { Object.const_get bibitem }
79
+
80
+ it "hash_to_bib method should call hash_to_bib method of #{flavor}" do
81
+ expect(converter_class).to receive(:hash_to_bib).with(:hash).and_return title: "title"
82
+ expect(bibitem_class).to receive(:new).with(title: "title").and_return :item
83
+ expect(processor.hash_to_bib(:hash)).to eq :item
84
+ end
85
+ end
86
+
87
+ shared_examples "remove_index_file method" do |flavor, file|
88
+ let(:processor) { Relaton::Registry.instance.by_type flavor }
89
+
90
+ it "remove index file" do
91
+ index = double "index"
92
+ expect(index).to receive(:remove_file)
93
+ expect(Relaton::Index).to receive(:find_or_create)
94
+ .with(flavor.downcase.to_sym, url: true, file: file).and_return index
95
+ processor.remove_index_file
96
+ end
97
+ end
98
+
99
+ context "ETSI processor" do
100
+ it_behaves_like "common processor methods", "ETSI", "RelatonEtsi", "Bibliography"
101
+ it_behaves_like "fetch_data method", "ETSI", "RelatonEtsi::DataFetcher", "etsi-csv"
102
+ it_behaves_like "from_xml method", "ETSI", "RelatonEtsi::XMLParser"
103
+ it_behaves_like "hash_to_bib method", "ETSI", "RelatonEtsi::HashConverter", "RelatonEtsi::BibliographicItem"
104
+ it_behaves_like "remove_index_file method", "ETSI", "index-v1.yaml"
105
+ end
106
+
107
+ context "ISBN processor" do
108
+ it_behaves_like "common processor methods", "ISBN", "RelatonIsbn", "OpenLibrary"
109
+ it_behaves_like "from_xml method", "ISBN", "RelatonBib::XMLParser"
110
+ it_behaves_like "hash_to_bib method", "ISBN", "RelatonBib::HashConverter", "RelatonBib::BibliographicItem"
111
+ end
112
+ end
35
113
  end
@@ -119,11 +119,22 @@ RSpec.describe Relaton::Registry do
119
119
  it "CCSDS" do
120
120
  expect(Relaton::Registry.instance.by_type("CCSDS")).to be_instance_of RelatonCcsds::Processor
121
121
  end
122
+
123
+ it "ETSI" do
124
+ expect(Relaton::Registry.instance.by_type("ETSI")).to be_instance_of RelatonEtsi::Processor
125
+ end
126
+
127
+ it "ISBN" do
128
+ expect(Relaton::Registry.instance.by_type("ISBN")).to be_instance_of RelatonIsbn::Processor
129
+ end
122
130
  end
123
131
 
124
132
  it "find processot by dataset" do
125
- expect(Relaton::Registry.instance
126
- .find_processor_by_dataset("nist-tech-pubs"))
133
+ expect(Relaton::Registry.instance.find_processor_by_dataset("nist-tech-pubs"))
127
134
  .to be_instance_of RelatonNist::Processor
128
135
  end
136
+
137
+ it "find processor by dataset" do
138
+ expect(Relaton::Registry.instance.find_processor_by_dataset "etsi-csv").to be_instance_of RelatonEtsi::Processor
139
+ end
129
140
  end
data/spec/relaton_spec.rb CHANGED
@@ -138,45 +138,45 @@ RSpec.describe Relaton::Db do
138
138
  end
139
139
 
140
140
  context "get GB reference" do
141
- # it "and cache it" do
142
- # VCR.use_cassette "gb_t_20223_2006" do
143
- # bib = @db.fetch "CN(GB/T 20223)", "2006", {}
144
- # expect(bib).to be_instance_of RelatonGb::GbBibliographicItem
145
- # expect(bib.to_xml(bibdata: true)).to include <<~XML
146
- # <project-number>GB/T 20223</project-number>
147
- # XML
148
- # expect(File.exist?("testcache")).to be true
149
- # expect(File.exist?("testcache2")).to be true
150
- # testcache = Relaton::DbCache.new "testcache"
151
- # expect(testcache["CN(GB/T 20223:2006)"]).to include <<~XML
152
- # <project-number>GB/T 20223</project-number>
153
- # XML
154
- # testcache = Relaton::DbCache.new "testcache2"
155
- # expect(testcache["CN(GB/T 20223:2006)"]).to include <<~XML
156
- # <project-number>GB/T 20223</project-number>
157
- # XML
158
- # end
159
- # end
160
-
161
- # it "with year" do
162
- # VCR.use_cassette "gb_t_20223_2006" do
163
- # bib = @db.fetch "CN(GB/T 20223-2006)", nil, {}
164
- # expect(bib).to be_instance_of RelatonGb::GbBibliographicItem
165
- # expect(bib.to_xml(bibdata: true)).to include <<~XML
166
- # <project-number>GB/T 20223</project-number>
167
- # XML
168
- # expect(File.exist?("testcache")).to be true
169
- # expect(File.exist?("testcache2")).to be true
170
- # testcache = Relaton::DbCache.new "testcache"
171
- # expect(testcache["CN(GB/T 20223:2006)"]).to include <<~XML
172
- # <project-number>GB/T 20223</project-number>
173
- # XML
174
- # testcache = Relaton::DbCache.new "testcache2"
175
- # expect(testcache["CN(GB/T 20223:2006)"]).to include <<~XML
176
- # <project-number>GB/T 20223</project-number>
177
- # XML
178
- # end
179
- # end
141
+ it "and cache it" do
142
+ VCR.use_cassette "gb_t_20223_2006" do
143
+ bib = @db.fetch "CN(GB/T 20223)", "2006", {}
144
+ expect(bib).to be_instance_of RelatonGb::GbBibliographicItem
145
+ expect(bib.to_xml(bibdata: true)).to include <<~XML
146
+ <project-number>GB/T 20223</project-number>
147
+ XML
148
+ expect(File.exist?("testcache")).to be true
149
+ expect(File.exist?("testcache2")).to be true
150
+ testcache = Relaton::DbCache.new "testcache"
151
+ expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
152
+ <project-number>GB/T 20223</project-number>
153
+ XML
154
+ testcache = Relaton::DbCache.new "testcache2"
155
+ expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
156
+ <project-number>GB/T 20223</project-number>
157
+ XML
158
+ end
159
+ end
160
+
161
+ it "with year" do
162
+ VCR.use_cassette "gb_t_20223_2006" do
163
+ bib = @db.fetch "CN(GB/T 20223-2006)", nil, {}
164
+ expect(bib).to be_instance_of RelatonGb::GbBibliographicItem
165
+ expect(bib.to_xml(bibdata: true)).to include <<~XML
166
+ <project-number>GB/T 20223</project-number>
167
+ XML
168
+ expect(File.exist?("testcache")).to be true
169
+ expect(File.exist?("testcache2")).to be true
170
+ testcache = Relaton::DbCache.new "testcache"
171
+ expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
172
+ <project-number>GB/T 20223</project-number>
173
+ XML
174
+ testcache = Relaton::DbCache.new "testcache2"
175
+ expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
176
+ <project-number>GB/T 20223</project-number>
177
+ XML
178
+ end
179
+ end
180
180
  end
181
181
 
182
182
  it "get RFC reference and cache it" do
@@ -355,6 +355,24 @@ RSpec.describe Relaton::Db do
355
355
  expect(bib.docidentifier.first.id).to eq "XEP 0001"
356
356
  end
357
357
 
358
+ it "get ETSI reference" do
359
+ docid = RelatonBib::DocumentIdentifier.new(id: "ETSI EN 300 175-8", type: "ETSI")
360
+ item = RelatonEtsi::BibliographicItem.new docid: [docid]
361
+ expect(RelatonEtsi::Bibliography).to receive(:get).with("ETSI EN 300 175-8", nil, {}).and_return item
362
+ bib = @db.fetch "ETSI EN 300 175-8"
363
+ expect(bib).to be_instance_of RelatonEtsi::BibliographicItem
364
+ expect(bib.docidentifier.first.id).to eq "ETSI EN 300 175-8"
365
+ end
366
+
367
+ it "get ISBN reference" do
368
+ docid = RelatonBib::DocumentIdentifier.new(id: "ISBN 978-0-580-50101-4", type: "ISBN")
369
+ item = RelatonBib::BibliographicItem.new docid: [docid]
370
+ expect(RelatonIsbn::OpenLibrary).to receive(:get).with("ISBN 978-0-580-50101-4", nil, {}).and_return item
371
+ bib = @db.fetch "ISBN 978-0-580-50101-4"
372
+ expect(bib).to be_instance_of RelatonBib::BibliographicItem
373
+ expect(bib.docidentifier.first.id).to eq "ISBN 978-0-580-50101-4"
374
+ end
375
+
358
376
  context "get combined documents" do
359
377
  context "ISO" do
360
378
  it "included" do
@@ -39,21 +39,21 @@ http_interactions:
39
39
  X-Xss-Protection:
40
40
  - 1; mode=block
41
41
  X-Github-Request-Id:
42
- - 6ACA:263D:D71965:10FED1A:6563F706
42
+ - EA0A:234C:6136C2:76A26F:657CBECC
43
43
  Accept-Ranges:
44
44
  - bytes
45
45
  Date:
46
- - Mon, 27 Nov 2023 01:55:22 GMT
46
+ - Fri, 15 Dec 2023 21:02:05 GMT
47
47
  Via:
48
48
  - 1.1 varnish
49
49
  X-Served-By:
50
- - cache-pdk-kpdk1780035-PDK
50
+ - cache-pdk-kpdk1780087-PDK
51
51
  X-Cache:
52
52
  - MISS
53
53
  X-Cache-Hits:
54
54
  - '0'
55
55
  X-Timer:
56
- - S1701050122.300647,VS0,VE158
56
+ - S1702674125.021523,VS0,VE264
57
57
  Vary:
58
58
  - Authorization,Accept-Encoding,Origin
59
59
  Access-Control-Allow-Origin:
@@ -61,9 +61,9 @@ http_interactions:
61
61
  Cross-Origin-Resource-Policy:
62
62
  - cross-origin
63
63
  X-Fastly-Request-Id:
64
- - 4fe800c6af7705f1b714a8e04007433d2c95ef7b
64
+ - 7cf65cbbcbdaeb1dfc42be6245dcb99d105b95c2
65
65
  Expires:
66
- - Mon, 27 Nov 2023 02:00:22 GMT
66
+ - Fri, 15 Dec 2023 21:07:05 GMT
67
67
  Source-Age:
68
68
  - '0'
69
69
  body:
@@ -11299,7 +11299,7 @@ http_interactions:
11299
11299
  HgMUAAAACAA6cm9XZto2RTS1BwAWXlAADQAYAAAAAAABAAAApIEAAAAAaW5k
11300
11300
  ZXgtdjEueWFtbFVUBQADENNUZXV4CwABBOkDAAAEfwAAAFBLBQYAAAAAAQAB
11301
11301
  AFMAAAB7tQcAAAA=
11302
- recorded_at: Mon, 27 Nov 2023 01:55:22 GMT
11302
+ recorded_at: Fri, 15 Dec 2023 21:02:05 GMT
11303
11303
  - request:
11304
11304
  method: get
11305
11305
  uri: https://raw.githubusercontent.com/relaton/relaton-data-3gpp/main/data/TR_00.01U_UMTS_3.0.0.yaml
@@ -11313,6 +11313,8 @@ http_interactions:
11313
11313
  - "*/*"
11314
11314
  User-Agent:
11315
11315
  - Ruby
11316
+ Host:
11317
+ - raw.githubusercontent.com
11316
11318
  response:
11317
11319
  status:
11318
11320
  code: 200
@@ -11339,21 +11341,21 @@ http_interactions:
11339
11341
  X-Xss-Protection:
11340
11342
  - 1; mode=block
11341
11343
  X-Github-Request-Id:
11342
- - FA38:9DA8:161F5FD:1B269AA:6563F70E
11344
+ - B8D8:0424:5FE216:754B4B:657CBED0
11343
11345
  Accept-Ranges:
11344
11346
  - bytes
11345
11347
  Date:
11346
- - Mon, 27 Nov 2023 01:55:26 GMT
11348
+ - Fri, 15 Dec 2023 21:02:08 GMT
11347
11349
  Via:
11348
11350
  - 1.1 varnish
11349
11351
  X-Served-By:
11350
- - cache-pdk-kpdk1780083-PDK
11352
+ - cache-pdk-kpdk1780090-PDK
11351
11353
  X-Cache:
11352
11354
  - MISS
11353
11355
  X-Cache-Hits:
11354
11356
  - '0'
11355
11357
  X-Timer:
11356
- - S1701050126.978850,VS0,VE223
11358
+ - S1702674129.629585,VS0,VE137
11357
11359
  Vary:
11358
11360
  - Authorization,Accept-Encoding,Origin
11359
11361
  Access-Control-Allow-Origin:
@@ -11361,9 +11363,9 @@ http_interactions:
11361
11363
  Cross-Origin-Resource-Policy:
11362
11364
  - cross-origin
11363
11365
  X-Fastly-Request-Id:
11364
- - b95b0612421e75a14fddd2d60ac6a4c7103edc2a
11366
+ - e5a350b43167b7f3d41e7f2809b0d4869346f491
11365
11367
  Expires:
11366
- - Mon, 27 Nov 2023 02:00:26 GMT
11368
+ - Fri, 15 Dec 2023 21:07:08 GMT
11367
11369
  Source-Age:
11368
11370
  - '0'
11369
11371
  body:
@@ -11404,5 +11406,5 @@ http_interactions:
11404
11406
  bWVldGluZzogU01HLTI4CiAgZnJlZXplX3N0YWdlMl9tZWV0aW5nOiBTTUct
11405
11407
  MjgKICBmcmVlemVfc3RhZ2UzX21lZXRpbmc6IFNNRy0yOAogIGNsb3NlX21l
11406
11408
  ZXRpbmc6IFNQLTI4CiAgcHJvamVjdF9lbmQ6ICcxOTk5LTAyLTEyJwo=
11407
- recorded_at: Mon, 27 Nov 2023 01:55:26 GMT
11409
+ recorded_at: Fri, 15 Dec 2023 21:02:08 GMT
11408
11410
  recorded_with: VCR 6.2.0
@@ -13,6 +13,8 @@ http_interactions:
13
13
  - "*/*"
14
14
  User-Agent:
15
15
  - Ruby
16
+ Host:
17
+ - api.relaton.org
16
18
  response:
17
19
  status:
18
20
  code: 200
@@ -25,27 +27,27 @@ http_interactions:
25
27
  Connection:
26
28
  - keep-alive
27
29
  Date:
28
- - Mon, 27 Nov 2023 01:56:09 GMT
30
+ - Fri, 15 Dec 2023 21:02:54 GMT
29
31
  X-Amzn-Requestid:
30
- - 0335c18a-9e5a-453a-bd05-2d4493ff348f
32
+ - d5797694-3f7c-4b5c-b0b4-4e258aa6421b
31
33
  Access-Control-Allow-Origin:
32
34
  - "*"
33
35
  Access-Control-Allow-Headers:
34
36
  - Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
35
37
  X-Amz-Apigw-Id:
36
- - PCOOoGFXIAMEpVw=
38
+ - QALFSHcAoAMEfnQ=
37
39
  Access-Control-Allow-Methods:
38
40
  - GET, POST, OPTIONS
39
41
  X-Amzn-Trace-Id:
40
- - Root=1-6563f72a-6cd241bc287ba8a67a95a7ee;Sampled=0;lineage=521d48d5:0
42
+ - Root=1-657cbeee-0e87a651219ca2fd35614c22;Sampled=0;lineage=521d48d5:0
41
43
  X-Cache:
42
44
  - Miss from cloudfront
43
45
  Via:
44
- - 1.1 0a576c2dd3353021ea1e162ded4d3a7c.cloudfront.net (CloudFront)
46
+ - 1.1 fc1009b8e45427207e2a571827e9dd24.cloudfront.net (CloudFront)
45
47
  X-Amz-Cf-Pop:
46
48
  - ATL51-C1
47
49
  X-Amz-Cf-Id:
48
- - YH0okkeNR7fj-Qv5Ljpr72dITOlVsS60NyvmUppIDvIm6GujDop0lw==
50
+ - _diMw4SxewdLl3Da5yx4iI-ZOXbCTRmzU6L0JQUGRIumlHu4ejmYCg==
49
51
  body:
50
52
  encoding: UTF-8
51
53
  base64_string: |
@@ -115,5 +117,5 @@ http_interactions:
115
117
  dHJ1Y3R1cmVkaWRlbnRpZmllciB0eXBlPSJJU08iPgogICAgICA8cHJvamVj
116
118
  dC1udW1iZXI+SVNPIDE5MTE1PC9wcm9qZWN0LW51bWJlcj4KICAgIDwvc3Ry
117
119
  dWN0dXJlZGlkZW50aWZpZXI+CiAgPC9leHQ+CjwvYmliZGF0YT4=
118
- recorded_at: Mon, 27 Nov 2023 01:56:09 GMT
120
+ recorded_at: Fri, 15 Dec 2023 21:02:54 GMT
119
121
  recorded_with: VCR 6.2.0