geo_concerns 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34af069d1dd402d1592d5e24933df3362ad4bd4d
4
- data.tar.gz: c04fb982ce925417ebeddaedbcc5052eb5ea064d
3
+ metadata.gz: 7859ed88c8abf63d62c3f01656c86bef9100759a
4
+ data.tar.gz: 9d9b2132b6e5497633bc66604656917fe6cf801b
5
5
  SHA512:
6
- metadata.gz: 0dc13d96992a96f8d02ba4da85d00884c30e10e4d5c1f81fe507d235219f0d9d5556732212bfea956cc68696c412d9a17e0ca841bf14cc00e2ffab95b9591591
7
- data.tar.gz: a33e2ed33523ebb633749a2bfe2056f9bbb8225b3d26c69580c3789044d2cacf332e693ee27a454b386fcbf7ab66c8a218fdfb75d24182803dce8b5fccddb497
6
+ metadata.gz: 9396b438f6ee45eef45ecd87b180e54f66e4a23bc83297c27dad047f4065eede959f5870c84ae94adff9529c3a13d6242067be951cbc1ccef497921618d83efb
7
+ data.tar.gz: a21f787e7a4762b5aeab53a76386975a6f92170a2b55dec1e2537438cb5466df028e9ddbf4856dc3eff3da6c51b5eafa7186910d9528bce9a9a60e8c218ec468
data/.travis.yml CHANGED
@@ -18,6 +18,7 @@ before_install:
18
18
  - sudo apt-add-repository --yes ppa:mapnik/nightly-${MAPNIK_VERSION}
19
19
  - sudo apt-get update -y
20
20
  - sudo apt-get -y install libmapnik=${MAPNIK_VERSION}* mapnik-utils=${MAPNIK_VERSION}* libmapnik-dev=${MAPNIK_VERSION}* mapnik-input-plugin*=${MAPNIK_VERSION}*
21
+ - gem install bundler -v 1.13.1 # hopefully temporary
21
22
  install: bundle install --jobs=3 --retry=3
22
23
  before_script:
23
24
  - gdalinfo --version
data/README.md CHANGED
@@ -21,6 +21,7 @@ Rails application for developing Hydra Geo models. Built around Curation Concern
21
21
  1. [GDAL](http://www.gdal.org/)
22
22
  * You can install it on Mac OSX with `brew install gdal`.
23
23
  * On Ubuntu, use `sudo apt-get install gdal-bin`.
24
+ 1. [GeoServer](http://geoserver.org/) (Optional)
24
25
 
25
26
  ## Mapnik
26
27
 
@@ -73,3 +74,43 @@ Then, in another terminal window:
73
74
  ```
74
75
  $ rake spec
75
76
  ```
77
+
78
+ ## Running GeoServer for Development with Docker
79
+
80
+ ### MacOS
81
+
82
+ 1. Make sure you have docker engine, docker-machine, and docker-compose installed.
83
+ - Docker Toolbox: [https://www.docker.com/products/docker-toolbox](https://www.docker.com/products/docker-toolbox)
84
+
85
+ 1. Execute the following command in the geo_concerns directory:
86
+
87
+ ```
88
+ $ source ./run-docker.sh
89
+ ```
90
+
91
+ ### Linux
92
+
93
+ 1. Make sure you have docker engine and docker-compose installed.
94
+ - [https://docs.docker.com/engine/installation/linux/](https://docs.docker.com/engine/installation/linux/)
95
+ - [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)
96
+
97
+ 1. Execute the following commands in the geo_concerns directory:
98
+
99
+ ```
100
+ $ docker-compose up -d
101
+ $ export GEOSERVER_URL="http://localhost:8181/geoserver/rest"
102
+ ```
103
+
104
+ ## Running GeoServer for Development with Vagrant
105
+
106
+ 1. Make sure you have VirtualBox and Vagrant installed.
107
+ - [https://www.virtualbox.org/wiki/Downloads](https://www.virtualbox.org/wiki/Downloads)
108
+ - [https://www.vagrantup.com/docs/installation/](https://www.vagrantup.com/docs/installation/)
109
+ 1. Execute the following commands:
110
+
111
+ ```
112
+ $ git clone https://github.com/geoconcerns/geoserver-vagrant.git
113
+ $ cd geoserver-vagrant/
114
+ $ vagrant up
115
+
116
+ ```
@@ -13,6 +13,6 @@ class DeliveryJob < ActiveJob::Base
13
13
  def perform(file_set, content_url)
14
14
  uri = URI.parse(content_url)
15
15
  raise NotImplementedError, 'Only supports file URLs' unless uri.scheme == 'file'
16
- GeoConcerns::DeliveryService.new.publish(file_set.id, uri.path)
16
+ GeoConcerns::DeliveryService.new(file_set, uri.path).publish
17
17
  end
18
18
  end
@@ -1,25 +1,18 @@
1
1
  require 'active_support/core_ext/hash/indifferent_access'
2
2
  require 'rgeoserver'
3
3
  require 'yaml'
4
+ require 'erb'
4
5
 
5
6
  module GeoConcerns
6
7
  module Delivery
7
8
  class Geoserver
8
- DEFAULT_CONFIG = {
9
- url: 'http://localhost:8181/geoserver/rest',
10
- user: 'admin',
11
- password: 'geoserver'
12
- }.with_indifferent_access.freeze
9
+ attr_reader :config, :workspace_name, :file_set, :file_path
13
10
 
14
- attr_reader :config
15
-
16
- def initialize
17
- begin
18
- data = File.read(Rails.root.join('config', 'geoserver.yml'))
19
- @config = YAML.load(data)['geoserver'].with_indifferent_access.freeze
20
- rescue Errno::ENOENT
21
- @config = DEFAULT_CONFIG
22
- end
11
+ def initialize(file_set, file_path)
12
+ @file_set = file_set
13
+ @file_path = file_path
14
+ @config = fetch_config
15
+ @workspace_name = @config.delete(:workspace)
23
16
  validate!
24
17
  end
25
18
 
@@ -27,12 +20,12 @@ module GeoConcerns
27
20
  @catalog ||= RGeoServer.catalog(config)
28
21
  end
29
22
 
30
- def publish(id, filename, type = :vector)
23
+ def publish(type = :vector)
31
24
  case type
32
25
  when :vector
33
- publish_vector(id, filename)
26
+ publish_vector
34
27
  when :raster
35
- publish_raster(id, filename)
28
+ publish_raster
36
29
  else
37
30
  raise ArgumentError, "Unknown file type #{type}"
38
31
  end
@@ -40,23 +33,41 @@ module GeoConcerns
40
33
 
41
34
  private
42
35
 
36
+ def fetch_config
37
+ raise ArgumentError, "FileSet visibility must be open or authenticated" unless visibility
38
+
39
+ data = ERB.new(File.read(Rails.root.join('config', 'geoserver.yml'))).result
40
+ YAML.load(data)['geoserver'][visibility].with_indifferent_access
41
+ end
42
+
43
+ def visibility
44
+ return file_set.visibility if file_set.visibility == 'open'
45
+ return file_set.visibility if file_set.visibility == 'authenticated'
46
+ end
47
+
43
48
  def validate!
44
49
  %w(url user password).map(&:to_sym).each do |k|
45
50
  raise ArgumentError, "Missing #{k} in configuration" unless config[k].present?
46
51
  end
47
52
  end
48
53
 
49
- def publish_vector(id, filename)
50
- raise ArgumentError, "Not ZIPed Shapefile: #{filename}" unless filename =~ /\.zip$/
51
-
52
- workspace = RGeoServer::Workspace.new catalog, name: 'geo'
54
+ def workspace
55
+ workspace = RGeoServer::Workspace.new catalog, name: workspace_name
53
56
  workspace.save if workspace.new?
54
- datastore = RGeoServer::DataStore.new catalog, workspace: workspace, name: id
55
- datastore.upload_file filename, publish: true
57
+ workspace
58
+ end
59
+
60
+ def datastore
61
+ RGeoServer::DataStore.new catalog, workspace: workspace, name: file_set.id
62
+ end
63
+
64
+ def publish_vector
65
+ raise ArgumentError, "Not ZIPed Shapefile: #{file_path}" unless file_path =~ /\.zip$/
66
+ datastore.upload_file file_path, publish: true
56
67
  end
57
68
 
58
- def publish_raster(_id, filename)
59
- raise ArgumentError, "Not GeoTIFF: #{filename}" unless filename =~ /\.tif$/
69
+ def publish_raster
70
+ raise ArgumentError, "Not GeoTIFF: #{file_path}" unless file_path =~ /\.tif$/
60
71
  raise NotImplementedError
61
72
  end
62
73
  end
@@ -2,8 +2,8 @@ module GeoConcerns
2
2
  class DeliveryService
3
3
  attr_reader :geoserver
4
4
 
5
- def initialize
6
- @geoserver = GeoConcerns::Delivery::Geoserver.new
5
+ def initialize(file_set, file_path)
6
+ @geoserver = GeoConcerns::Delivery::Geoserver.new(file_set, file_path)
7
7
  end
8
8
 
9
9
  delegate :publish, to: :geoserver
@@ -0,0 +1,10 @@
1
+ version: '2'
2
+ services:
3
+ rabbitmq:
4
+ image: rabbitmq
5
+ ports:
6
+ - "8081:8080"
7
+ geoserver:
8
+ image: thinkwhere/geoserver
9
+ ports:
10
+ - "8181:8080"
data/geo_concerns.gemspec CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'json-schema', '>= 2.6.2'
27
27
  spec.add_dependency 'rgeoserver', '>= 0.9.1'
28
28
 
29
- spec.add_dependency 'bundler', '~> 1.12.5' # TODO: 1.13 breaks our builds
30
29
 
30
+ spec.add_development_dependency 'bundler', '~> 1.13'
31
31
  spec.add_development_dependency 'sqlite3'
32
32
  spec.add_development_dependency 'devise', '>= 3.0', '< 5'
33
33
  spec.add_development_dependency 'rspec-rails', '>= 3.5.2'
@@ -1,17 +1,25 @@
1
1
  geoserver:
2
- # Set to the REST API for the GeoServer
3
- url: "http://localhost:8181/geoserver/rest"
4
- # Optional user/password, set to false to disable
5
- user: "admin"
6
- password: "geoserver"
7
- # Set to your GWC server, or "builtin" for the one bundled with GeoServer
8
- geowebcache_url: "builtin"
9
2
 
10
- # RestClient:
11
- restclient:
12
- # Set to false to disable or stdout/stderr or 'filename.out'
13
- logfile: stderr
14
- # Timeout (in seconds)
15
- timeout: 300
16
- # Open Timeout (in seconds)
17
- open_timeout: 60
3
+ # GeoServer config options for open and public data
4
+ open: &open
5
+ # Set to the REST API for the GeoServer
6
+ url: <%= ENV['PUBLIC_GEOSERVER_URL'] || "http://localhost:8181/geoserver/rest" %>
7
+ # Optional user and password, set to false to disable
8
+ user: <%= ENV['PUBLIC_GEOSERVER_USER'] || "admin" %>
9
+ password: <%= ENV['PUBLIC_GEOSERVER_PASSWORD'] || "geoserver" %>
10
+ # Set to your GWC server, or "builtin" for the one bundled with GeoServer
11
+ geowebcache_url: <%= ENV['PUBLIC_GEOSERVER_GWC_URL'] || "builtin" %>
12
+ # Name of the workspace to save your data in
13
+ workspace: <%= ENV['PUBLIC_GEOSERVER_WS'] || "public" %>
14
+ restclient:
15
+ # Set to false to disable or stdout, stderr, or filename
16
+ logfile: stderr
17
+ # Timeout (in seconds)
18
+ timeout: 300
19
+ # Open Timeout (in seconds)
20
+ open_timeout: 60
21
+
22
+ # GeoServer config options for restricted data or data that needs authentication
23
+ authenticated:
24
+ <<: *open
25
+ workspace: <%= ENV['AUTH_GEOSERVER_WS'] || "restricted" %>
@@ -1,3 +1,3 @@
1
1
  module GeoConcerns
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "0.0.9".freeze
3
3
  end
data/run-docker.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+ docker-machine start
3
+ docker_ip=$(docker-machine ip)
4
+ eval $(docker-machine env)
5
+ docker-compose up -d
6
+ geoserver_url="http://"$docker_ip":8181/geoserver/rest"
7
+ export GEOSERVER_URL=$geoserver_url
@@ -7,13 +7,14 @@ describe GeoConcerns::DeliveryJob do
7
7
  context '#perform' do
8
8
  context 'local file' do
9
9
  let(:content_url) { 'file:/somewhere-to-display-copy' }
10
+ let(:service) { instance_double('GeoConcerns::DeliveryService') }
10
11
  it 'delegates to DeliveryService' do
11
- dbl = double
12
- expect(GeoConcerns::DeliveryService).to receive(:new).and_return(dbl)
13
- expect(dbl).to receive(:publish).with(file_set.id, URI(content_url).path)
12
+ expect(GeoConcerns::DeliveryService).to receive(:new).with(file_set, URI(content_url).path).and_return(service)
13
+ expect(service).to receive(:publish)
14
14
  subject.perform(file_set, content_url)
15
15
  end
16
16
  end
17
+
17
18
  context 'remote file' do
18
19
  let(:content_url) { 'http://somewhere/to-display-copy' }
19
20
  it 'errors out' do
@@ -2,71 +2,96 @@ require 'spec_helper'
2
2
 
3
3
  describe GeoConcerns::Delivery::Geoserver do
4
4
  let(:id) { 'abc123' }
5
+ let(:file_set) { instance_double("FileSet") }
6
+ let(:visibility) { 'open' }
7
+ let(:path) { 'spec/fixtures/files/tufts-cambridgegrid100-04.zip' }
5
8
 
6
- context '#initialize' do
7
- it 'configures correctly with defaults' do
8
- expect(File).to receive(:read).and_raise(Errno::ENOENT)
9
+ subject { described_class.new file_set, path }
10
+
11
+ before do
12
+ allow(file_set).to receive(:visibility).and_return(visibility)
13
+ allow(file_set).to receive(:id).and_return(id)
14
+ end
15
+
16
+ context 'with an authenticated file set visibility' do
17
+ let(:visibility) { 'authenticated' }
18
+ it 'does not raise error' do
9
19
  expect { subject }.not_to raise_error
10
- expect(subject.config).to include('url' => 'http://localhost:8181/geoserver/rest',
11
- 'user' => 'admin',
12
- 'password' => 'geoserver')
13
20
  end
14
21
  end
15
22
 
16
- context '#catalog' do
17
- it 'connects to a RGeoServer catalog' do
18
- expect(RGeoServer).to receive(:catalog).with(hash_including(:url, :user, :password)).and_return(double).once
19
- subject.catalog
20
- subject.catalog # should cache result
23
+ context 'with a private file set visibility' do
24
+ let(:visibility) { 'private' }
25
+ it 'raises an error' do
26
+ expect { subject }.to raise_error(ArgumentError, /FileSet visibility/)
21
27
  end
22
28
  end
23
29
 
24
- context '#publish' do
30
+ describe '#publish' do
25
31
  it 'requires a valid type' do
26
- expect { subject.publish(id, 'some/file', :unknown) }.to raise_error(ArgumentError, /Unknown file type/)
32
+ expect { subject.publish(:unknown) }.to raise_error(ArgumentError, /Unknown file type/)
27
33
  end
28
- context 'vector' do
34
+
35
+ context 'when type is vector' do
29
36
  let(:type) { :vector }
30
- let(:filename) { 'file.zip' }
31
37
  it 'routes to publish_vector' do
32
- expect(subject).to receive(:publish_vector).with(id, filename)
33
- subject.publish(id, filename, type)
38
+ expect(subject).to receive(:publish_vector)
39
+ subject.publish(type)
34
40
  end
35
41
  end
36
- context 'raster' do
42
+
43
+ context 'when type is raster' do
37
44
  let(:type) { :raster }
38
- let(:filename) { 'file.tif' }
39
45
  it 'routes to publish_raster' do
40
- expect(subject).to receive(:publish_raster).with(id, filename)
41
- subject.publish(id, filename, type)
46
+ expect(subject).to receive(:publish_raster)
47
+ subject.publish(type)
42
48
  end
43
49
  end
44
50
  end
45
51
 
46
- context '#publish_vector' do
47
- let(:filename) { 'spec/fixtures/files/tufts-cambridgegrid100-04.zip' }
48
- it 'requires a vector ZIP file' do
49
- expect { subject.send(:publish_vector, id, 'not-a-zip') }.to raise_error(ArgumentError, /Not ZIPed Shapefile/)
52
+ describe '#publish_vector' do
53
+ context 'when a vector is not a zip file' do
54
+ let(:path) { 'not-a-zip' }
55
+ it 'raises an error' do
56
+ expect { subject.send(:publish_vector) }.to raise_error(ArgumentError, /Not ZIPed Shapefile/)
57
+ end
50
58
  end
51
- it 'dispatches to RGeoServer' do
52
- ws_dbl = double
53
- expect(RGeoServer::Workspace).to receive(:new).with(subject.catalog, hash_including(name: 'geo')).and_return(ws_dbl)
54
- expect(ws_dbl).to receive(:'new?').and_return(true)
55
- expect(ws_dbl).to receive(:save)
56
- ds_dbl = double
57
- expect(RGeoServer::DataStore).to receive(:new).with(subject.catalog, hash_including(workspace: ws_dbl, name: id)).and_return(ds_dbl)
58
- expect(ds_dbl).to receive(:upload_file).with(filename, hash_including(publish: true))
59
- subject.send(:publish_vector, id, filename)
59
+
60
+ context 'with a path to a zipped shapefile' do
61
+ let(:ws) { double }
62
+ let(:ds) { double }
63
+
64
+ it 'dispatches to RGeoServer' do
65
+ expect(RGeoServer::Workspace).to receive(:new).with(subject.catalog, hash_including(name: 'public')).and_return(ws)
66
+ expect(ws).to receive(:'new?').and_return(true)
67
+ expect(ws).to receive(:save)
68
+ expect(RGeoServer::DataStore).to receive(:new).with(subject.catalog, hash_including(workspace: ws, name: id)).and_return(ds)
69
+ expect(ds).to receive(:upload_file).with(path, hash_including(publish: true))
70
+ subject.send(:publish_vector)
71
+ end
60
72
  end
61
73
  end
62
74
 
63
- context '#publish_raster' do
64
- let(:filename) { 'spec/fixtures/files/S_566_1914_clip.tif' }
65
- it 'requires GeoTIFF' do
66
- expect { subject.send(:publish_raster, id, 'not-a-tiff') }.to raise_error(ArgumentError, /Not GeoTIFF/)
67
- end
75
+ describe '#publish_raster' do
76
+ let(:path) { 'spec/fixtures/files/S_566_1914_clip.tif' }
77
+
68
78
  it 'is not implemented yet' do
69
- expect { subject.send(:publish_raster, id, filename) }.to raise_error(NotImplementedError)
79
+ expect { subject.send(:publish_raster) }.to raise_error(NotImplementedError)
80
+ end
81
+
82
+ context 'when a raster is not a GeoTIFF file' do
83
+ let(:path) { 'not-a-tiff' }
84
+ it 'raises an error' do
85
+ expect { subject.send(:publish_raster) }.to raise_error(ArgumentError, /Not GeoTIFF/)
86
+ end
87
+ end
88
+ end
89
+
90
+ describe '#catalog' do
91
+ it 'connects to a RGeoServer catalog' do
92
+ expect(RGeoServer).to receive(:catalog).with(hash_including(:url, :user, :password)).and_return(double).once
93
+ subject.catalog
94
+ subject.catalog # should cache result
70
95
  end
71
96
  end
72
97
  end
@@ -2,14 +2,23 @@ require 'spec_helper'
2
2
 
3
3
  describe GeoConcerns::DeliveryService do
4
4
  let(:id) { 'abc123' }
5
- let(:filename) { 'somewhere-to-display-copy' }
5
+ let(:path) { 'somewhere-to-display-copy' }
6
+ let(:file_set) { instance_double("FileSet") }
7
+ let(:visibility) { 'open' }
8
+ let(:service) { instance_double('GeoConcerns::Delivery::Geoserver') }
9
+
10
+ subject { described_class.new file_set, path }
11
+
12
+ before do
13
+ allow(file_set).to receive(:visibility).and_return(visibility)
14
+ allow(service).to receive(:visibility).and_return(visibility)
15
+ end
6
16
 
7
17
  context '#publish' do
8
18
  it 'dispatches to Geoserver delivery' do
9
- dbl = double
10
- expect(subject).to receive(:geoserver).and_return(dbl)
11
- expect(dbl).to receive(:publish).with(id, filename)
12
- subject.publish(id, filename)
19
+ expect(subject).to receive(:geoserver).and_return(service)
20
+ expect(service).to receive(:publish)
21
+ subject.publish
13
22
  end
14
23
  end
15
24
  end
data/template.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  gem 'curation_concerns', '1.5.0'
2
- gem 'geo_concerns', '0.0.8'
2
+ gem 'geo_concerns', '0.0.9'
3
3
 
4
4
  run 'bundle install'
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo_concerns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Griffin
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-09-10 00:00:00.000000000 Z
15
+ date: 2016-09-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: curation_concerns
@@ -90,14 +90,14 @@ dependencies:
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: 1.12.5
94
- type: :runtime
93
+ version: '1.13'
94
+ type: :development
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
- version: 1.12.5
100
+ version: '1.13'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: sqlite3
103
103
  requirement: !ruby/object:Gem::Requirement
@@ -468,6 +468,7 @@ files:
468
468
  - app/views/geo_concerns/related/_parent_works.html.erb
469
469
  - app/vocabs/geo_concerns/geo_terms.rb
470
470
  - config/routes.rb
471
+ - docker-compose.yml
471
472
  - geo_concerns.gemspec
472
473
  - lib/generators/geo_concerns/install_generator.rb
473
474
  - lib/generators/geo_concerns/templates/actors/curation_concerns/actors/image_work_actor.rb
@@ -499,6 +500,7 @@ files:
499
500
  - lib/geo_concerns/engine.rb
500
501
  - lib/geo_concerns/version.rb
501
502
  - lib/tasks/geo_concerns_tasks.rake
503
+ - run-docker.sh
502
504
  - solr/config/_rest_managed.json
503
505
  - solr/config/admin-extra.html
504
506
  - solr/config/elevate.xml