geo_combine 0.9.2 → 0.10.0

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.
@@ -5,6 +5,7 @@ require 'spec_helper'
5
5
  # TODO: Provide additional expectations on html structure
6
6
  describe 'FGDC to html' do
7
7
  include XmlDocs
8
+
8
9
  let(:page) { GeoCombine::Fgdc.new(tufts_fgdc).to_html }
9
10
 
10
11
  describe 'Identification Information' do
@@ -5,6 +5,7 @@ require 'spec_helper'
5
5
  # TODO: Provide additional expectations on html structure
6
6
  describe 'ISO 19139 to html' do
7
7
  include XmlDocs
8
+
8
9
  let(:page) { GeoCombine::Iso19139.new(stanford_iso).to_html }
9
10
 
10
11
  describe 'Identification Information' do
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe GeoCombine::CkanMetadata do
6
6
  include JsonDocs
7
+
7
8
  let(:ckan_sample) { described_class.new(ckan_metadata) }
8
9
 
9
10
  describe '#to_geoblacklight' do
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe GeoCombine::EsriOpenData do
6
6
  include JsonDocs
7
+
7
8
  let(:esri_sample) { described_class.new(esri_opendata_metadata) }
8
9
  let(:metadata) { esri_sample.instance_variable_get(:@metadata) }
9
10
 
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe GeoCombine::Fgdc do
6
6
  include XmlDocs
7
+
7
8
  let(:fgdc_object) { described_class.new(tufts_fgdc) }
8
9
 
9
10
  describe '#initialize' do
@@ -32,7 +33,7 @@ RSpec.describe GeoCombine::Fgdc do
32
33
  end
33
34
 
34
35
  it 'is not valid due to bad modification date but valid otherwise' do
35
- expect { fgdc_geobl.valid? }.to raise_error(JSON::Schema::ValidationError, /layer_modified_dt/)
36
+ expect { fgdc_geobl.validate! }.to raise_error(JSON::Schema::ValidationError, /layer_modified_dt/)
36
37
  fgdc_geobl.metadata.delete 'layer_modified_dt'
37
38
  expect(fgdc_geobl).to be_valid
38
39
  end
@@ -51,7 +52,7 @@ RSpec.describe GeoCombine::Fgdc do
51
52
  end
52
53
 
53
54
  it 'dc_description_s' do
54
- expect(fgdc_geobl.metadata['dc_description_s']).to match(/Ecuador created from/)
55
+ expect(fgdc_geobl.metadata['dc_description_s']).to match('Ecuador created from')
55
56
  end
56
57
 
57
58
  it 'dc_rights_s' do
@@ -6,6 +6,7 @@ RSpec.describe GeoCombine::Geoblacklight do
6
6
  include XmlDocs
7
7
  include JsonDocs
8
8
  include GeoCombine::Exceptions
9
+
9
10
  let(:full_geobl) { described_class.new(full_geoblacklight) }
10
11
  let(:enhanced_geobl) { described_class.new(basic_geoblacklight, 'layer_geom_type_s' => 'esriGeometryPolygon') }
11
12
  let(:basic_geobl) { described_class.new(basic_geoblacklight) }
@@ -60,11 +61,17 @@ RSpec.describe GeoCombine::Geoblacklight do
60
61
  it 'formats the geometry type field' do
61
62
  expect(enhanced_geobl.metadata['layer_geom_type_s']).to eq 'Polygon'
62
63
  end
64
+
65
+ it 'populates the geometry type field from the subject field if not set' do
66
+ enhanced_from_subject_geobl = described_class.new(basic_geoblacklight, 'dc_subject_sm' => ['polygon'])
67
+ enhanced_from_subject_geobl.enhance_metadata
68
+ expect(enhanced_from_subject_geobl.metadata['layer_geom_type_s']).to eq 'Polygon'
69
+ end
63
70
  end
64
71
 
65
- describe '#valid?' do
72
+ describe '#validate!' do
66
73
  it 'a valid geoblacklight-schema document should be valid' do
67
- expect(full_geobl.valid?).to be true
74
+ expect(full_geobl).to be_valid
68
75
  end
69
76
 
70
77
  context 'must have required fields' do
@@ -78,7 +85,7 @@ RSpec.describe GeoCombine::Geoblacklight do
78
85
  ].each do |field|
79
86
  it field do
80
87
  full_geobl.metadata.delete field
81
- expect { full_geobl.valid? }.to raise_error(JSON::Schema::ValidationError, /#{field}/)
88
+ expect { full_geobl.validate! }.to raise_error(JSON::Schema::ValidationError, /#{field}/)
82
89
  end
83
90
  end
84
91
  end
@@ -104,7 +111,7 @@ RSpec.describe GeoCombine::Geoblacklight do
104
111
  ].each do |field|
105
112
  it field do
106
113
  full_geobl.metadata.delete field
107
- expect { full_geobl.valid? }.not_to raise_error
114
+ expect { full_geobl.validate! }.not_to raise_error
108
115
  end
109
116
  end
110
117
  end
@@ -119,31 +126,25 @@ RSpec.describe GeoCombine::Geoblacklight do
119
126
  ].each do |field|
120
127
  it field do
121
128
  full_geobl.metadata.delete field
122
- expect { full_geobl.valid? }.not_to raise_error
129
+ expect { full_geobl.validate! }.not_to raise_error
123
130
  end
124
131
  end
125
132
  end
126
133
 
127
134
  it 'an invalid document' do
128
- expect { basic_geobl.valid? }.to raise_error JSON::Schema::ValidationError
135
+ expect { basic_geobl.validate! }.to raise_error JSON::Schema::ValidationError
129
136
  end
130
137
 
131
138
  it 'calls the dct_references_s validator' do
132
- expect(enhanced_geobl).to receive(:dct_references_validate!)
139
+ expect(enhanced_geobl).to receive(:validate_references!)
133
140
  enhanced_geobl.valid?
134
141
  end
135
-
136
- it 'validates spatial bounding box' do
137
- expect(JSON::Validator).to receive(:validate!).and_return true
138
- expect { basic_geobl.valid? }
139
- .to raise_error GeoCombine::Exceptions::InvalidGeometry
140
- end
141
142
  end
142
143
 
143
- describe '#dct_references_validate!' do
144
+ describe '#validate_references!' do
144
145
  context 'with valid document' do
145
146
  it 'is valid' do
146
- expect(full_geobl.dct_references_validate!).to be true
147
+ expect { full_geobl.validate_references! }.not_to raise_error
147
148
  end
148
149
  end
149
150
 
@@ -173,22 +174,22 @@ RSpec.describe GeoCombine::Geoblacklight do
173
174
  end
174
175
 
175
176
  it 'unparseable json' do
176
- expect { bad_ref.dct_references_validate! }.to raise_error JSON::ParserError
177
+ expect { bad_ref.validate_references! }.to raise_error JSON::ParserError
177
178
  end
178
179
 
179
180
  it 'not a hash' do
180
- expect { not_hash.dct_references_validate! }.to raise_error GeoCombine::Exceptions::InvalidDCTReferences
181
+ expect { not_hash.validate_references! }.to raise_error GeoCombine::Exceptions::InvalidDCTReferences
181
182
  end
182
183
  end
183
184
  end
184
185
 
185
- describe 'spatial_validate!' do
186
+ describe 'validate_spatial!' do
186
187
  context 'when valid' do
187
- it { expect { full_geobl.spatial_validate! }.not_to raise_error }
188
+ it { expect { full_geobl.validate_spatial! }.not_to raise_error }
188
189
  end
189
190
 
190
191
  context 'when invalid' do
191
- it { expect { basic_geobl.spatial_validate! }.to raise_error GeoCombine::Exceptions::InvalidGeometry }
192
+ it { expect { basic_geobl.validate_spatial! }.to raise_error GeoCombine::Exceptions::InvalidGeometry }
192
193
  end
193
194
  end
194
195
 
@@ -5,7 +5,7 @@ require 'geo_combine/harvester'
5
5
  require 'spec_helper'
6
6
 
7
7
  RSpec.describe GeoCombine::Harvester do
8
- subject(:harvester) { described_class.new(ogm_path: 'spec/fixtures/indexing', schema_version: '1.0') }
8
+ subject(:harvester) { described_class.new(ogm_path: 'spec/fixtures/indexing', logger: logger) }
9
9
 
10
10
  let(:logger) { instance_double(Logger, warn: nil, info: nil, error: nil, debug: nil) }
11
11
  let(:repo_name) { 'my-institution' }
@@ -14,11 +14,12 @@ RSpec.describe GeoCombine::Harvester do
14
14
  let(:stub_repo) { instance_double(Git::Base) }
15
15
  let(:stub_gh_api) do
16
16
  [
17
- { name: repo_name, size: 100 },
18
- { name: 'another-institution', size: 100 },
19
- { name: 'outdated-institution', size: 100, archived: true }, # archived
20
- { name: 'aardvark', size: 300 }, # on denylist
21
- { name: 'empty', size: 0 } # no data
17
+ { name: repo_name, size: 100, custom_properties: { supported_schemas: ['Aardvark'] } },
18
+ { name: 'another-institution', size: 100, custom_properties: { supported_schemas: ['Aardvark', '1.0'] } }, # multiple schemas
19
+ { name: 'v1-institution', size: 300, custom_properties: { supported_schemas: ['1.0'] } }, # schema mismatch
20
+ { name: 'outdated-institution', size: 100, custom_properties: { supported_schemas: ['Aardvark'] }, archived: true }, # archived
21
+ { name: 'empty', size: 0, custom_properties: { supported_schemas: ['Aardvark'] } }, # no data
22
+ { name: 'tool', size: 50 } # not a metadata repository
22
23
  ]
23
24
  end
24
25
 
@@ -42,15 +43,15 @@ RSpec.describe GeoCombine::Harvester do
42
43
  describe '#docs_to_index' do
43
44
  it 'yields each JSON record with its path, skipping layers.JSON' do
44
45
  expect { |b| harvester.docs_to_index(&b) }.to yield_successive_args(
45
- [JSON.parse(File.read('spec/fixtures/indexing/basic_geoblacklight.json')), 'spec/fixtures/indexing/basic_geoblacklight.json'],
46
- [JSON.parse(File.read('spec/fixtures/indexing/geoblacklight.json')), 'spec/fixtures/indexing/geoblacklight.json']
46
+ [JSON.parse(File.read('spec/fixtures/indexing/aardvark.json')), 'spec/fixtures/indexing/aardvark.json']
47
47
  )
48
48
  end
49
49
 
50
- it 'skips records with a different schema version' do
51
- harvester = described_class.new(ogm_path: 'spec/fixtures/indexing/', schema_version: 'Aardvark', logger:)
50
+ it 'can yield JSON records for a different schema version' do
51
+ harvester = described_class.new(ogm_path: 'spec/fixtures/indexing/', schema_version: '1.0', logger:)
52
52
  expect { |b| harvester.docs_to_index(&b) }.to yield_successive_args(
53
- [JSON.parse(File.read('spec/fixtures/indexing/aardvark.json')), 'spec/fixtures/indexing/aardvark.json']
53
+ [JSON.parse(File.read('spec/fixtures/indexing/basic_geoblacklight.json')), 'spec/fixtures/indexing/basic_geoblacklight.json'],
54
+ [JSON.parse(File.read('spec/fixtures/indexing/geoblacklight.json')), 'spec/fixtures/indexing/geoblacklight.json']
54
55
  )
55
56
  end
56
57
  end
@@ -79,15 +80,27 @@ RSpec.describe GeoCombine::Harvester do
79
80
  expect(harvester.pull_all).to eq(%w[my-institution another-institution])
80
81
  end
81
82
 
82
- it 'skips repositories in the denylist' do
83
+ it 'skips repositories with no schema declared' do
83
84
  harvester.pull_all
84
- expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/aardvark.git')
85
+ expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/tool.git')
85
86
  end
86
87
 
87
88
  it 'skips archived repositories' do
88
89
  harvester.pull_all
89
90
  expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/outdated-institution.git')
90
91
  end
92
+
93
+ it 'skips repositories with no data' do
94
+ harvester.pull_all
95
+ expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/empty.git')
96
+ end
97
+
98
+ it 'skips repositories that are on the skip list' do
99
+ stub_const('ENV', ENV.to_h.merge('OGM_SKIP_REPOS' => 'my-institution,another-institution'))
100
+ harvester.pull_all
101
+ expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/my-institution.git')
102
+ expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/another-institution.git')
103
+ end
91
104
  end
92
105
 
93
106
  describe '#clone' do
@@ -115,14 +128,31 @@ RSpec.describe GeoCombine::Harvester do
115
128
  expect(Git).to have_received(:clone).exactly(2).times
116
129
  end
117
130
 
118
- it 'skips repositories in the denylist' do
131
+ it 'skips repositories with no schema declared' do
132
+ harvester.clone_all
133
+ expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/tool.git')
134
+ end
135
+
136
+ it 'skips archived repositories' do
119
137
  harvester.clone_all
120
- expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/aardvark.git')
138
+ expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/outdated-institution.git')
139
+ end
140
+
141
+ it 'skips repositories with no data' do
142
+ harvester.clone_all
143
+ expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/empty.git')
121
144
  end
122
145
 
123
146
  it 'returns the names of repositories cloned' do
124
147
  expect(harvester.clone_all).to eq(%w[my-institution another-institution])
125
148
  end
149
+
150
+ it 'skips repositories that are on the skip list' do
151
+ stub_const('ENV', ENV.to_h.merge('OGM_SKIP_REPOS' => 'my-institution,another-institution'))
152
+ harvester.pull_all
153
+ expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/my-institution.git')
154
+ expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/another-institution.git')
155
+ end
126
156
  end
127
157
 
128
158
  describe '#ogm_api_uri' do
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe GeoCombine::Iso19139 do
6
6
  include XmlDocs
7
+
7
8
  let(:iso_object) { described_class.new(stanford_iso) }
8
9
 
9
10
  describe '#initialize' do
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo_combine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Reed
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-13 00:00:00.000000000 Z
10
+ date: 2026-07-07 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -196,30 +195,30 @@ dependencies:
196
195
  name: rubocop
197
196
  requirement: !ruby/object:Gem::Requirement
198
197
  requirements:
199
- - - "~>"
198
+ - - ">="
200
199
  - !ruby/object:Gem::Version
201
- version: '1.25'
200
+ version: '0'
202
201
  type: :development
203
202
  prerelease: false
204
203
  version_requirements: !ruby/object:Gem::Requirement
205
204
  requirements:
206
- - - "~>"
205
+ - - ">="
207
206
  - !ruby/object:Gem::Version
208
- version: '1.25'
207
+ version: '0'
209
208
  - !ruby/object:Gem::Dependency
210
209
  name: rubocop-rspec
211
210
  requirement: !ruby/object:Gem::Requirement
212
211
  requirements:
213
- - - "~>"
212
+ - - ">="
214
213
  - !ruby/object:Gem::Version
215
- version: '2.8'
214
+ version: '0'
216
215
  type: :development
217
216
  prerelease: false
218
217
  version_requirements: !ruby/object:Gem::Requirement
219
218
  requirements:
220
- - - "~>"
219
+ - - ">="
221
220
  - !ruby/object:Gem::Version
222
- version: '2.8'
221
+ version: '0'
223
222
  - !ruby/object:Gem::Dependency
224
223
  name: rubocop-rake
225
224
  requirement: !ruby/object:Gem::Requirement
@@ -269,6 +268,7 @@ executables: []
269
268
  extensions: []
270
269
  extra_rdoc_files: []
271
270
  files:
271
+ - ".github/dependabot.yml"
272
272
  - ".github/workflows/ruby.yml"
273
273
  - ".gitignore"
274
274
  - ".rspec"
@@ -279,6 +279,7 @@ files:
279
279
  - README.md
280
280
  - Rakefile
281
281
  - geo_combine.gemspec
282
+ - lib/.DS_Store
282
283
  - lib/geo_combine.rb
283
284
  - lib/geo_combine/bounding_box.rb
284
285
  - lib/geo_combine/ckan_metadata.rb
@@ -304,6 +305,7 @@ files:
304
305
  - lib/xslt/fgdc2html.xsl
305
306
  - lib/xslt/iso2geoBL.xsl
306
307
  - lib/xslt/iso2html.xsl
308
+ - lib/xslt/isoAardvark.xsl
307
309
  - lib/xslt/utils/convert-enumerations.xsl
308
310
  - lib/xslt/utils/convert-latlong.xsl
309
311
  - lib/xslt/utils/decode-uri/base.css
@@ -361,7 +363,6 @@ homepage: ''
361
363
  licenses:
362
364
  - Apache
363
365
  metadata: {}
364
- post_install_message:
365
366
  rdoc_options: []
366
367
  require_paths:
367
368
  - lib
@@ -376,8 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
377
  - !ruby/object:Gem::Version
377
378
  version: '0'
378
379
  requirements: []
379
- rubygems_version: 3.4.19
380
- signing_key:
380
+ rubygems_version: 3.6.2
381
381
  specification_version: 4
382
382
  summary: A Ruby toolkit for managing geospatial metadata
383
383
  test_files: