relaton 2.1.0 → 2.2.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/CLAUDE.md +8 -0
- data/Gemfile +8 -0
- data/lib/relaton/db/cache.rb +232 -0
- data/lib/relaton/db/config.rb +24 -0
- data/lib/relaton/db/registry.rb +119 -0
- data/lib/relaton/db/util.rb +9 -0
- data/lib/relaton/db/version.rb +5 -0
- data/lib/relaton/db/workers_pool.rb +22 -0
- data/lib/relaton/db.rb +21 -206
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton.rb +2 -10
- data/relaton.gemspec +47 -36
- data/spec/relaton/config_spec.rb +1 -1
- data/spec/relaton/db_cache_spec.rb +4 -4
- data/spec/relaton/db_spec.rb +18 -7
- data/spec/relaton/registry_spec.rb +39 -39
- data/spec/relaton/util_spec.rb +1 -1
- data/spec/relaton_meta_spec.rb +25 -0
- data/spec/relaton_spec.rb +163 -88
- data/spec/spec_helper.rb +2 -2
- data/spec/vcr_cassetes/api_relaton_org.yml +8 -8
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +76 -79
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +80 -77
- data/spec/vcr_cassetes/cipm_meeting_43.yml +1372 -1380
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +500 -504
- data/spec/vcr_cassetes/iso_19115_1.yml +17204 -13047
- data/spec/vcr_cassetes/iso_19115_1_2.yml +193 -240
- data/spec/vcr_cassetes/iso_19115_1_std.yml +17207 -13050
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +116 -160
- data/spec/vcr_cassetes/iso_19133_2005.yml +78 -82
- data/spec/vcr_cassetes/iso_combined_applied.yml +186 -232
- data/spec/vcr_cassetes/iso_combined_included.yml +187 -233
- data/spec/vcr_cassetes/ogc_19_025r1.yml +211 -208
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +246 -246
- data/spec/vcr_cassetes/rfc_8341.yml +1026 -1020
- metadata +133 -78
- data/.rubocop.yml +0 -12
- data/lib/relaton/config.rb +0 -24
- data/lib/relaton/db_cache.rb +0 -230
- data/lib/relaton/registry.rb +0 -118
- data/lib/relaton/util.rb +0 -7
- data/lib/relaton/workers_pool.rb +0 -21
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +0 -12720
- data/spec/vcr_cassetes/cie_001_1980.yml +0 -401
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +0 -86
- data/spec/vcr_cassetes/ecma_6.yml +0 -112
- data/spec/vcr_cassetes/en_10160_1999.yml +0 -13624
- data/spec/vcr_cassetes/ieee_528_2019.yml +0 -2786
- data/spec/vcr_cassetes/iso_dis.yml +0 -157
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
RSpec.describe Relaton::Registry do
|
|
2
|
-
before { Relaton.instance_variable_set :@configuration, nil }
|
|
1
|
+
RSpec.describe Relaton::Db::Registry do
|
|
2
|
+
before { Relaton::Db.instance_variable_set :@configuration, nil }
|
|
3
3
|
|
|
4
4
|
it "outputs backend not present" do
|
|
5
|
-
stub_const "Relaton::Registry::SUPPORTED_GEMS", ["not_supported_gem"]
|
|
6
|
-
expect { Relaton::Registry.clone.instance }.to output(
|
|
7
|
-
/\[relaton\] ERROR: backend not_supported_gem not present/,
|
|
5
|
+
stub_const "Relaton::Db::Registry::SUPPORTED_GEMS", ["not_supported_gem"]
|
|
6
|
+
expect { Relaton::Db::Registry.clone.instance }.to output(
|
|
7
|
+
/\[relaton-db\] ERROR: backend not_supported_gem not present/,
|
|
8
8
|
).to_stderr_from_any_process
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it "finds ISO processor" do
|
|
12
|
-
expect(Relaton::Registry.instance.find_processor("relaton_iso"))
|
|
12
|
+
expect(Relaton::Db::Registry.instance.find_processor("relaton_iso"))
|
|
13
13
|
.to be_instance_of Relaton::Iso::Processor
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "returns supported processors" do
|
|
17
|
-
processors = Relaton::Registry.instance.supported_processors
|
|
17
|
+
processors = Relaton::Db::Registry.instance.supported_processors
|
|
18
18
|
expect(processors).to include :relaton_iso
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
context "finds processor by type" do
|
|
22
22
|
it "CN" do
|
|
23
|
-
expect(Relaton::Registry.instance.by_type("CN")).to be_instance_of Relaton::Gb::Processor
|
|
23
|
+
expect(Relaton::Db::Registry.instance.by_type("CN")).to be_instance_of Relaton::Gb::Processor
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "IEC" do
|
|
27
|
-
expect(Relaton::Registry.instance.by_type("IEC")).to be_instance_of Relaton::Iec::Processor
|
|
27
|
+
expect(Relaton::Db::Registry.instance.by_type("IEC")).to be_instance_of Relaton::Iec::Processor
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "IETF" do
|
|
31
|
-
expect(Relaton::Registry.instance.by_type("IETF")).to be_instance_of Relaton::Ietf::Processor
|
|
31
|
+
expect(Relaton::Db::Registry.instance.by_type("IETF")).to be_instance_of Relaton::Ietf::Processor
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "ISO" do
|
|
35
|
-
expect(Relaton::Registry.instance.by_type("ISO")).to be_instance_of Relaton::Iso::Processor
|
|
35
|
+
expect(Relaton::Db::Registry.instance.by_type("ISO")).to be_instance_of Relaton::Iso::Processor
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "ITU" do
|
|
39
|
-
expect(Relaton::Registry.instance.by_type("ITU")).to be_instance_of Relaton::Itu::Processor
|
|
39
|
+
expect(Relaton::Db::Registry.instance.by_type("ITU")).to be_instance_of Relaton::Itu::Processor
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "NIST" do
|
|
43
|
-
expect(Relaton::Registry.instance.by_type("NIST")).to be_instance_of Relaton::Nist::Processor
|
|
43
|
+
expect(Relaton::Db::Registry.instance.by_type("NIST")).to be_instance_of Relaton::Nist::Processor
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "OGC" do
|
|
47
|
-
expect(Relaton::Registry.instance.by_type("OGC")).to be_instance_of Relaton::Ogc::Processor
|
|
47
|
+
expect(Relaton::Db::Registry.instance.by_type("OGC")).to be_instance_of Relaton::Ogc::Processor
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "CC" do
|
|
51
|
-
expect(Relaton::Registry.instance.by_type("CC")).to be_instance_of Relaton::Calconnect::Processor
|
|
51
|
+
expect(Relaton::Db::Registry.instance.by_type("CC")).to be_instance_of Relaton::Calconnect::Processor
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "OMG" do
|
|
55
|
-
expect(Relaton::Registry.instance.by_type("OMG")).to be_instance_of Relaton::Omg::Processor
|
|
55
|
+
expect(Relaton::Db::Registry.instance.by_type("OMG")).to be_instance_of Relaton::Omg::Processor
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "UN" do
|
|
59
|
-
expect(Relaton::Registry.instance.by_type("UN")).to be_instance_of Relaton::Un::Processor
|
|
59
|
+
expect(Relaton::Db::Registry.instance.by_type("UN")).to be_instance_of Relaton::Un::Processor
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it "W3C" do
|
|
63
|
-
expect(Relaton::Registry.instance.by_type("W3C")).to be_instance_of Relaton::W3c::Processor
|
|
63
|
+
expect(Relaton::Db::Registry.instance.by_type("W3C")).to be_instance_of Relaton::W3c::Processor
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "IEEE" do
|
|
67
|
-
expect(Relaton::Registry.instance.by_type("IEEE")).to be_instance_of Relaton::Ieee::Processor
|
|
67
|
+
expect(Relaton::Db::Registry.instance.by_type("IEEE")).to be_instance_of Relaton::Ieee::Processor
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "IHO" do
|
|
71
|
-
expect(Relaton::Registry.instance.by_type("IHO")).to be_instance_of Relaton::Iho::Processor
|
|
71
|
+
expect(Relaton::Db::Registry.instance.by_type("IHO")).to be_instance_of Relaton::Iho::Processor
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "BIPM" do
|
|
75
|
-
expect(Relaton::Registry.instance.by_type("BIPM")).to be_instance_of Relaton::Bipm::Processor
|
|
76
|
-
expect(Relaton::Registry.instance.processor_by_ref("CCTF"))
|
|
75
|
+
expect(Relaton::Db::Registry.instance.by_type("BIPM")).to be_instance_of Relaton::Bipm::Processor
|
|
76
|
+
expect(Relaton::Db::Registry.instance.processor_by_ref("CCTF"))
|
|
77
77
|
.to be_instance_of Relaton::Bipm::Processor
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "ECMA" do
|
|
81
|
-
expect(Relaton::Registry.instance.by_type("ECMA")).to be_instance_of Relaton::Ecma::Processor
|
|
81
|
+
expect(Relaton::Db::Registry.instance.by_type("ECMA")).to be_instance_of Relaton::Ecma::Processor
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "CIE" do
|
|
85
|
-
expect(Relaton::Registry.instance.by_type("CIE")).to be_instance_of Relaton::Cie::Processor
|
|
85
|
+
expect(Relaton::Db::Registry.instance.by_type("CIE")).to be_instance_of Relaton::Cie::Processor
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it "BSI" do
|
|
89
|
-
expect(Relaton::Registry.instance.by_type("BSI")).to be_instance_of Relaton::Bsi::Processor
|
|
89
|
+
expect(Relaton::Db::Registry.instance.by_type("BSI")).to be_instance_of Relaton::Bsi::Processor
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it "CEN" do
|
|
93
|
-
expect(Relaton::Registry.instance.by_type("CEN")).to be_instance_of Relaton::Cen::Processor
|
|
93
|
+
expect(Relaton::Db::Registry.instance.by_type("CEN")).to be_instance_of Relaton::Cen::Processor
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
it "IANA" do
|
|
97
|
-
expect(Relaton::Registry.instance.by_type("IANA")).to be_instance_of Relaton::Iana::Processor
|
|
97
|
+
expect(Relaton::Db::Registry.instance.by_type("IANA")).to be_instance_of Relaton::Iana::Processor
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
it "3GPP" do
|
|
101
|
-
expect(Relaton::Registry.instance.by_type("3GPP")).to be_instance_of Relaton::ThreeGpp::Processor
|
|
101
|
+
expect(Relaton::Db::Registry.instance.by_type("3GPP")).to be_instance_of Relaton::ThreeGpp::Processor
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
it "OASIS" do
|
|
105
|
-
expect(Relaton::Registry.instance.by_type("OASIS")).to be_instance_of Relaton::Oasis::Processor
|
|
105
|
+
expect(Relaton::Db::Registry.instance.by_type("OASIS")).to be_instance_of Relaton::Oasis::Processor
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it "DOI" do
|
|
109
|
-
expect(Relaton::Registry.instance.by_type("DOI")).to be_instance_of Relaton::Doi::Processor
|
|
110
|
-
expect(Relaton::Registry.instance.processor_by_ref("doi:10.1000/182"))
|
|
109
|
+
expect(Relaton::Db::Registry.instance.by_type("DOI")).to be_instance_of Relaton::Doi::Processor
|
|
110
|
+
expect(Relaton::Db::Registry.instance.processor_by_ref("doi:10.1000/182"))
|
|
111
111
|
.to be_instance_of Relaton::Doi::Processor
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it "JIS" do
|
|
115
|
-
expect(Relaton::Registry.instance.by_type("JIS")).to be_instance_of Relaton::Jis::Processor
|
|
115
|
+
expect(Relaton::Db::Registry.instance.by_type("JIS")).to be_instance_of Relaton::Jis::Processor
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
it "XSF" do
|
|
119
|
-
expect(Relaton::Registry.instance.by_type("XEP")).to be_instance_of Relaton::Xsf::Processor
|
|
119
|
+
expect(Relaton::Db::Registry.instance.by_type("XEP")).to be_instance_of Relaton::Xsf::Processor
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
it "CCSDS" do
|
|
123
|
-
expect(Relaton::Registry.instance.by_type("CCSDS")).to be_instance_of Relaton::Ccsds::Processor
|
|
123
|
+
expect(Relaton::Db::Registry.instance.by_type("CCSDS")).to be_instance_of Relaton::Ccsds::Processor
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
it "ETSI" do
|
|
127
|
-
expect(Relaton::Registry.instance.by_type("ETSI")).to be_instance_of Relaton::Etsi::Processor
|
|
127
|
+
expect(Relaton::Db::Registry.instance.by_type("ETSI")).to be_instance_of Relaton::Etsi::Processor
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
it "ISBN" do
|
|
131
|
-
expect(Relaton::Registry.instance.by_type("ISBN")).to be_instance_of Relaton::Isbn::Processor
|
|
131
|
+
expect(Relaton::Db::Registry.instance.by_type("ISBN")).to be_instance_of Relaton::Isbn::Processor
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
context "PLATEAU" do
|
|
135
|
-
let(:processor) { Relaton::Registry.instance.by_type("PLATEAU") }
|
|
135
|
+
let(:processor) { Relaton::Db::Registry.instance.by_type("PLATEAU") }
|
|
136
136
|
before { processor }
|
|
137
137
|
|
|
138
138
|
it "finds processor" do
|
|
@@ -167,12 +167,12 @@ RSpec.describe Relaton::Registry do
|
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
it "find processot by dataset" do
|
|
170
|
-
expect(Relaton::Registry.instance.find_processor_by_dataset("nist-tech-pubs"))
|
|
170
|
+
expect(Relaton::Db::Registry.instance.find_processor_by_dataset("nist-tech-pubs"))
|
|
171
171
|
.to be_instance_of Relaton::Nist::Processor
|
|
172
172
|
end
|
|
173
173
|
|
|
174
174
|
it "find processor by dataset" do
|
|
175
|
-
expect(Relaton::Registry.instance.find_processor_by_dataset("etsi-csv"))
|
|
175
|
+
expect(Relaton::Db::Registry.instance.find_processor_by_dataset("etsi-csv"))
|
|
176
176
|
.to be_instance_of Relaton::Etsi::Processor
|
|
177
177
|
end
|
|
178
178
|
end
|
data/spec/relaton/util_spec.rb
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe "relaton top-level entry point" do
|
|
4
|
+
it "has a version" do
|
|
5
|
+
expect(Relaton::VERSION).to be_a(String)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "loads Relaton::Db via require 'relaton'" do
|
|
9
|
+
expect(defined?(Relaton::Db)).to eq("constant")
|
|
10
|
+
expect(Relaton::Db).to be_a(Class)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "exposes Relaton::Db::Registry" do
|
|
14
|
+
expect(defined?(Relaton::Db::Registry)).to eq("constant")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "does NOT pull relaton-cli's runtime code via require 'relaton'" do
|
|
18
|
+
# The gem's lib/relaton.rb requires only relaton/db, not relaton/cli.
|
|
19
|
+
# Even if Relaton::Cli is defined as a module shell by some other code
|
|
20
|
+
# path, its runtime classes (Command, ::start) must not be loaded just
|
|
21
|
+
# from `require 'relaton'`.
|
|
22
|
+
expect(defined?(Relaton::Cli::Command)).to be_nil
|
|
23
|
+
expect(Relaton::Cli.respond_to?(:start)).to be(false) if defined?(Relaton::Cli)
|
|
24
|
+
end
|
|
25
|
+
end
|
data/spec/relaton_spec.rb
CHANGED
|
@@ -2,7 +2,7 @@ RSpec.describe Relaton::Db do
|
|
|
2
2
|
before :each do |example|
|
|
3
3
|
FileUtils.rm_rf %w(testcache testcache2)
|
|
4
4
|
@db = Relaton::Db.new "testcache", "testcache2"
|
|
5
|
-
Relaton.instance_variable_set :@configuration, nil
|
|
5
|
+
Relaton::Db.instance_variable_set :@configuration, nil
|
|
6
6
|
|
|
7
7
|
if example.metadata[:vcr]
|
|
8
8
|
require "relaton/index"
|
|
@@ -15,7 +15,7 @@ RSpec.describe Relaton::Db do
|
|
|
15
15
|
|
|
16
16
|
it "rejects an illegal reference prefix" do
|
|
17
17
|
expect { @db.fetch("XYZ XYZ", nil, {}) }.to output(
|
|
18
|
-
/\[relaton\] INFO: \(XYZ XYZ\) `XYZ XYZ` does not/,
|
|
18
|
+
/\[relaton-db\] INFO: \(XYZ XYZ\) `XYZ XYZ` does not/,
|
|
19
19
|
).to_stderr_from_any_process
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -35,40 +35,58 @@ RSpec.describe Relaton::Db do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "with year in code" do
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ISO 19133:2005",
|
|
39
|
+
type: "ISO", primary: true)
|
|
40
|
+
item = Relaton::Iso::ItemData.new(
|
|
41
|
+
docidentifier: [docid], fetched: Date.today.to_s, type: "standard",
|
|
42
|
+
)
|
|
43
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
44
|
+
.with("ISO 19133:2005", nil, {}).and_return item
|
|
45
|
+
bib = @db.fetch("ISO 19133:2005")
|
|
46
|
+
expect(bib).to be_instance_of Relaton::Iso::ItemData
|
|
47
|
+
xml = bib.to_xml
|
|
48
|
+
expect(xml).to include 'id="ISO191332005"'
|
|
49
|
+
expect(xml).to include 'type="standard"'
|
|
50
|
+
testcache = Relaton::Db::Cache.new "testcache"
|
|
51
|
+
expect(
|
|
52
|
+
testcache.valid_entry?("ISO(ISO 19133:2005)", Date.today.year.to_s),
|
|
53
|
+
).to eq Date.today.year.to_s
|
|
49
54
|
end
|
|
50
55
|
|
|
51
56
|
context "all parts" do
|
|
57
|
+
let(:all_parts_item) do
|
|
58
|
+
docid = Relaton::Bib::Docidentifier.new(
|
|
59
|
+
content: "ISO 19115 (all parts)", type: "ISO", primary: true,
|
|
60
|
+
)
|
|
61
|
+
Relaton::Iso::ItemData.new(docidentifier: [docid],
|
|
62
|
+
fetched: Date.today.to_s)
|
|
63
|
+
end
|
|
64
|
+
|
|
52
65
|
it "implicity" do
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
66
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
67
|
+
.with("ISO 19115", nil, { all_parts: true }).and_return all_parts_item
|
|
68
|
+
bib = @db.fetch("ISO 19115", nil, all_parts: true)
|
|
69
|
+
expect(bib.docidentifier[0].content).to eq "ISO 19115 (all parts)"
|
|
57
70
|
end
|
|
58
71
|
|
|
59
72
|
it "explicity" do
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
74
|
+
.with("ISO 19115 (all parts)", nil, {}).and_return all_parts_item
|
|
75
|
+
bib = @db.fetch("ISO 19115 (all parts)")
|
|
76
|
+
expect(bib.docidentifier[0].content).to eq "ISO 19115 (all parts)"
|
|
64
77
|
end
|
|
65
78
|
end
|
|
66
79
|
|
|
67
80
|
it "gets sn ISO/DIS reference" do
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ISO/DIS 14460",
|
|
82
|
+
type: "ISO")
|
|
83
|
+
item = Relaton::Iso::ItemData.new(
|
|
84
|
+
docidentifier: [docid], fetched: Date.today.to_s,
|
|
85
|
+
)
|
|
86
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
87
|
+
.with("ISO/DIS 14460", nil, {}).and_return item
|
|
88
|
+
bib = @db.fetch "ISO/DIS 14460"
|
|
89
|
+
expect(bib.docidentifier[0].content).to eq "ISO/DIS 14460"
|
|
72
90
|
end
|
|
73
91
|
end
|
|
74
92
|
|
|
@@ -129,20 +147,26 @@ RSpec.describe Relaton::Db do
|
|
|
129
147
|
expect(bib).to be_nil
|
|
130
148
|
expect(File.exist?("testcache")).to be true
|
|
131
149
|
expect(File.exist?("testcache2")).to be true
|
|
132
|
-
testcache = Relaton::
|
|
150
|
+
testcache = Relaton::Db::Cache.new "testcache"
|
|
133
151
|
expect(testcache.fetched("ISO(ISO 111111119115-1)")).to eq Date.today.to_s
|
|
134
152
|
expect(testcache["ISO(ISO 111111119115-1)"]).to include "not_found"
|
|
135
|
-
testcache = Relaton::
|
|
153
|
+
testcache = Relaton::Db::Cache.new "testcache2"
|
|
136
154
|
expect(testcache.fetched("ISO(ISO 111111119115-1)")).to eq Date.today.to_s
|
|
137
155
|
expect(testcache["ISO(ISO 111111119115-1)"]).to include "not_found"
|
|
138
156
|
end
|
|
139
157
|
end
|
|
140
158
|
|
|
141
159
|
it "list all elements as a serialization" do
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
160
|
+
%w[ISO\ 19115-1 ISO\ 19115-2].each do |code|
|
|
161
|
+
docid = Relaton::Bib::Docidentifier.new(content: code, type: "ISO",
|
|
162
|
+
primary: true)
|
|
163
|
+
item = Relaton::Iso::ItemData.new(docidentifier: [docid],
|
|
164
|
+
fetched: Date.today.to_s)
|
|
165
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
166
|
+
.with(code, nil, {}).and_return item
|
|
145
167
|
end
|
|
168
|
+
@db.fetch "ISO 19115-1", nil, {}
|
|
169
|
+
@db.fetch "ISO 19115-2", nil, {}
|
|
146
170
|
# file = "spec/support/list_entries.xml"
|
|
147
171
|
# File.write file, @db.to_xml unless File.exist? file
|
|
148
172
|
docs = Nokogiri::XML @db.to_xml
|
|
@@ -155,9 +179,9 @@ RSpec.describe Relaton::Db do
|
|
|
155
179
|
expect(@db.load_entry("not existed key")).to be_nil
|
|
156
180
|
@db.save_entry "test key", nil
|
|
157
181
|
expect(@db.load_entry("test key")).to be_nil
|
|
158
|
-
testcache = Relaton::
|
|
182
|
+
testcache = Relaton::Db::Cache.new "testcache"
|
|
159
183
|
testcache.delete("test_key")
|
|
160
|
-
testcache2 = Relaton::
|
|
184
|
+
testcache2 = Relaton::Db::Cache.new "testcache2"
|
|
161
185
|
testcache2.delete("test_key")
|
|
162
186
|
expect(@db.load_entry("test key")).to be_nil
|
|
163
187
|
end
|
|
@@ -172,11 +196,11 @@ RSpec.describe Relaton::Db do
|
|
|
172
196
|
XML
|
|
173
197
|
expect(File.exist?("testcache")).to be true
|
|
174
198
|
expect(File.exist?("testcache2")).to be true
|
|
175
|
-
testcache = Relaton::
|
|
199
|
+
testcache = Relaton::Db::Cache.new "testcache"
|
|
176
200
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
177
201
|
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
178
202
|
XML
|
|
179
|
-
testcache = Relaton::
|
|
203
|
+
testcache = Relaton::Db::Cache.new "testcache2"
|
|
180
204
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
181
205
|
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
182
206
|
XML
|
|
@@ -192,11 +216,11 @@ RSpec.describe Relaton::Db do
|
|
|
192
216
|
XML
|
|
193
217
|
expect(File.exist?("testcache")).to be true
|
|
194
218
|
expect(File.exist?("testcache2")).to be true
|
|
195
|
-
testcache = Relaton::
|
|
219
|
+
testcache = Relaton::Db::Cache.new "testcache"
|
|
196
220
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
197
221
|
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
198
222
|
XML
|
|
199
|
-
testcache = Relaton::
|
|
223
|
+
testcache = Relaton::Db::Cache.new "testcache2"
|
|
200
224
|
expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
|
|
201
225
|
<project-number origyr="2006">GB/T 20223-2006</project-number>
|
|
202
226
|
XML
|
|
@@ -213,11 +237,11 @@ RSpec.describe Relaton::Db do
|
|
|
213
237
|
)
|
|
214
238
|
expect(File.exist?("testcache")).to be true
|
|
215
239
|
expect(File.exist?("testcache2")).to be true
|
|
216
|
-
testcache = Relaton::
|
|
240
|
+
testcache = Relaton::Db::Cache.new "testcache"
|
|
217
241
|
expect(testcache["IETF(RFC 8341)"]).to include(
|
|
218
242
|
'<docidentifier type="IETF" primary="true">RFC 8341</docidentifier>',
|
|
219
243
|
)
|
|
220
|
-
testcache = Relaton::
|
|
244
|
+
testcache = Relaton::Db::Cache.new "testcache2"
|
|
221
245
|
expect(testcache["IETF(RFC 8341)"]).to include(
|
|
222
246
|
'<docidentifier type="IETF" primary="true">RFC 8341</docidentifier>',
|
|
223
247
|
)
|
|
@@ -305,7 +329,13 @@ RSpec.describe Relaton::Db do
|
|
|
305
329
|
expect(bib.docidentifier.first.content).to eq "CCSDS 230.2-G-1"
|
|
306
330
|
end
|
|
307
331
|
|
|
308
|
-
it "get IEEE reference"
|
|
332
|
+
it "get IEEE reference" do
|
|
333
|
+
require "relaton/ieee"
|
|
334
|
+
docid = Relaton::Bib::Docidentifier.new(content: "IEEE Std 528-2019",
|
|
335
|
+
type: "IEEE")
|
|
336
|
+
item = Relaton::Ieee::ItemData.new docidentifier: [docid]
|
|
337
|
+
expect(Relaton::Ieee::Bibliography).to receive(:get)
|
|
338
|
+
.with("IEEE Std 528-2019", nil, {}).and_return item
|
|
309
339
|
bib = @db.fetch "IEEE Std 528-2019"
|
|
310
340
|
expect(bib).to be_instance_of Relaton::Ieee::ItemData
|
|
311
341
|
end
|
|
@@ -322,17 +352,23 @@ RSpec.describe Relaton::Db do
|
|
|
322
352
|
end
|
|
323
353
|
|
|
324
354
|
it "get ECMA reference" do
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
355
|
+
require "relaton/ecma"
|
|
356
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ECMA-6", type: "ECMA")
|
|
357
|
+
item = Relaton::Ecma::ItemData.new docidentifier: [docid]
|
|
358
|
+
expect(Relaton::Ecma::Bibliography).to receive(:get)
|
|
359
|
+
.with("ECMA-6", nil, {}).and_return item
|
|
360
|
+
bib = @db.fetch "ECMA-6"
|
|
361
|
+
expect(bib).to be_instance_of Relaton::Ecma::ItemData
|
|
329
362
|
end
|
|
330
363
|
|
|
331
364
|
it "get CIE reference" do
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
365
|
+
require "relaton/cie"
|
|
366
|
+
docid = Relaton::Bib::Docidentifier.new(content: "CIE 001-1980", type: "CIE")
|
|
367
|
+
item = Relaton::Cie::ItemData.new docidentifier: [docid]
|
|
368
|
+
expect(Relaton::Cie::Bibliography).to receive(:get)
|
|
369
|
+
.with("CIE 001-1980", nil, {}).and_return item
|
|
370
|
+
bib = @db.fetch "CIE 001-1980"
|
|
371
|
+
expect(bib).to be_instance_of Relaton::Cie::ItemData
|
|
336
372
|
end
|
|
337
373
|
|
|
338
374
|
it "get BSI reference" do
|
|
@@ -348,10 +384,13 @@ RSpec.describe Relaton::Db do
|
|
|
348
384
|
end
|
|
349
385
|
|
|
350
386
|
it "get CEN reference" do
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
387
|
+
require "relaton/cen"
|
|
388
|
+
docid = Relaton::Bib::Docidentifier.new(content: "EN 10160:1999", type: "CEN")
|
|
389
|
+
item = Relaton::Cen::ItemData.new docidentifier: [docid]
|
|
390
|
+
expect(Relaton::Cen::Bibliography).to receive(:get)
|
|
391
|
+
.with("EN 10160:1999", nil, {}).and_return item
|
|
392
|
+
bib = @db.fetch "EN 10160:1999"
|
|
393
|
+
expect(bib).to be_instance_of Relaton::Cen::ItemData
|
|
355
394
|
end
|
|
356
395
|
|
|
357
396
|
it "get IANA reference" do
|
|
@@ -368,10 +407,15 @@ RSpec.describe Relaton::Db do
|
|
|
368
407
|
end
|
|
369
408
|
|
|
370
409
|
it "get 3GPP reference" do
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
410
|
+
require "relaton/3gpp"
|
|
411
|
+
docid = Relaton::Bib::Docidentifier.new(
|
|
412
|
+
content: "3GPP TR 00.01U:UMTS/3.0.0", type: "3GPP",
|
|
413
|
+
)
|
|
414
|
+
item = Relaton::ThreeGpp::ItemData.new docidentifier: [docid]
|
|
415
|
+
expect(Relaton::ThreeGpp::Bibliography).to receive(:get)
|
|
416
|
+
.with("3GPP TR 00.01U:UMTS/3.0.0", nil, {}).and_return item
|
|
417
|
+
bib = @db.fetch "3GPP TR 00.01U:UMTS/3.0.0"
|
|
418
|
+
expect(bib).to be_instance_of Relaton::ThreeGpp::ItemData
|
|
375
419
|
end
|
|
376
420
|
|
|
377
421
|
it "get OASIS reference" do
|
|
@@ -401,7 +445,14 @@ RSpec.describe Relaton::Db do
|
|
|
401
445
|
expect(bib.docidentifier.first.content).to eq "BIPM Metrologia 29 6 373"
|
|
402
446
|
end
|
|
403
447
|
|
|
404
|
-
it "get DOI reference"
|
|
448
|
+
it "get DOI reference" do
|
|
449
|
+
require "relaton/doi"
|
|
450
|
+
docid = Relaton::Bib::Docidentifier.new(
|
|
451
|
+
content: "10.6028/nist.ir.8245", type: "DOI",
|
|
452
|
+
)
|
|
453
|
+
item = Relaton::Bib::ItemData.new docidentifier: [docid]
|
|
454
|
+
expect(Relaton::Doi::Crossref).to receive(:get)
|
|
455
|
+
.with("doi:10.6028/nist.ir.8245").and_return item
|
|
405
456
|
bib = @db.fetch "doi:10.6028/nist.ir.8245"
|
|
406
457
|
expect(bib).to be_instance_of Relaton::Bib::ItemData
|
|
407
458
|
end
|
|
@@ -469,39 +520,54 @@ RSpec.describe Relaton::Db do
|
|
|
469
520
|
|
|
470
521
|
context "get combined documents" do
|
|
471
522
|
context "ISO" do
|
|
523
|
+
# combine_doc (Db's own logic) fetches the base + amendment separately
|
|
524
|
+
# and assembles the relation graph; only the per-part lookups are stubbed,
|
|
525
|
+
# so the relation types/descriptions assembled here stay fully exercised.
|
|
526
|
+
def iso_item(content)
|
|
527
|
+
docid = Relaton::Bib::Docidentifier.new(content: content, type: "ISO",
|
|
528
|
+
primary: true)
|
|
529
|
+
Relaton::Iso::ItemData.new(docidentifier: [docid],
|
|
530
|
+
fetched: Date.today.to_s)
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
before do
|
|
534
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
535
|
+
.with("ISO 19115-1:2014", nil, {})
|
|
536
|
+
.and_return iso_item("ISO 19115-1:2014")
|
|
537
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
538
|
+
.with("ISO 19115-1:2014/Amd 1", nil, {})
|
|
539
|
+
.and_return iso_item("ISO 19115-1:2014/Amd 1:2018")
|
|
540
|
+
end
|
|
541
|
+
|
|
472
542
|
it "included" do
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
.to eq "ISO 19115-1:2014/Amd 1:2018"
|
|
486
|
-
end
|
|
543
|
+
bib = @db.fetch "ISO 19115-1:2014 + Amd 1"
|
|
544
|
+
expect(bib.docidentifier[0].content)
|
|
545
|
+
.to eq "ISO 19115-1:2014 + Amd 1"
|
|
546
|
+
expect(bib.relation[0].type).to eq "updates"
|
|
547
|
+
rel0 = bib.relation[0].bibitem
|
|
548
|
+
expect(rel0.docidentifier[0].content)
|
|
549
|
+
.to eq "ISO 19115-1:2014"
|
|
550
|
+
expect(bib.relation[1].type).to eq "derivedFrom"
|
|
551
|
+
expect(bib.relation[1].description).to be_nil
|
|
552
|
+
rel1 = bib.relation[1].bibitem
|
|
553
|
+
expect(rel1.docidentifier[0].content)
|
|
554
|
+
.to eq "ISO 19115-1:2014/Amd 1:2018"
|
|
487
555
|
end
|
|
488
556
|
|
|
489
557
|
it "applied" do
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
.to eq "ISO 19115-1:2014/Amd 1:2018"
|
|
504
|
-
end
|
|
558
|
+
bib = @db.fetch "ISO 19115-1:2014, Amd 1"
|
|
559
|
+
expect(bib.docidentifier[0].content)
|
|
560
|
+
.to eq "ISO 19115-1:2014, Amd 1"
|
|
561
|
+
expect(bib.relation[0].type).to eq "updates"
|
|
562
|
+
rel0 = bib.relation[0].bibitem
|
|
563
|
+
expect(rel0.docidentifier[0].content)
|
|
564
|
+
.to eq "ISO 19115-1:2014"
|
|
565
|
+
expect(bib.relation[1].type).to eq "complements"
|
|
566
|
+
expect(bib.relation[1].description.content)
|
|
567
|
+
.to eq "amendment"
|
|
568
|
+
rel1 = bib.relation[1].bibitem
|
|
569
|
+
expect(rel1.docidentifier[0].content)
|
|
570
|
+
.to eq "ISO 19115-1:2014/Amd 1:2018"
|
|
505
571
|
end
|
|
506
572
|
end
|
|
507
573
|
|
|
@@ -679,7 +745,7 @@ RSpec.describe Relaton::Db do
|
|
|
679
745
|
processor = double "processor", short: :relaton_iso
|
|
680
746
|
expect(processor).to receive(:grammar_hash)
|
|
681
747
|
.and_return("new_version").exactly(2).times
|
|
682
|
-
expect(Relaton::Registry.instance)
|
|
748
|
+
expect(Relaton::Db::Registry.instance)
|
|
683
749
|
.to receive(:by_type)
|
|
684
750
|
.and_return(processor).exactly(2).times
|
|
685
751
|
Relaton::Db.new "testcache", "testcache2"
|
|
@@ -690,14 +756,14 @@ RSpec.describe Relaton::Db do
|
|
|
690
756
|
|
|
691
757
|
context "api.relaton.org" do
|
|
692
758
|
before(:each) do
|
|
693
|
-
Relaton.configure do |config|
|
|
759
|
+
Relaton::Db.configure do |config|
|
|
694
760
|
config.use_api = true
|
|
695
761
|
# config.api_host = "http://0.0.0.0:9292"
|
|
696
762
|
end
|
|
697
763
|
end
|
|
698
764
|
|
|
699
765
|
after(:each) do
|
|
700
|
-
Relaton.configure do |config|
|
|
766
|
+
Relaton::Db.configure do |config|
|
|
701
767
|
config.use_api = false
|
|
702
768
|
end
|
|
703
769
|
end
|
|
@@ -710,6 +776,15 @@ RSpec.describe Relaton::Db do
|
|
|
710
776
|
end
|
|
711
777
|
|
|
712
778
|
it "if unavailable then get document directly" do
|
|
779
|
+
docid = Relaton::Bib::Docidentifier.new(content: "ISO 19115-2:2019",
|
|
780
|
+
type: "ISO", primary: true)
|
|
781
|
+
item = Relaton::Iso::ItemData.new(docidentifier: [docid],
|
|
782
|
+
fetched: Date.today.to_s)
|
|
783
|
+
# api.relaton.org is refused below, so the fetch must fall back to the
|
|
784
|
+
# flavor's direct lookup -- stub that so the fallback path is exercised
|
|
785
|
+
# without depending on the live ISO index.
|
|
786
|
+
expect(Relaton::Iso::Bibliography).to receive(:get)
|
|
787
|
+
.with("ISO 19115-2", "2019", {}).and_return item
|
|
713
788
|
expect(Net::HTTP).to receive(:get_response)
|
|
714
789
|
.and_wrap_original do |m, *args|
|
|
715
790
|
raise Errno::ECONNREFUSED if args[0].host == "api.relaton.org"
|