geo_concerns 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/geo_concerns/messenger_behavior.rb +5 -5
- data/app/models/concerns/geo_concerns/file_set/derivatives.rb +3 -14
- data/app/processors/geo_concerns/processors/image.rb +17 -10
- data/app/services/geo_concerns/events_generator.rb +2 -2
- data/app/services/geo_concerns/rabbit_messaging_client.rb +2 -2
- data/geo_concerns.gemspec +1 -0
- data/lib/generators/geo_concerns/install_generator.rb +2 -2
- data/lib/generators/geo_concerns/templates/config/{messaging.yml → geo_concerns_messaging.yml} +0 -0
- data/lib/generators/geo_concerns/templates/config/initializers/geo_concerns_messaging_config.rb +37 -0
- data/lib/geo_concerns/version.rb +1 -1
- data/spec/controllers/file_sets_controller_spec.rb +1 -1
- data/spec/models/concerns/geo_concerns/file_set/derivatives_spec.rb +2 -25
- data/spec/processors/geo_concerns/processors/image_spec.rb +9 -16
- data/spec/services/geo_concerns/rabbit_messaging_client_spec.rb +1 -1
- data/template.rb +1 -1
- metadata +18 -4
- data/lib/generators/geo_concerns/templates/config/initializers/messaging_config.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855515a951ec28e268a9cd763fb7672293f3124c
|
4
|
+
data.tar.gz: 56188c811164b602d7192147c7080416b28ba211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e847ae51eb4d7b2f460f944f88d265df4bb1d2f1cc7c2d5191a8a8cbf6cad9164ddce90ebd1c0dc94feca07978144e21abc15d1c0861939af7fcaea2b2028c5b
|
7
|
+
data.tar.gz: d7750c9f69ce7bbff2d3303611ac3ebd73ea164a57f5b17034700e29b1a57c0c81105154d892e3355f78371bc885ebb6419c58af3a5d9e5a47fcca15ac33e22d
|
@@ -3,22 +3,22 @@ module GeoConcerns
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def destroy
|
6
|
-
|
6
|
+
geo_concerns_messenger.record_deleted(geo_concern)
|
7
7
|
super
|
8
8
|
end
|
9
9
|
|
10
10
|
def after_create_response
|
11
11
|
super
|
12
|
-
|
12
|
+
geo_concerns_messenger.record_created(geo_concern)
|
13
13
|
end
|
14
14
|
|
15
15
|
def after_update_response
|
16
16
|
super
|
17
|
-
|
17
|
+
geo_concerns_messenger.record_updated(geo_concern)
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
@
|
20
|
+
def geo_concerns_messenger
|
21
|
+
@geo_concerns_messenger ||= GeoConcerns::Messaging.messenger
|
22
22
|
end
|
23
23
|
|
24
24
|
def geo_concern
|
@@ -5,8 +5,6 @@ module GeoConcerns
|
|
5
5
|
|
6
6
|
def create_derivatives(filename)
|
7
7
|
case geo_mime_type
|
8
|
-
when *GeoConcerns::ImageFormatService.select_options.map(&:last)
|
9
|
-
image_derivatives(filename)
|
10
8
|
when *GeoConcerns::RasterFormatService.select_options.map(&:last)
|
11
9
|
raster_derivatives(filename)
|
12
10
|
when *GeoConcerns::VectorFormatService.select_options.map(&:last)
|
@@ -15,16 +13,7 @@ module GeoConcerns
|
|
15
13
|
super
|
16
14
|
|
17
15
|
# Once all the derivatives are created, send a derivatives created message
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def image_derivatives(filename)
|
22
|
-
Hydra::Derivatives::ImageDerivatives
|
23
|
-
.create(filename, outputs: [{ label: :thumbnail,
|
24
|
-
id: id,
|
25
|
-
format: 'png',
|
26
|
-
size: '200x150>',
|
27
|
-
url: derivative_url('thumbnail') }])
|
16
|
+
geo_concerns_messenger.derivatives_created(self)
|
28
17
|
end
|
29
18
|
|
30
19
|
def raster_derivatives(filename)
|
@@ -63,8 +52,8 @@ module GeoConcerns
|
|
63
52
|
GeoConcerns::DerivativePath
|
64
53
|
end
|
65
54
|
|
66
|
-
def
|
67
|
-
@
|
55
|
+
def geo_concerns_messenger
|
56
|
+
@geo_concerns_messenger ||= GeoConcerns::Messaging.messenger
|
68
57
|
end
|
69
58
|
end
|
70
59
|
end
|
@@ -12,18 +12,25 @@ module GeoConcerns
|
|
12
12
|
# @param out_path [String] processor output file path.
|
13
13
|
# @param options [Hash] creation options
|
14
14
|
# @option options [String] `:output_size` as "w h" or "wxh"
|
15
|
+
# rubocop:disable Metrics/MethodLength
|
15
16
|
def self.convert(in_path, out_path, options)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
size = options[:output_size].tr(' ', 'x')
|
18
|
+
convert = MiniMagick::Tool::Convert.new(whiny: false)
|
19
|
+
convert << in_path
|
20
|
+
convert << "-resize"
|
21
|
+
convert << size
|
22
|
+
convert << "-extent"
|
23
|
+
convert << size
|
24
|
+
convert << "-background"
|
25
|
+
convert << "white"
|
26
|
+
convert << "-gravity"
|
27
|
+
convert << "center"
|
28
|
+
convert << out_path
|
29
|
+
|
30
|
+
# suppress stderr b/c geotiffs return 'unknown field' warnings
|
31
|
+
convert.call { |_stdout, _stderr| }
|
26
32
|
end
|
33
|
+
# rubocop:enable Metrics/MethodLength
|
27
34
|
|
28
35
|
# Trims extra whitespace.
|
29
36
|
# @param in_path [String] file input path
|
@@ -15,11 +15,11 @@ module GeoConcerns
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def geoblacklight_event_generator
|
18
|
-
GeoblacklightEventGenerator.new(Messaging.geoblacklight_client)
|
18
|
+
GeoblacklightEventGenerator.new(GeoConcerns::Messaging.geoblacklight_client)
|
19
19
|
end
|
20
20
|
|
21
21
|
def geoserver_event_generator
|
22
|
-
GeoserverEventGenerator.new(Messaging.geoserver_client)
|
22
|
+
GeoserverEventGenerator.new(GeoConcerns::Messaging.geoserver_client)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -16,12 +16,12 @@ module GeoConcerns
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def geoblacklight
|
19
|
-
exchange_name = Messaging.config['events']['exchange']['geoblacklight']
|
19
|
+
exchange_name = GeoConcerns::Messaging.config['events']['exchange']['geoblacklight']
|
20
20
|
@exchange ||= channel.fanout(exchange_name, durable: true)
|
21
21
|
end
|
22
22
|
|
23
23
|
def geoserver
|
24
|
-
exchange_name = Messaging.config['events']['exchange']['geoserver']
|
24
|
+
exchange_name = GeoConcerns::Messaging.config['events']['exchange']['geoserver']
|
25
25
|
@exchange ||= channel.fanout(exchange_name, durable: true)
|
26
26
|
end
|
27
27
|
|
data/geo_concerns.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'simpler-tiles'
|
28
28
|
spec.add_dependency 'bunny'
|
29
29
|
spec.add_dependency 'geoblacklight_messaging'
|
30
|
+
spec.add_dependency 'jquery-ui-rails', '~> 5.0.5'
|
30
31
|
|
31
32
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
32
33
|
spec.add_development_dependency 'sqlite3'
|
@@ -74,8 +74,8 @@ module GeoConcerns
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def install_messaging_config
|
77
|
-
config_file_path = 'config/
|
78
|
-
initializer_file_path = 'config/initializers/
|
77
|
+
config_file_path = 'config/geo_concerns_messaging.yml'
|
78
|
+
initializer_file_path = 'config/initializers/geo_concerns_messaging_config.rb'
|
79
79
|
copy_file config_file_path, config_file_path
|
80
80
|
copy_file initializer_file_path, initializer_file_path
|
81
81
|
end
|
data/lib/generators/geo_concerns/templates/config/{messaging.yml → geo_concerns_messaging.yml}
RENAMED
File without changes
|
data/lib/generators/geo_concerns/templates/config/initializers/geo_concerns_messaging_config.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module GeoConcerns
|
2
|
+
module Messaging
|
3
|
+
def config
|
4
|
+
@config ||= config_yaml.with_indifferent_access
|
5
|
+
end
|
6
|
+
|
7
|
+
def messenger
|
8
|
+
GeoConcerns::EventsGenerator.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def geoblacklight_client
|
12
|
+
local_client
|
13
|
+
end
|
14
|
+
|
15
|
+
def geoserver_client
|
16
|
+
local_client
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def config_yaml
|
22
|
+
config_file = "#{Rails.root}/config/geo_concerns_messaging.yml"
|
23
|
+
YAML.load(ERB.new(File.read(config_file)).result)[Rails.env]
|
24
|
+
end
|
25
|
+
|
26
|
+
def local_client
|
27
|
+
GeoConcerns::LocalMessagingClient.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def rabbit_client
|
31
|
+
GeoConcerns::RabbitMessagingClient.new(Messaging.config['events']['server'])
|
32
|
+
end
|
33
|
+
|
34
|
+
module_function :config, :config_yaml, :messenger, :local_client,
|
35
|
+
:rabbit_client, :geoblacklight_client, :geoserver_client
|
36
|
+
end
|
37
|
+
end
|
data/lib/geo_concerns/version.rb
CHANGED
@@ -24,7 +24,7 @@ describe CurationConcerns::FileSetsController, type: :controller do
|
|
24
24
|
|
25
25
|
before do
|
26
26
|
sign_in user
|
27
|
-
allow(Messaging).to receive(:messenger).and_return(messenger)
|
27
|
+
allow(GeoConcerns::Messaging).to receive(:messenger).and_return(messenger)
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'after updating metadata' do
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
shared_examples 'a set of raster derivatives' do
|
4
4
|
let(:messenger) { instance_double(GeoConcerns::EventsGenerator) }
|
5
5
|
before do
|
6
|
-
allow(Messaging).to receive(:messenger).and_return(messenger)
|
6
|
+
allow(GeoConcerns::Messaging).to receive(:messenger).and_return(messenger)
|
7
7
|
expect(messenger).to receive(:derivatives_created).with(file_set)
|
8
8
|
end
|
9
9
|
it 'makes a thumbnail' do
|
@@ -26,7 +26,7 @@ end
|
|
26
26
|
shared_examples 'a set of vector derivatives' do
|
27
27
|
let(:messenger) { instance_double(GeoConcerns::EventsGenerator) }
|
28
28
|
before do
|
29
|
-
allow(Messaging).to receive(:messenger).and_return(messenger)
|
29
|
+
allow(GeoConcerns::Messaging).to receive(:messenger).and_return(messenger)
|
30
30
|
expect(messenger).to receive(:derivatives_created).with(file_set)
|
31
31
|
end
|
32
32
|
it 'makes a thumbnail' do
|
@@ -46,21 +46,6 @@ shared_examples 'a set of vector derivatives' do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
shared_examples 'a set of image derivatives' do
|
50
|
-
let(:messenger) { instance_double(GeoConcerns::EventsGenerator) }
|
51
|
-
before do
|
52
|
-
allow(Messaging).to receive(:messenger).and_return(messenger)
|
53
|
-
expect(messenger).to receive(:derivatives_created).with(file_set)
|
54
|
-
end
|
55
|
-
it 'makes a thumbnail' do
|
56
|
-
new_thumb = "#{Rails.root}/tmp/derivatives/#{file_set.id}/thumbnail.thumbnail"
|
57
|
-
expect {
|
58
|
-
file_set.create_derivatives(file_name)
|
59
|
-
}.to change { Dir[new_thumb].empty? }
|
60
|
-
.from(true).to(false)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
49
|
describe CurationConcerns::FileSet do
|
65
50
|
let(:file_set) { FileSet.create { |gf| gf.apply_depositor_metadata('geonerd@example.com') } }
|
66
51
|
|
@@ -78,14 +63,6 @@ describe CurationConcerns::FileSet do
|
|
78
63
|
end
|
79
64
|
|
80
65
|
describe 'geo derivatives' do
|
81
|
-
describe 'image processing' do
|
82
|
-
context 'with a jpeg' do
|
83
|
-
let(:geo_mime_type) { 'image/jpeg' }
|
84
|
-
let(:file_name) { File.join(fixture_path, 'files', 'americas.jpg') }
|
85
|
-
it_behaves_like 'a set of image derivatives'
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
66
|
describe 'vector processing' do
|
90
67
|
context 'with a shapefile' do
|
91
68
|
let(:geo_mime_type) { 'application/zip; ogr-format="ESRI Shapefile"' }
|
@@ -11,37 +11,31 @@ describe GeoConcerns::Processors::Image do
|
|
11
11
|
|
12
12
|
subject { TestProcessor.new }
|
13
13
|
|
14
|
-
let(:
|
14
|
+
let(:shell) { double }
|
15
15
|
let(:output_file_png) { 'output/geo.png' }
|
16
16
|
let(:output_file) { output_file_png }
|
17
17
|
let(:file_name) { 'files/geo.tif' }
|
18
18
|
let(:options) { { output_size: '150 150' } }
|
19
19
|
|
20
20
|
describe '#convert' do
|
21
|
-
let(:
|
21
|
+
let(:args) {
|
22
|
+
[['convert', 'files/geo.tif', '-resize', '150x150', '-extent',
|
23
|
+
'150x150', '-background', 'white', '-gravity', 'center',
|
24
|
+
'output/geo.png'], { whiny: false, stderr: false }]
|
25
|
+
}
|
22
26
|
|
23
27
|
before do
|
24
|
-
allow(MiniMagick::
|
28
|
+
allow(MiniMagick::Shell).to receive(:new).and_return(shell)
|
25
29
|
end
|
26
30
|
|
27
31
|
it 'transforms the image and saves it as a PNG' do
|
28
|
-
expect(
|
29
|
-
expect(image).to receive(:combine_options)
|
30
|
-
expect(image).to receive(:write).with(output_file_png)
|
32
|
+
expect(shell).to receive(:run).with(*args).and_return('output message')
|
31
33
|
subject.class.convert(file_name, output_file_png, options)
|
32
34
|
end
|
33
|
-
|
34
|
-
it 'transforms the image and saves it as a JPG' do
|
35
|
-
expect(image).to receive(:format).with('jpg')
|
36
|
-
expect(image).to receive(:combine_options)
|
37
|
-
expect(image).to receive(:write).with(output_file_jpg)
|
38
|
-
subject.class.convert(file_name, output_file_jpg, options)
|
39
|
-
end
|
40
35
|
end
|
41
36
|
|
42
37
|
describe '#trim' do
|
43
|
-
let(:
|
44
|
-
let(:args) { [["convert", "files/geo.tif", "-trim", "output/geo.png"], { whiny: true }] }
|
38
|
+
let(:args) { [['convert', 'files/geo.tif', '-trim', 'output/geo.png'], { whiny: true }] }
|
45
39
|
|
46
40
|
before do
|
47
41
|
allow(MiniMagick::Shell).to receive(:new).and_return(shell)
|
@@ -53,7 +47,6 @@ describe GeoConcerns::Processors::Image do
|
|
53
47
|
end
|
54
48
|
|
55
49
|
describe '#center' do
|
56
|
-
let(:shell) { double }
|
57
50
|
let(:args) {
|
58
51
|
[['convert', '-size', '150x150', 'xc:white', 'files/geo.tif',
|
59
52
|
'-gravity', 'center', '-composite', 'output/geo.png'],
|
@@ -10,7 +10,7 @@ RSpec.describe GeoConcerns::RabbitMessagingClient do
|
|
10
10
|
let(:bunny_session) { instance_double(Bunny::Session, create_channel: channel) }
|
11
11
|
|
12
12
|
before do
|
13
|
-
allow(Messaging).to receive(:config).and_return(config)
|
13
|
+
allow(GeoConcerns::Messaging).to receive(:config).and_return(config)
|
14
14
|
allow(Bunny).to receive(:new).and_return(bunny_session)
|
15
15
|
allow(bunny_session).to receive(:start)
|
16
16
|
end
|
data/template.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
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-
|
15
|
+
date: 2016-12-02 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: curation_concerns
|
@@ -112,6 +112,20 @@ dependencies:
|
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: jquery-ui-rails
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 5.0.5
|
122
|
+
type: :runtime
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 5.0.5
|
115
129
|
- !ruby/object:Gem::Dependency
|
116
130
|
name: bundler
|
117
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -518,12 +532,12 @@ files:
|
|
518
532
|
- lib/generators/geo_concerns/templates/config/authorities/metadata_formats.yml
|
519
533
|
- lib/generators/geo_concerns/templates/config/authorities/raster_formats.yml
|
520
534
|
- lib/generators/geo_concerns/templates/config/authorities/vector_formats.yml
|
535
|
+
- lib/generators/geo_concerns/templates/config/geo_concerns_messaging.yml
|
521
536
|
- lib/generators/geo_concerns/templates/config/geoblacklight.yml
|
522
537
|
- lib/generators/geo_concerns/templates/config/geoserver.yml
|
538
|
+
- lib/generators/geo_concerns/templates/config/initializers/geo_concerns_messaging_config.rb
|
523
539
|
- lib/generators/geo_concerns/templates/config/initializers/geoblacklight_config.rb
|
524
|
-
- lib/generators/geo_concerns/templates/config/initializers/messaging_config.rb
|
525
540
|
- lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb
|
526
|
-
- lib/generators/geo_concerns/templates/config/messaging.yml
|
527
541
|
- lib/generators/geo_concerns/templates/config/simpler_tiles.yml
|
528
542
|
- lib/generators/geo_concerns/templates/controllers/curation_concerns/file_sets_controller.rb
|
529
543
|
- lib/generators/geo_concerns/templates/controllers/curation_concerns/image_works_controller.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Messaging
|
2
|
-
def config
|
3
|
-
@config ||= config_yaml.with_indifferent_access
|
4
|
-
end
|
5
|
-
|
6
|
-
def messenger
|
7
|
-
GeoConcerns::EventsGenerator.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def geoblacklight_client
|
11
|
-
local_client
|
12
|
-
end
|
13
|
-
|
14
|
-
def geoserver_client
|
15
|
-
local_client
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def config_yaml
|
21
|
-
YAML.load(ERB.new(File.read("#{Rails.root}/config/messaging.yml")).result)[Rails.env]
|
22
|
-
end
|
23
|
-
|
24
|
-
def local_client
|
25
|
-
GeoConcerns::LocalMessagingClient.new
|
26
|
-
end
|
27
|
-
|
28
|
-
def rabbit_client
|
29
|
-
GeoConcerns::RabbitMessagingClient.new(Messaging.config['events']['server'])
|
30
|
-
end
|
31
|
-
|
32
|
-
module_function :config, :config_yaml, :messenger, :local_client,
|
33
|
-
:rabbit_client, :geoblacklight_client, :geoserver_client
|
34
|
-
end
|