geo_concerns 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +101 -0
- data/.travis.yml +17 -0
- data/Gemfile +46 -0
- data/LICENSE +202 -0
- data/README.md +46 -0
- data/Rakefile +21 -0
- data/app/actors/geo_concerns/file_actor.rb +20 -0
- data/app/actors/geo_concerns/file_set_actor.rb +7 -0
- data/app/assets/images/geo_concerns/.keep +0 -0
- data/app/assets/images/geo_concerns/images/geocoder.png +0 -0
- data/app/assets/images/geo_concerns/images/throbber.gif +0 -0
- data/app/assets/images/geo_concerns/img/filter-icon.png +0 -0
- data/app/assets/images/geo_concerns/img/move-handle.png +0 -0
- data/app/assets/images/geo_concerns/img/resize-handle.png +0 -0
- data/app/assets/javascripts/geo_concerns/Control.Geocoder.js +1056 -0
- data/app/assets/javascripts/geo_concerns/application.js +5 -0
- data/app/assets/javascripts/geo_concerns/bounding_box_selector.js +100 -0
- data/app/assets/javascripts/geo_concerns/leaflet-boundingbox.js +467 -0
- data/app/assets/stylesheets/geo_concerns/Control.Geocoder.css +104 -0
- data/app/assets/stylesheets/geo_concerns/application.css +18 -0
- data/app/assets/stylesheets/geo_concerns/bounding_box.scss +7 -0
- data/app/assets/stylesheets/geo_concerns/leaflet-boundingbox.css +17 -0
- data/app/controllers/concerns/geo_concerns/file_sets_controller_behavior.rb +19 -0
- data/app/controllers/concerns/geo_concerns/image_works_controller_behavior.rb +13 -0
- data/app/controllers/concerns/geo_concerns/raster_works_controller_behavior.rb +23 -0
- data/app/controllers/concerns/geo_concerns/vector_works_controller_behavior.rb +23 -0
- data/app/forms/geo_concerns/basic_geo_metadata_form.rb +8 -0
- data/app/forms/geo_concerns/external_metadata_file_form.rb +8 -0
- data/app/forms/geo_concerns/georeferenced_form.rb +9 -0
- data/app/forms/geo_concerns/image_work_form.rb +9 -0
- data/app/forms/geo_concerns/raster_work_form.rb +8 -0
- data/app/forms/geo_concerns/vector_work_form.rb +8 -0
- data/app/helpers/bounding_box_helper.rb +24 -0
- data/app/helpers/geo_concerns/application_helper.rb +4 -0
- data/app/models/concerns/geo_concerns/basic_geo_metadata.rb +21 -0
- data/app/models/concerns/geo_concerns/external_metadata_file_behavior.rb +31 -0
- data/app/models/concerns/geo_concerns/extractors/fgdc_helper.rb +9 -0
- data/app/models/concerns/geo_concerns/extractors/fgdc_metadata_extractor.rb +114 -0
- data/app/models/concerns/geo_concerns/extractors/iso19139_helper.rb +50 -0
- data/app/models/concerns/geo_concerns/extractors/mods_helper.rb +15 -0
- data/app/models/concerns/geo_concerns/file_set/derivatives.rb +60 -0
- data/app/models/concerns/geo_concerns/file_set_presenter_behavior.rb +7 -0
- data/app/models/concerns/geo_concerns/geo_file_format_behavior.rb +37 -0
- data/app/models/concerns/geo_concerns/geo_file_set_behavior.rb +11 -0
- data/app/models/concerns/geo_concerns/georeferenced_behavior.rb +18 -0
- data/app/models/concerns/geo_concerns/image_file_behavior.rb +14 -0
- data/app/models/concerns/geo_concerns/image_work_behavior.rb +69 -0
- data/app/models/concerns/geo_concerns/metadata_extraction_helper.rb +28 -0
- data/app/models/concerns/geo_concerns/raster_file_behavior.rb +14 -0
- data/app/models/concerns/geo_concerns/raster_work_behavior.rb +82 -0
- data/app/models/concerns/geo_concerns/solr_document_behavior.rb +25 -0
- data/app/models/concerns/geo_concerns/vector_file_behavior.rb +14 -0
- data/app/models/concerns/geo_concerns/vector_work_behavior.rb +78 -0
- data/app/presenters/geo_concerns/geo_concerns_show_presenter.rb +30 -0
- data/app/presenters/geo_concerns/image_work_show_presenter.rb +18 -0
- data/app/presenters/geo_concerns/raster_work_show_presenter.rb +18 -0
- data/app/presenters/geo_concerns/vector_work_show_presenter.rb +10 -0
- data/app/processors/geo_concerns/processors/base_geo_processor.rb +86 -0
- data/app/processors/geo_concerns/processors/raster.rb +11 -0
- data/app/processors/geo_concerns/processors/raster/aig.rb +44 -0
- data/app/processors/geo_concerns/processors/raster/base.rb +74 -0
- data/app/processors/geo_concerns/processors/raster/dem.rb +46 -0
- data/app/processors/geo_concerns/processors/raster/processor.rb +27 -0
- data/app/processors/geo_concerns/processors/vector.rb +11 -0
- data/app/processors/geo_concerns/processors/vector/base.rb +68 -0
- data/app/processors/geo_concerns/processors/vector/processor.rb +25 -0
- data/app/processors/geo_concerns/processors/vector/shapefile.rb +20 -0
- data/app/processors/geo_concerns/processors/zip.rb +31 -0
- data/app/renderers/coverage_renderer.rb +34 -0
- data/app/runners/geo_concerns/runners/raster_derivatives.rb +9 -0
- data/app/runners/geo_concerns/runners/vector_derivatives.rb +9 -0
- data/app/schemas/geo_concerns/basic_geo_metadata_optional.rb +39 -0
- data/app/schemas/geo_concerns/basic_geo_metadata_required.rb +25 -0
- data/app/services/authority_service.rb +23 -0
- data/app/services/geo_concerns/derivative_path.rb +16 -0
- data/app/services/image_format_service.rb +4 -0
- data/app/services/metadata_format_service.rb +4 -0
- data/app/services/raster_format_service.rb +4 -0
- data/app/services/vector_format_service.rb +4 -0
- data/app/values/geo_concerns/coverage.rb +36 -0
- data/app/values/geo_concerns/time_period.rb +31 -0
- data/app/views/curation_concerns/file_sets/_form.html.erb +48 -0
- data/app/views/curation_concerns/image_works/_form.html.erb +23 -0
- data/app/views/curation_concerns/image_works/_image_work.html.erb +2 -0
- data/app/views/curation_concerns/image_works/_members.html.erb +30 -0
- data/app/views/curation_concerns/image_works/_related_image_files.html.erb +24 -0
- data/app/views/curation_concerns/image_works/_show_actions.html.erb +16 -0
- data/app/views/curation_concerns/image_works/show.html.erb +17 -0
- data/app/views/curation_concerns/raster_works/_form.html.erb +25 -0
- data/app/views/curation_concerns/raster_works/_members.html.erb +30 -0
- data/app/views/curation_concerns/raster_works/_raster_work.html.erb +2 -0
- data/app/views/curation_concerns/raster_works/_related_raster_files.html.erb +24 -0
- data/app/views/curation_concerns/raster_works/_show_actions.html.erb +16 -0
- data/app/views/curation_concerns/raster_works/show.html.erb +17 -0
- data/app/views/curation_concerns/vector_works/_form.html.erb +25 -0
- data/app/views/curation_concerns/vector_works/_related_vector_files.html.erb +24 -0
- data/app/views/curation_concerns/vector_works/_show_actions.html.erb +15 -0
- data/app/views/curation_concerns/vector_works/_vector_work.html.erb +2 -0
- data/app/views/curation_concerns/vector_works/show.html.erb +15 -0
- data/app/views/geo_concerns/_attribute_rows.html.erb +11 -0
- data/app/views/geo_concerns/_attributes.html.erb +13 -0
- data/app/views/geo_concerns/_form_additional_information.html.erb +11 -0
- data/app/views/geo_concerns/_form_bounding_box.html.erb +9 -0
- data/app/views/geo_concerns/_form_descriptive_fields.html.erb +9 -0
- data/app/views/geo_concerns/_form_files_and_links.html.erb +0 -0
- data/app/views/geo_concerns/_form_populate_metadata.html.erb +8 -0
- data/app/views/geo_concerns/_form_required_information.html.erb +12 -0
- data/app/views/geo_concerns/_form_supplementary_fields.html.erb +15 -0
- data/app/views/geo_concerns/_related_external_metadata_files.html.erb +24 -0
- data/app/vocabs/geo_concerns/geo_terms.rb +12 -0
- data/bin/rails +12 -0
- data/config/routes.rb +6 -0
- data/geo_concerns.gemspec +36 -0
- data/lib/generators/geo_concerns/install_generator.rb +119 -0
- data/lib/generators/geo_concerns/templates/actors/curation_concerns/image_work_actor.rb +4 -0
- data/lib/generators/geo_concerns/templates/actors/curation_concerns/raster_work_actor.rb +4 -0
- data/lib/generators/geo_concerns/templates/actors/curation_concerns/vector_work_actor.rb +4 -0
- data/lib/generators/geo_concerns/templates/config/authorities/image_formats.yml +5 -0
- data/lib/generators/geo_concerns/templates/config/authorities/metadata_formats.yml +7 -0
- data/lib/generators/geo_concerns/templates/config/authorities/raster_formats.yml +9 -0
- data/lib/generators/geo_concerns/templates/config/authorities/vector_formats.yml +5 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/file_sets_controller.rb +6 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/image_works_controller.rb +5 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/raster_works_controller.rb +6 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/vector_works_controller.rb +6 -0
- data/lib/generators/geo_concerns/templates/geo_concerns.js +1 -0
- data/lib/generators/geo_concerns/templates/geo_concerns.scss +3 -0
- data/lib/generators/geo_concerns/templates/jobs/characterize_job.rb +12 -0
- data/lib/generators/geo_concerns/templates/models/file_set.rb +4 -0
- data/lib/generators/geo_concerns/templates/models/image_work.rb +6 -0
- data/lib/generators/geo_concerns/templates/models/raster_work.rb +7 -0
- data/lib/generators/geo_concerns/templates/models/vector_work.rb +7 -0
- data/lib/generators/geo_concerns/templates/presenters/file_set_presenter.rb +3 -0
- data/lib/generators/geo_concerns/templates/spec/actor_spec.rb.erb +9 -0
- data/lib/generators/geo_concerns/templates/spec/controller_spec.rb.erb +9 -0
- data/lib/generators/geo_concerns/templates/spec/model_spec.rb.erb +9 -0
- data/lib/geo_concerns.rb +6 -0
- data/lib/geo_concerns/engine.rb +4 -0
- data/lib/geo_concerns/version.rb +3 -0
- data/lib/tasks/geo_concerns_tasks.rake +4 -0
- data/solr/config/_rest_managed.json +3 -0
- data/solr/config/admin-extra.html +31 -0
- data/solr/config/elevate.xml +36 -0
- data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
- data/solr/config/protwords.txt +21 -0
- data/solr/config/schema.xml +372 -0
- data/solr/config/scripts.conf +24 -0
- data/solr/config/solrconfig.xml +312 -0
- data/solr/config/spellings.txt +2 -0
- data/solr/config/stopwords.txt +58 -0
- data/solr/config/stopwords_en.txt +58 -0
- data/solr/config/synonyms.txt +31 -0
- data/solr/config/xslt/example.xsl +132 -0
- data/solr/config/xslt/example_atom.xsl +67 -0
- data/solr/config/xslt/example_rss.xsl +66 -0
- data/solr/config/xslt/luke.xsl +337 -0
- data/spec/actors/geo_concerns/file_actor_spec.rb +26 -0
- data/spec/controllers/image_works_controller_spec.rb +25 -0
- data/spec/controllers/raster_works_controller_spec.rb +50 -0
- data/spec/controllers/vector_works_controller_spec.rb +50 -0
- data/spec/factories/external_metadata_files.rb +20 -0
- data/spec/factories/image_files.rb +32 -0
- data/spec/factories/image_works.rb +68 -0
- data/spec/factories/raster_files.rb +35 -0
- data/spec/factories/raster_works.rb +86 -0
- data/spec/factories/users.rb +26 -0
- data/spec/factories/vector_files.rb +31 -0
- data/spec/factories/vector_works.rb +83 -0
- data/spec/features/create_raster_work_spec.rb +49 -0
- data/spec/forms/geo_concerns/basic_geo_metadata_form_spec.rb +27 -0
- data/spec/forms/geo_concerns/external_metadata_file_form_spec.rb +27 -0
- data/spec/forms/geo_concerns/georeferenced_form_spec.rb +29 -0
- data/spec/forms/geo_concerns/image_work_form_spec.rb +11 -0
- data/spec/forms/geo_concerns/raster_work_form_spec.rb +15 -0
- data/spec/forms/geo_concerns/vector_work_form_spec.rb +15 -0
- data/spec/helpers/bounding_box_helper_spec.rb +34 -0
- data/spec/models/concerns/basic_geo_metadata_spec.rb +21 -0
- data/spec/models/concerns/geo_concerns/file_set/derivatives_spec.rb +108 -0
- data/spec/models/concerns/geo_concerns/file_set/geo_file_format_behavior_spec.rb +56 -0
- data/spec/models/external_metadata_file_spec.rb +118 -0
- data/spec/models/file_set_spec.rb +9 -0
- data/spec/models/image_file_spec.rb +48 -0
- data/spec/models/image_work_spec.rb +71 -0
- data/spec/models/raster_file_spec.rb +48 -0
- data/spec/models/raster_work_spec.rb +122 -0
- data/spec/models/solr_document_spec.rb +35 -0
- data/spec/models/vector_file_spec.rb +48 -0
- data/spec/models/vector_work_spec.rb +113 -0
- data/spec/presenters/file_set_presenter_spec.rb +13 -0
- data/spec/presenters/geo_concerns_show_presenter_spec.rb +56 -0
- data/spec/presenters/image_work_show_presenter_spec.rb +52 -0
- data/spec/presenters/raster_work_show_presenter_spec.rb +52 -0
- data/spec/presenters/vector_work_show_presenter_spec.rb +41 -0
- data/spec/processors/geo_concerns/processors/base_geo_processor_spec.rb +109 -0
- data/spec/processors/geo_concerns/processors/raster/aig_spec.rb +28 -0
- data/spec/processors/geo_concerns/processors/raster/base_spec.rb +86 -0
- data/spec/processors/geo_concerns/processors/raster/dem_spec.rb +26 -0
- data/spec/processors/geo_concerns/processors/raster/processor_spec.rb +39 -0
- data/spec/processors/geo_concerns/processors/vector/base_spec.rb +67 -0
- data/spec/processors/geo_concerns/processors/vector/processor_spec.rb +28 -0
- data/spec/processors/geo_concerns/processors/vector/shapefile_spec.rb +17 -0
- data/spec/processors/geo_concerns/processors/zip_spec.rb +39 -0
- data/spec/renderers/coverage_renderer_spec.rb +21 -0
- data/spec/services/derivative_path_spec.rb +12 -0
- data/spec/services/raster_format_service_spec.rb +13 -0
- data/spec/spec_helper.rb +34 -0
- data/spec/support/controllers/engine_helpers.rb +7 -0
- data/spec/support/database_cleaner.rb +18 -0
- data/spec/support/devise.rb +10 -0
- data/spec/support/devise_helpers.rb +6 -0
- data/spec/support/factory_girl.rb +3 -0
- data/spec/support/features.rb +14 -0
- data/spec/support/features/session_helpers.rb +40 -0
- data/spec/support/fixture_reader.rb +7 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +20 -0
- data/spec/values/coverage_spec.rb +40 -0
- data/tasks/ci.rake +49 -0
- metadata +527 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FileSet do
|
4
|
+
let(:user) { create(:user) }
|
5
|
+
subject { described_class.new(mime_type: 'application/zip; ogr-format="ESRI Shapefile"') }
|
6
|
+
|
7
|
+
context "when mime_type is a vector format" do
|
8
|
+
it "responds as a vector file" do
|
9
|
+
expect(subject.vector_file?).to be_truthy
|
10
|
+
end
|
11
|
+
it "doesn't respond as a raster file" do
|
12
|
+
expect(subject.raster_file?).to be_falsey
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'vector work association' do
|
17
|
+
let(:work) { FactoryGirl.create(:vector_work_with_one_file) }
|
18
|
+
subject { work.file_sets.first.reload }
|
19
|
+
it 'belongs to vector work' do
|
20
|
+
expect(subject.vector_work).to eq [work]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "to_solr" do
|
25
|
+
let(:solr_doc) { FactoryGirl.build(:vector_file,
|
26
|
+
date_uploaded: Time.zone.today,
|
27
|
+
cartographic_projection: 'urn:ogc:def:crs:EPSG::6326').to_solr
|
28
|
+
}
|
29
|
+
|
30
|
+
it "indexes the coordinate reference system" do
|
31
|
+
expect(solr_doc.keys).to include 'cartographic_projection_tesim'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'metadata' do
|
36
|
+
it 'has descriptive metadata' do
|
37
|
+
expect(subject).to respond_to(:title)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has an authoritative cartographic projection' do
|
41
|
+
expect(subject).to respond_to(:cartographic_projection)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'has standard' do
|
45
|
+
expect(subject).to respond_to(:mime_type)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VectorWork do
|
4
|
+
let(:user) { FactoryGirl.find_or_create(:jill) }
|
5
|
+
let(:vector_file1) { FileSet.new(mime_type: 'application/zip; ogr-format="ESRI Shapefile"') }
|
6
|
+
let(:vector_file2) { FileSet.new(mime_type: 'application/zip; ogr-format="ESRI Shapefile"') }
|
7
|
+
let(:ext_metadata_file1) { FileSet.new(mime_type: 'application/xml; schema=iso19139') }
|
8
|
+
let(:ext_metadata_file2) { FileSet.new(mime_type: 'application/xml; schema=iso19139') }
|
9
|
+
let(:coverage) { GeoConcerns::Coverage.new(43.039, -69.856, 42.943, -71.032) }
|
10
|
+
|
11
|
+
describe 'with acceptable inputs' do
|
12
|
+
subject { described_class.new }
|
13
|
+
it 'adds vector file set and metadatato file set' do
|
14
|
+
subject.members << vector_file1
|
15
|
+
subject.members << vector_file2
|
16
|
+
subject.members << ext_metadata_file1
|
17
|
+
subject.members << ext_metadata_file2
|
18
|
+
expect(subject.vector_files).to eq [vector_file1, vector_file2]
|
19
|
+
expect(subject.metadata_files).to eq [ext_metadata_file1, ext_metadata_file2]
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'defines what type of object it is' do
|
23
|
+
expect(subject.vector_work?).to be_truthy
|
24
|
+
expect(subject.vector_file?).to be_falsey
|
25
|
+
expect(subject.image_work?).to be_falsey
|
26
|
+
expect(subject.image_file?).to be_falsey
|
27
|
+
expect(subject.raster_work?).to be_falsey
|
28
|
+
expect(subject.raster_file?).to be_falsey
|
29
|
+
expect(subject.external_metadata_file?).to be_falsey
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'updates the title' do
|
34
|
+
subject.attributes = { title: ['A vector work'] }
|
35
|
+
expect(subject.title).to eq(['A vector work'])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'updates the coverage' do
|
39
|
+
subject.attributes = { coverage: coverage.to_s }
|
40
|
+
expect(subject.coverage).to eq(coverage.to_s)
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'metadata' do
|
44
|
+
it 'has descriptive metadata' do
|
45
|
+
expect(subject).to respond_to(:title)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'has geospatial metadata' do
|
49
|
+
expect(subject).to respond_to(:coverage)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with files' do
|
54
|
+
subject { FactoryGirl.create(:vector_work_with_files, title: ['Test title 4'], coverage: coverage.to_s) }
|
55
|
+
|
56
|
+
it 'has two files' do
|
57
|
+
expect(subject.vector_files.size).to eq 2
|
58
|
+
expect(subject.vector_files.first.mime_type).to eq 'application/zip; ogr-format="ESRI Shapefile"'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with metadata files' do
|
63
|
+
subject { FactoryGirl.create(:vector_work_with_metadata_files) }
|
64
|
+
|
65
|
+
it 'aggregates external metadata files' do
|
66
|
+
expect(subject.metadata_files.size).to eq 2
|
67
|
+
expect(subject.metadata_files.first.mime_type).to eq 'application/xml; schema=iso19139'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#raster_work' do
|
72
|
+
let(:vector_work) { FactoryGirl.create(:vector_work, title: ['Vector'], coverage: coverage.to_s) }
|
73
|
+
let(:raster_work) { FactoryGirl.create(:raster_work, title: ['Raster'], coverage: coverage.to_s) }
|
74
|
+
|
75
|
+
before do
|
76
|
+
raster_work.ordered_members << vector_work
|
77
|
+
vector_work.save
|
78
|
+
raster_work.save
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'has a parent image work' do
|
82
|
+
expect(vector_work.raster_work).to be_a RasterWork
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "to_solr" do
|
87
|
+
subject { FactoryGirl.build(:vector_work, date_uploaded: Time.zone.today, coverage: coverage.to_s).to_solr }
|
88
|
+
it "indexes ordered_by_ssim field" do
|
89
|
+
expect(subject.keys).to include 'ordered_by_ssim'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'populate_metadata' do
|
94
|
+
subject { FactoryGirl.create(:vector_work_with_one_metadata_file) }
|
95
|
+
let(:doc) { Nokogiri::XML(read_test_data_fixture('McKay/S_566_1914_clip_iso.xml')) }
|
96
|
+
|
97
|
+
it 'has an extraction method' do
|
98
|
+
expect(subject).to respond_to(:extract_metadata)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'can perform extraction and set for ISO 19139' do
|
102
|
+
external_metadata_file = subject.metadata_files.first
|
103
|
+
allow(external_metadata_file).to receive(:metadata_xml) { doc }
|
104
|
+
allow(external_metadata_file).to receive(:mime_type) { 'application/xml; schema=iso19139' }
|
105
|
+
subject.populate_metadata
|
106
|
+
expect(subject.title).to eq(['S_566_1914_clip.tif'])
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'will fail if there are multiple metadata files' do
|
110
|
+
expect { FactoryGirl.create(:vector_work_with_metadata_files).extract_metadata }.to raise_error(NotImplementedError)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe FileSetPresenter do
|
4
|
+
let(:ability) { nil }
|
5
|
+
let(:solr_document) { SolrDocument.new }
|
6
|
+
subject { described_class.new(solr_document, ability) }
|
7
|
+
|
8
|
+
describe "#label" do
|
9
|
+
it "returns nil" do
|
10
|
+
expect(subject.label).to be_nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ::GeoConcerns::GeoConcernsShowPresenter do
|
4
|
+
let(:solr_document) { SolrDocument.new(attributes) }
|
5
|
+
let(:ability) { nil }
|
6
|
+
|
7
|
+
describe "delegated methods" do
|
8
|
+
let(:attributes) { { "mime_type_ssi" => ['image/tiff; gdal-format=GTiff'] } }
|
9
|
+
subject { described_class.new(solr_document, ability) }
|
10
|
+
|
11
|
+
describe "#first" do
|
12
|
+
it "delegates to solr document" do
|
13
|
+
expect(subject.first('mime_type_ssi')).to eq('image/tiff; gdal-format=GTiff')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#has?" do
|
18
|
+
it "delegates to solr document" do
|
19
|
+
expect(subject.has?('mime_type_ssi')).to be_truthy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#external_metadata_file_formats_presenters" do
|
25
|
+
let(:obj) { FactoryGirl.create(:raster_work_with_metadata_files) }
|
26
|
+
let(:attributes) { obj.to_solr }
|
27
|
+
subject { described_class.new(solr_document, ability) }
|
28
|
+
|
29
|
+
it "returns external_metadata_file_formats_presenters" do
|
30
|
+
expect(subject.external_metadata_file_formats_presenters.count).to eq 2
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#attribute_to_html" do
|
35
|
+
let(:attributes) { FactoryGirl.create(:raster_work).to_solr }
|
36
|
+
let(:attribute_renderer) { double('attribute_renderer') }
|
37
|
+
let(:coverage_renderer) { double('coverage_renderer') }
|
38
|
+
|
39
|
+
subject { described_class.new(solr_document, ability) }
|
40
|
+
|
41
|
+
before do
|
42
|
+
allow(CurationConcerns::AttributeRenderer).to receive(:new).and_return(attribute_renderer)
|
43
|
+
allow(CoverageRenderer).to receive(:new).and_return(coverage_renderer)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "uses a CoverageRenderer when the field is coverage" do
|
47
|
+
expect(coverage_renderer).to receive(:render)
|
48
|
+
subject.attribute_to_html(:coverage)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "uses an AttributeRenderer when the field is not coverage" do
|
52
|
+
expect(attribute_renderer).to receive(:render)
|
53
|
+
subject.attribute_to_html(:language)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe GeoConcerns::ImageWorkShowPresenter do
|
4
|
+
let(:solr_document) { SolrDocument.new(attributes) }
|
5
|
+
let(:ability) { nil }
|
6
|
+
|
7
|
+
describe "delegated methods" do
|
8
|
+
let(:attributes) { { "mime_type_ssi" => ['image/tiff'] } }
|
9
|
+
subject { described_class.new(solr_document, ability) }
|
10
|
+
|
11
|
+
describe "#first" do
|
12
|
+
it "delegates to solr document" do
|
13
|
+
expect(subject.first('mime_type_ssi')).to eq('image/tiff')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#has?" do
|
18
|
+
it "delegates to solr document" do
|
19
|
+
expect(subject.has?('mime_type_ssi')).to be_truthy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#raster_work_presenters" do
|
25
|
+
let(:obj) { FactoryGirl.create(:image_work_with_raster_works) }
|
26
|
+
let(:attributes) { obj.to_solr }
|
27
|
+
subject { described_class.new(solr_document, ability) }
|
28
|
+
|
29
|
+
it "returns raster work presenters" do
|
30
|
+
expect(subject.raster_work_presenters.count).to eq 2
|
31
|
+
expect(subject.raster_work_presenters.first.first('has_model_ssim')).to eq "RasterWork"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "file presenters" do
|
36
|
+
let(:obj) { FactoryGirl.create(:image_work_with_files_and_metadata_files) }
|
37
|
+
let(:attributes) { obj.to_solr }
|
38
|
+
subject { described_class.new(solr_document, ability) }
|
39
|
+
|
40
|
+
describe "#image_file_presenters" do
|
41
|
+
it "returns only raster_file_presenters file presenters" do
|
42
|
+
expect(subject.image_file_presenters.count).to eq 2
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#external_metadata_file_formats_presenters" do
|
47
|
+
it "returns only external_metadata_file_formats_presenters" do
|
48
|
+
expect(subject.external_metadata_file_formats_presenters.count).to eq 2
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe GeoConcerns::RasterWorkShowPresenter do
|
4
|
+
let(:solr_document) { SolrDocument.new(attributes) }
|
5
|
+
let(:ability) { nil }
|
6
|
+
|
7
|
+
describe "delegated methods" do
|
8
|
+
let(:attributes) { { "mime_type_ssi" => ['image/tiff; gdal-format=GTiff'] } }
|
9
|
+
subject { described_class.new(solr_document, ability) }
|
10
|
+
|
11
|
+
describe "#first" do
|
12
|
+
it "delegates to solr document" do
|
13
|
+
expect(subject.first('mime_type_ssi')).to eq('image/tiff; gdal-format=GTiff')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#has?" do
|
18
|
+
it "delegates to solr document" do
|
19
|
+
expect(subject.has?('mime_type_ssi')).to be_truthy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#vector_work_presenters" do
|
25
|
+
let(:obj) { FactoryGirl.create(:raster_work_with_vector_works) }
|
26
|
+
let(:attributes) { obj.to_solr }
|
27
|
+
subject { described_class.new(solr_document, ability) }
|
28
|
+
|
29
|
+
it "returns vector work presenters" do
|
30
|
+
expect(subject.vector_work_presenters.count).to eq 2
|
31
|
+
expect(subject.vector_work_presenters.first.first('has_model_ssim')).to eq "VectorWork"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "file presenters" do
|
36
|
+
let(:obj) { FactoryGirl.create(:raster_work_with_files_and_metadata_files) }
|
37
|
+
let(:attributes) { obj.to_solr }
|
38
|
+
subject { described_class.new(solr_document, ability) }
|
39
|
+
|
40
|
+
describe "#raster_file_presenters" do
|
41
|
+
it "returns only raster_file_presenters file presenters" do
|
42
|
+
expect(subject.raster_file_presenters.count).to eq 2
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#external_metadata_file_formats_presenters" do
|
47
|
+
it "returns only external_metadata_file_formats_presenters" do
|
48
|
+
expect(subject.external_metadata_file_formats_presenters.count).to eq 2
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ::GeoConcerns::VectorWorkShowPresenter do
|
4
|
+
let(:solr_document) { SolrDocument.new(attributes) }
|
5
|
+
let(:ability) { nil }
|
6
|
+
|
7
|
+
describe "delegated methods" do
|
8
|
+
let(:attributes) { { "mime_type_ssi" => ['application/zip; ogr-format="ESRI Shapefile"'] } }
|
9
|
+
subject { described_class.new(solr_document, ability) }
|
10
|
+
|
11
|
+
describe "#first" do
|
12
|
+
it "delegates to solr document" do
|
13
|
+
expect(subject.first('mime_type_ssi')).to eq('application/zip; ogr-format="ESRI Shapefile"')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#has?" do
|
18
|
+
it "delegates to solr document" do
|
19
|
+
expect(subject.has?('mime_type_ssi')).to be_truthy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "file presenters" do
|
25
|
+
let(:obj) { FactoryGirl.create(:vector_work_with_vector_and_metadata_files) }
|
26
|
+
let(:attributes) { obj.to_solr }
|
27
|
+
subject { described_class.new(solr_document, ability) }
|
28
|
+
|
29
|
+
describe "#vector_file_presenters" do
|
30
|
+
it "returns only vector file presenters" do
|
31
|
+
expect(subject.vector_file_presenters.count).to eq 2
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#external_metadata_file_formats_presenters" do
|
36
|
+
it "returns only external_metadata_file_formats_presenters" do
|
37
|
+
expect(subject.external_metadata_file_formats_presenters.count).to eq 2
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoConcerns::Processors::BaseGeoProcessor do
|
4
|
+
before do
|
5
|
+
class TestProcessor
|
6
|
+
include GeoConcerns::Processors::BaseGeoProcessor
|
7
|
+
def directives
|
8
|
+
end
|
9
|
+
|
10
|
+
def source_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
allow(subject).to receive(:directives).and_return(directives)
|
15
|
+
allow(subject).to receive(:source_path).and_return(file_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
after { Object.send(:remove_const, :TestProcessor) }
|
19
|
+
|
20
|
+
subject { TestProcessor.new }
|
21
|
+
|
22
|
+
let(:directives) { { format: 'png', size: '200x400' } }
|
23
|
+
let(:output_file) { 'output/geo.png' }
|
24
|
+
let(:file_name) { 'files/geo.tif' }
|
25
|
+
let(:options) { { output_format: 'PNG', output_size: '150 150' } }
|
26
|
+
|
27
|
+
describe '#translate' do
|
28
|
+
it 'returns a gdal_translate command ' do
|
29
|
+
expect(subject.class.translate(file_name, options, output_file))
|
30
|
+
.to include('gdal_translate')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#intermediate_file_path' do
|
35
|
+
it 'returns a path to a temporary file based on the input file' do
|
36
|
+
expect(subject.class.intermediate_file_path(output_file))
|
37
|
+
.to include('geo_temp.png')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#label' do
|
42
|
+
context 'when directives hash has a label value' do
|
43
|
+
let(:directives) { { label: :thumbnail } }
|
44
|
+
it 'returns the label' do
|
45
|
+
expect(subject.label).to eq(:thumbnail)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when directives hash does not have label value' do
|
50
|
+
it 'returns an empty string' do
|
51
|
+
expect(subject.label).to eq('')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#output_format' do
|
57
|
+
context 'when given jpg as a format' do
|
58
|
+
let(:directives) { { format: 'jpg' } }
|
59
|
+
it 'returns JPEG' do
|
60
|
+
expect(subject.output_format).to eq('JPEG')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when given png as a format' do
|
65
|
+
it 'returns PNG' do
|
66
|
+
expect(subject.output_format).to eq('PNG')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#output_size' do
|
72
|
+
context 'when given a size string with an x' do
|
73
|
+
it 'returns a size string with a space instead' do
|
74
|
+
expect(subject.output_size).to eq('200 400')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#output_srid' do
|
80
|
+
context 'when directives hash has an srid value' do
|
81
|
+
let(:directives) { { srid: 'EPSG:26918' } }
|
82
|
+
it 'returns that value' do
|
83
|
+
expect(subject.output_srid).to eq('EPSG:26918')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when directives hash does not have an srid value' do
|
88
|
+
it 'returns that the default srid' do
|
89
|
+
expect(subject.output_srid).to eq('EPSG:4326')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#basename' do
|
95
|
+
it 'returns the base file name of the source file' do
|
96
|
+
expect(subject.basename).to eq('geo')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#options_for' do
|
101
|
+
it 'returns a hash that includes output size and format' do
|
102
|
+
expect(subject.options_for("a")).to include(:output_format,
|
103
|
+
:output_size,
|
104
|
+
:label,
|
105
|
+
:output_srid,
|
106
|
+
:basename)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|