geo_combine 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/README.md +61 -0
- data/lib/geo_combine.rb +3 -0
- data/lib/geo_combine/geo_blacklight_harvester.rb +203 -0
- data/lib/geo_combine/version.rb +1 -1
- data/lib/tasks/geo_combine.rake +10 -0
- data/lib/xslt/iso2html.xsl +1107 -1070
- data/spec/features/iso2html_spec.rb +7 -1
- data/spec/lib/geo_combine/geo_blacklight_harvester_spec.rb +190 -0
- metadata +6 -4
@@ -20,31 +20,37 @@ describe 'ISO 19139 to html' do
|
|
20
20
|
describe 'Spatial Reference Information' do
|
21
21
|
it 'has sections' do
|
22
22
|
expect(page).to have_tag '#iso-spatial-reference-info'
|
23
|
+
expect(page).to have_tag 'h2', text: 'Identification Information'
|
23
24
|
end
|
24
25
|
end
|
25
26
|
describe 'Data Quality Information' do
|
26
27
|
it 'has sections' do
|
27
28
|
expect(page).to have_tag '#iso-data-quality-info'
|
29
|
+
expect(page).to have_tag 'h2', text: 'Data Quality Information'
|
28
30
|
end
|
29
31
|
end
|
30
32
|
describe 'Distribution Information' do
|
31
33
|
it 'has sections' do
|
32
34
|
expect(page).to have_tag '#iso-distribution-info'
|
35
|
+
expect(page).to have_tag 'h2', text: 'Distribution Information'
|
33
36
|
end
|
34
37
|
end
|
35
38
|
describe 'Content Information' do
|
36
39
|
it 'has sections' do
|
37
|
-
expect(page).to have_tag '#iso-
|
40
|
+
expect(page).to have_tag '#iso-content-info'
|
41
|
+
expect(page).to have_tag 'h2', text: 'Content Information'
|
38
42
|
end
|
39
43
|
end
|
40
44
|
describe 'Spatial Representation Information' do
|
41
45
|
it 'has sections' do
|
42
46
|
expect(page).to have_tag '#iso-spatial-representation-info'
|
47
|
+
expect(page).to have_tag 'h2', text: 'Spatial Representation Information'
|
43
48
|
end
|
44
49
|
end
|
45
50
|
describe 'Metadata Reference Information' do
|
46
51
|
it 'has sections' do
|
47
52
|
expect(page).to have_tag '#iso-metadata-reference-info'
|
53
|
+
expect(page).to have_tag 'h2', text: 'Metadata Reference Information'
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'rsolr'
|
5
|
+
|
6
|
+
RSpec.describe GeoCombine::GeoBlacklightHarvester do
|
7
|
+
let(:site_key) { :INSTITUTION }
|
8
|
+
let(:stub_json_response) { '{}' }
|
9
|
+
let(:stub_solr_connection) { double('RSolr::Connection') }
|
10
|
+
subject(:harvester) { described_class.new(site_key) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(described_class).to receive(:config).and_return({
|
14
|
+
INSTITUTION: {
|
15
|
+
host: 'https://example.com/',
|
16
|
+
params: {
|
17
|
+
f: { dct_provenance_s: ['INSTITUTION'] }
|
18
|
+
}
|
19
|
+
}
|
20
|
+
})
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'initialization' do
|
24
|
+
context 'when an unconfigured site is sent in' do
|
25
|
+
let(:site_key) { 'unknown' }
|
26
|
+
|
27
|
+
it { expect { harvester }.to raise_error(ArgumentError) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#index' do
|
32
|
+
before do
|
33
|
+
expect(Net::HTTP).to receive(:get).with(
|
34
|
+
URI('https://example.com?f%5Bdct_provenance_s%5D%5B%5D=INSTITUTION&format=json&per_page=100&page=1')
|
35
|
+
).and_return(stub_json_response)
|
36
|
+
allow(RSolr).to receive(:connect).and_return(stub_solr_connection)
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:docs) { [{ layer_slug_s: 'abc-123' }, { layer_slug_s: 'abc-321' }] }
|
40
|
+
let(:stub_json_response) do
|
41
|
+
{ response: { docs: docs, pages: { current_page: 1, total_pages: 1 } } }.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'adds documents returned to solr' do
|
45
|
+
expect(stub_solr_connection).to receive(:update).with(hash_including(data: docs.to_json)).and_return(nil)
|
46
|
+
harvester.index
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'document tranformations' do
|
50
|
+
let(:docs) do
|
51
|
+
[
|
52
|
+
{ layer_slug_s: 'abc-123', _version_: '1', timestamp: '1999-12-31', score: 0.1 },
|
53
|
+
{ layer_slug_s: 'abc-321', dc_source_s: 'abc-123' }
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when a tranformer is set' do
|
58
|
+
before do
|
59
|
+
expect(described_class).to receive(:document_transformer).at_least(:once).and_return(
|
60
|
+
->(doc) {
|
61
|
+
doc.delete('_version_')
|
62
|
+
doc
|
63
|
+
}
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'removes the _version_ field as requested' do
|
68
|
+
expect(stub_solr_connection).to receive(:update).with(
|
69
|
+
hash_including(
|
70
|
+
data: [
|
71
|
+
{ layer_slug_s: 'abc-123', timestamp: '1999-12-31', score: 0.1 },
|
72
|
+
{ layer_slug_s: 'abc-321', dc_source_s: 'abc-123' }
|
73
|
+
].to_json
|
74
|
+
)
|
75
|
+
).and_return(nil)
|
76
|
+
|
77
|
+
harvester.index
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when no transformer is set' do
|
82
|
+
it 'removes the _version_, timestamp, and score fields' do
|
83
|
+
expect(stub_solr_connection).to receive(:update).with(
|
84
|
+
hash_including(
|
85
|
+
data: [
|
86
|
+
{ layer_slug_s: 'abc-123' },
|
87
|
+
{ layer_slug_s: 'abc-321', dc_source_s: 'abc-123' }
|
88
|
+
].to_json
|
89
|
+
)
|
90
|
+
).and_return(nil)
|
91
|
+
|
92
|
+
harvester.index
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe 'BlacklightResponseVersionFactory' do
|
99
|
+
let(:version_class) { described_class::BlacklightResponseVersionFactory.call(json) }
|
100
|
+
|
101
|
+
context 'when a legacy blacklight version (6 and earlier)' do
|
102
|
+
let(:json) { { 'response' => {} } }
|
103
|
+
|
104
|
+
it { expect(version_class).to be described_class::LegacyBlacklightResponse }
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'when a modern blacklight version (7 and later)' do
|
108
|
+
let(:json) { { 'links' => {}, 'data' => [] } }
|
109
|
+
|
110
|
+
it { expect(version_class).to be described_class::ModernBlacklightResponse }
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when a the JSON response is not recognizable' do
|
114
|
+
let(:json) { { error: 'Broken' } }
|
115
|
+
|
116
|
+
it { expect { version_class }.to raise_error(NotImplementedError) }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'LegacyBlacklightResponse' do
|
121
|
+
before do
|
122
|
+
allow(RSolr).to receive(:connect).and_return(stub_solr_connection)
|
123
|
+
end
|
124
|
+
|
125
|
+
let(:first_docs) { [{ 'layer_slug_s' => 'abc-123' }, { 'layer_slug_s' => 'abc-321' }] }
|
126
|
+
let(:second_docs) { [{ 'layer_slug_s' => 'xyz-123' }, { 'layer_slug_s' => 'xyz-321' }] }
|
127
|
+
let(:stub_first_response) do
|
128
|
+
{ 'response' => { 'docs' => first_docs, 'pages' => { 'current_page' => 1, 'total_pages' => 2 } } }
|
129
|
+
end
|
130
|
+
let(:stub_second_response) do
|
131
|
+
{ 'response' => { 'docs' => second_docs, 'pages' => { 'current_page' => 2, 'total_pages' => 2 } } }
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#documents' do
|
135
|
+
it 'pages through the response and returns all the documents' do
|
136
|
+
expect(Net::HTTP).to receive(:get).with(
|
137
|
+
URI('https://example.com?f%5Bdct_provenance_s%5D%5B%5D=INSTITUTION&format=json&per_page=100&page=2')
|
138
|
+
).and_return(stub_second_response.to_json)
|
139
|
+
base_url = 'https://example.com?f%5Bdct_provenance_s%5D%5B%5D=INSTITUTION&format=json&per_page=100'
|
140
|
+
docs = described_class::LegacyBlacklightResponse.new(response: stub_first_response, base_url: base_url).documents
|
141
|
+
|
142
|
+
expect(docs.to_a).to eq([first_docs, second_docs])
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe 'ModernBlacklightResponse' do
|
148
|
+
before do
|
149
|
+
allow(RSolr).to receive(:connect).and_return(stub_solr_connection)
|
150
|
+
expect(Net::HTTP).to receive(:get).with(
|
151
|
+
URI('https://example.com?f%5Bdct_provenance_s%5D%5B%5D=INSTITUTION&format=json&per_page=100&page=2')
|
152
|
+
).and_return(second_results_response.to_json)
|
153
|
+
end
|
154
|
+
|
155
|
+
let(:first_results_response) do
|
156
|
+
{ 'data' => [
|
157
|
+
{ 'links' => { 'self' => 'https://example.com/catalog/abc-123' } },
|
158
|
+
{ 'links' => { 'self' => 'https://example.com/catalog/abc-321' } }
|
159
|
+
],
|
160
|
+
'links' => { 'next' => 'https://example.com?f%5Bdct_provenance_s%5D%5B%5D=INSTITUTION&format=json&per_page=100&page=2' }
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
let(:second_results_response) do
|
165
|
+
{ 'data' => [
|
166
|
+
{ 'links' => { 'self' => 'https://example.com/catalog/xyz-123' } },
|
167
|
+
{ 'links' => { 'self' => 'https://example.com/catalog/xyz-321' } }
|
168
|
+
]
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#documents' do
|
173
|
+
it 'pages through the response and fetches documents for each "link" on the response data' do
|
174
|
+
%w[abc-123 abc-321 xyz-123 xyz-321].each do |id|
|
175
|
+
expect(Net::HTTP).to receive(:get).with(
|
176
|
+
URI("https://example.com/catalog/#{id}/raw")
|
177
|
+
).and_return({ 'layer_slug_s' => id }.to_json)
|
178
|
+
end
|
179
|
+
|
180
|
+
base_url = 'https://example.com?f%5Bdct_provenance_s%5D%5B%5D=INSTITUTION&format=json&per_page=100'
|
181
|
+
docs = described_class::ModernBlacklightResponse.new(response: first_results_response, base_url: base_url).documents
|
182
|
+
|
183
|
+
expect(docs.to_a).to eq([
|
184
|
+
[{ 'layer_slug_s' => 'abc-123' }, { 'layer_slug_s' => 'abc-321' }],
|
185
|
+
[{ 'layer_slug_s' => 'xyz-123' }, { 'layer_slug_s' => 'xyz-321' }],
|
186
|
+
])
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_combine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Reed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- lib/geo_combine/fgdc.rb
|
192
192
|
- lib/geo_combine/formats.rb
|
193
193
|
- lib/geo_combine/formatting.rb
|
194
|
+
- lib/geo_combine/geo_blacklight_harvester.rb
|
194
195
|
- lib/geo_combine/geoblacklight.rb
|
195
196
|
- lib/geo_combine/geometry_types.rb
|
196
197
|
- lib/geo_combine/iso19139.rb
|
@@ -234,6 +235,7 @@ files:
|
|
234
235
|
- spec/lib/geo_combine/esri_open_data_spec.rb
|
235
236
|
- spec/lib/geo_combine/fgdc_spec.rb
|
236
237
|
- spec/lib/geo_combine/formatting_spec.rb
|
238
|
+
- spec/lib/geo_combine/geo_blacklight_harvester_spec.rb
|
237
239
|
- spec/lib/geo_combine/geoblacklight_spec.rb
|
238
240
|
- spec/lib/geo_combine/iso19139_spec.rb
|
239
241
|
- spec/lib/geo_combine/ogp_spec.rb
|
@@ -258,8 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
260
|
- !ruby/object:Gem::Version
|
259
261
|
version: '0'
|
260
262
|
requirements: []
|
261
|
-
|
262
|
-
rubygems_version: 2.4.5
|
263
|
+
rubygems_version: 3.1.2
|
263
264
|
signing_key:
|
264
265
|
specification_version: 4
|
265
266
|
summary: A Ruby toolkit for managing geospatial metadata
|
@@ -282,6 +283,7 @@ test_files:
|
|
282
283
|
- spec/lib/geo_combine/esri_open_data_spec.rb
|
283
284
|
- spec/lib/geo_combine/fgdc_spec.rb
|
284
285
|
- spec/lib/geo_combine/formatting_spec.rb
|
286
|
+
- spec/lib/geo_combine/geo_blacklight_harvester_spec.rb
|
285
287
|
- spec/lib/geo_combine/geoblacklight_spec.rb
|
286
288
|
- spec/lib/geo_combine/iso19139_spec.rb
|
287
289
|
- spec/lib/geo_combine/ogp_spec.rb
|