geoblacklight_sidecar_images 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +12 -20
- data/.travis.yml +4 -4
- data/Gemfile +1 -1
- data/README.md +11 -11
- data/geoblacklight_sidecar_images.gemspec +2 -2
- data/lib/generators/geoblacklight_sidecar_images/templates/config/initializers/statesman.rb +2 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/jobs/store_image_job.rb +2 -2
- data/lib/generators/geoblacklight_sidecar_images/templates/models/sidecar_image_state_machine.rb +8 -6
- data/lib/generators/geoblacklight_sidecar_images/templates/models/sidecar_image_transition.rb +3 -1
- data/lib/generators/geoblacklight_sidecar_images/templates/models/solr_document_sidecar.rb +4 -4
- data/lib/generators/geoblacklight_sidecar_images/templates/services/image_service.rb +65 -62
- data/lib/geoblacklight_sidecar_images/version.rb +1 -1
- data/spec/jobs/store_image_job_spec.rb +6 -6
- data/spec/models/solr_document_spec.rb +3 -0
- data/spec/rails_helper.rb +2 -2
- data/spec/services/image_service_spec.rb +17 -8
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8eb8793e9bc01499aa73ada433ccd2b545c4381
|
4
|
+
data.tar.gz: b62ea3956e24e52f58fc82d5ae0bc6122ec1fd63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7e1f1a1084046921f213aac5c1a9ae73cb2e3ef5112455a33bf36dd5f66871a06f456d3fabb0c19e967676e2bfd155fb11832cfcc3e446355487d437fc34301
|
7
|
+
data.tar.gz: 1cb4ced8521c6e4778379d784901196a832b2c5989f0523c2ca092f8d22c495f0a7c66e20ec5e97f2d0f40d75addcd2ca27713567ee12b65d50e3674e5805a4c
|
data/.rubocop.yml
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
1
3
|
Rails:
|
2
4
|
Enabled: true
|
3
5
|
|
4
6
|
AllCops:
|
5
7
|
DisplayCopNames: true
|
6
8
|
|
7
|
-
Include:
|
8
|
-
- '**/Gemfile'
|
9
|
-
- '**/Rakefile'
|
10
|
-
|
11
9
|
Exclude:
|
12
10
|
- 'db/**/*'
|
13
|
-
- 'vendor/**/*'
|
14
11
|
- '.internal_test_app/**/*'
|
15
12
|
- 'lib/generators/geoblacklight/templates/**/*'
|
16
13
|
- 'geoblacklight_sidecar_images.gemspec'
|
@@ -26,7 +23,7 @@ Lint/RescueException:
|
|
26
23
|
Metrics/BlockLength:
|
27
24
|
Exclude:
|
28
25
|
- 'spec/**/*'
|
29
|
-
|
26
|
+
|
30
27
|
Metrics/LineLength:
|
31
28
|
Max: 100
|
32
29
|
Exclude:
|
@@ -44,31 +41,26 @@ Metrics/AbcSize:
|
|
44
41
|
|
45
42
|
Metrics/MethodLength:
|
46
43
|
Max: 16
|
44
|
+
Exclude:
|
45
|
+
- 'spec/**/*'
|
46
|
+
- 'Rakefile'
|
47
|
+
- 'lib/generators/geoblacklight_sidecar_images/templates/services/image_service.rb'
|
47
48
|
|
48
49
|
# TODO: Add top-level class and module documentation.
|
49
50
|
Style/Documentation:
|
50
51
|
Enabled: false
|
51
52
|
|
53
|
+
Style/MutableConstant:
|
54
|
+
Enabled: false
|
55
|
+
|
52
56
|
# Overrides method in blacklight. Must use method name.
|
53
|
-
|
57
|
+
Naming/PredicateName:
|
54
58
|
Exclude:
|
55
59
|
- 'lib/geoblacklight/view_helper_override.rb'
|
56
60
|
|
57
61
|
RSpec/FilePath:
|
58
62
|
Enabled: false
|
59
63
|
|
60
|
-
# Rubocop bug causes view specs to fail.
|
61
|
-
# https://github.com/nevir/rubocop-rspec/issues/47
|
62
|
-
RSpec/DescribeClass:
|
63
|
-
Enabled: false
|
64
|
-
|
65
|
-
# geoblacklight references in solr_document_spec are
|
66
|
-
# difficult to mock because of the use of 'method_missing'.
|
67
|
-
# https://relishapp.com/rspec/rspec-mocks/docs/verifying-doubles/dynamic-classes
|
68
|
-
RSpec/AnyInstance:
|
69
|
-
Exclude:
|
70
|
-
- 'spec/models/concerns/geoblacklight/solr_document_spec.rb'
|
71
|
-
|
72
64
|
Style/SignalException:
|
73
65
|
EnforcedStyle: semantic
|
74
66
|
|
@@ -78,7 +70,7 @@ Style/StringLiterals:
|
|
78
70
|
Enabled: true
|
79
71
|
EnforcedStyle: single_quotes
|
80
72
|
|
81
|
-
|
73
|
+
Layout/DotPosition:
|
82
74
|
Description: Checks the position of the dot in multi-line method calls.
|
83
75
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
84
76
|
Enabled: true
|
data/.travis.yml
CHANGED
@@ -8,12 +8,12 @@ notifications:
|
|
8
8
|
email: false
|
9
9
|
|
10
10
|
rvm:
|
11
|
-
- 2.4.
|
11
|
+
- 2.4.5
|
12
12
|
|
13
13
|
matrix:
|
14
14
|
include:
|
15
|
-
- rvm: 2.
|
16
|
-
env: "RAILS_VERSION=5.
|
15
|
+
- rvm: 2.4.5
|
16
|
+
env: "RAILS_VERSION=5.2.1"
|
17
17
|
|
18
18
|
before_install:
|
19
19
|
- gem update --system
|
@@ -21,7 +21,7 @@ before_install:
|
|
21
21
|
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
|
22
22
|
|
23
23
|
env:
|
24
|
-
- "RAILS_VERSION=5.1
|
24
|
+
- "RAILS_VERSION=5.2.1 "
|
25
25
|
|
26
26
|
global_env:
|
27
27
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
data/Gemfile
CHANGED
@@ -16,7 +16,7 @@ group :development, :test do
|
|
16
16
|
# Peg simplecov to < 0.8 until this is resolved:
|
17
17
|
# https://github.com/colszowka/simplecov/issues/281
|
18
18
|
gem 'coveralls', require: false
|
19
|
-
gem 'rubocop', '0.
|
19
|
+
gem 'rubocop', '0.60.0', require: false
|
20
20
|
end
|
21
21
|
|
22
22
|
# To use a debugger
|
data/README.md
CHANGED
@@ -60,11 +60,11 @@ $ rails new app-name -m https://raw.githubusercontent.com/ewlarson/geoblacklight
|
|
60
60
|
|
61
61
|
```bash
|
62
62
|
# Run your GBL instance
|
63
|
-
rake geoblacklight:server
|
63
|
+
bundle exec rake geoblacklight:server
|
64
64
|
```
|
65
65
|
|
66
66
|
```bash
|
67
|
-
rake gblsci:sample_data:ingest['<FULL_LOCAL_PATH_TO>/geoblacklight_sidecar_images/spec/fixtures/files']
|
67
|
+
bundle exec rake gblsci:sample_data:ingest['<FULL_LOCAL_PATH_TO>/geoblacklight_sidecar_images/spec/fixtures/files']
|
68
68
|
```
|
69
69
|
|
70
70
|
## Rake tasks
|
@@ -76,7 +76,7 @@ rake gblsci:sample_data:ingest['<FULL_LOCAL_PATH_TO>/geoblacklight_sidecar_image
|
|
76
76
|
Spawns background jobs to harvest images for all documents in your Solr index.
|
77
77
|
|
78
78
|
```bash
|
79
|
-
rake gblsci:images:harvest_all
|
79
|
+
bundle exec rake gblsci:images:harvest_all
|
80
80
|
```
|
81
81
|
|
82
82
|
#### Harvest an individual image
|
@@ -84,7 +84,7 @@ rake gblsci:images:harvest_all
|
|
84
84
|
Allows you to add images one document id at a time.
|
85
85
|
|
86
86
|
```bash
|
87
|
-
rake gblsci:images:harvest_doc_id['stanford-cz128vq0535']
|
87
|
+
bundle exec rake gblsci:images:harvest_doc_id['stanford-cz128vq0535']
|
88
88
|
```
|
89
89
|
|
90
90
|
#### Harvest all incomplete states
|
@@ -92,13 +92,13 @@ rake gblsci:images:harvest_doc_id['stanford-cz128vq0535']
|
|
92
92
|
Reattempt image harvesting for all non-successful state objects.
|
93
93
|
|
94
94
|
```bash
|
95
|
-
rake gblsci:images:harvest_retry
|
95
|
+
bundle exec rake gblsci:images:harvest_retry
|
96
96
|
```
|
97
97
|
|
98
98
|
### Check image states
|
99
99
|
|
100
100
|
```bash
|
101
|
-
rake gblsci:images:harvest_states
|
101
|
+
bundle exec rake gblsci:images:harvest_states
|
102
102
|
```
|
103
103
|
|
104
104
|
We use a state machine library to track success/failure of our harvest tasks. The states we track are:
|
@@ -123,7 +123,7 @@ SolrDocumentSidecar.image_state.last_transition => #<SidecarImageTransition id:
|
|
123
123
|
Remove all sidecar objects and attached images
|
124
124
|
|
125
125
|
```bash
|
126
|
-
rake gblsci:images:harvest_purge_all
|
126
|
+
bundle exec rake gblsci:images:harvest_purge_all
|
127
127
|
```
|
128
128
|
|
129
129
|
#### Remove orphaned AR objects
|
@@ -131,7 +131,7 @@ rake gblsci:images:harvest_purge_all
|
|
131
131
|
Remove all sidecar objects and attached images for AR objects without a corresponding Solr document
|
132
132
|
|
133
133
|
```bash
|
134
|
-
rake gblsci:images:harvest_purge_orphans
|
134
|
+
bundle exec rake gblsci:images:harvest_purge_orphans
|
135
135
|
```
|
136
136
|
|
137
137
|
#### Remove a batch
|
@@ -139,7 +139,7 @@ rake gblsci:images:harvest_purge_orphans
|
|
139
139
|
Remove sidecar objects and attached images via a CSV file of document ids
|
140
140
|
|
141
141
|
```bash
|
142
|
-
rake gblsci:images:harvest_purge_orphans
|
142
|
+
bundle exec rake gblsci:images:harvest_purge_orphans
|
143
143
|
```
|
144
144
|
|
145
145
|
### Troubleshooting
|
@@ -149,7 +149,7 @@ rake gblsci:images:harvest_purge_orphans
|
|
149
149
|
Generate a CSV file of sidecar objects and associated image state. Useful for debugging problem items.
|
150
150
|
|
151
151
|
```bash
|
152
|
-
rake gblsci:images:harvest_report
|
152
|
+
bundle exec rake gblsci:images:harvest_report
|
153
153
|
```
|
154
154
|
|
155
155
|
#### Failed state inspect
|
@@ -157,7 +157,7 @@ rake gblsci:images:harvest_report
|
|
157
157
|
Prints details for failed state harvest objects to stdout
|
158
158
|
|
159
159
|
```bash
|
160
|
-
rake gblsci:images:harvest_failed_state_inspect
|
160
|
+
bundle exec rake gblsci:images:harvest_failed_state_inspect
|
161
161
|
```
|
162
162
|
|
163
163
|
## Prioritize Solr Thumbnail Field URIs
|
@@ -31,8 +31,8 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_development_dependency 'database_cleaner', '~> 1.3'
|
32
32
|
s.add_development_dependency 'engine_cart', '~> 1.0'
|
33
33
|
s.add_development_dependency 'rspec-rails', '~> 3.0'
|
34
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
35
|
-
s.add_development_dependency 'rubocop-rspec', '~> 1.
|
34
|
+
s.add_development_dependency 'rubocop', '~> 0.60.0'
|
35
|
+
s.add_development_dependency 'rubocop-rspec', '~> 1.30.0'
|
36
36
|
s.add_development_dependency 'selenium-webdriver'
|
37
37
|
s.add_development_dependency 'solr_wrapper'
|
38
38
|
end
|
@@ -5,9 +5,9 @@ class StoreImageJob < ApplicationJob
|
|
5
5
|
|
6
6
|
def perform(solr_document_id)
|
7
7
|
cat = CatalogController.new
|
8
|
-
|
8
|
+
_response, document = cat.fetch(solr_document_id)
|
9
9
|
|
10
|
-
metadata =
|
10
|
+
metadata = {}
|
11
11
|
metadata['solr_doc_id'] = document.id
|
12
12
|
metadata['solr_version'] = document.sidecar.version
|
13
13
|
|
data/lib/generators/geoblacklight_sidecar_images/templates/models/sidecar_image_state_machine.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class SidecarImageStateMachine
|
2
4
|
include Statesman::Machine
|
3
5
|
|
@@ -10,10 +12,10 @@ class SidecarImageStateMachine
|
|
10
12
|
|
11
13
|
# Queued => Background Job Init
|
12
14
|
# Processing => Failed, Placeheld, Succeeded
|
13
|
-
transition from: :initialized, to: [
|
14
|
-
transition from: :queued, to: [
|
15
|
-
transition from: :processing, to: [
|
16
|
-
transition from: :placeheld, to: [
|
17
|
-
transition from: :failed, to: [
|
18
|
-
transition from: :succeeded, to: [
|
15
|
+
transition from: :initialized, to: %i[queued processing]
|
16
|
+
transition from: :queued, to: %i[queued processing]
|
17
|
+
transition from: :processing, to: %i[queued processing placeheld succeeded failed]
|
18
|
+
transition from: :placeheld, to: %i[queued processing]
|
19
|
+
transition from: :failed, to: %i[queued processing]
|
20
|
+
transition from: :succeeded, to: %i[queued processing]
|
19
21
|
end
|
@@ -21,7 +21,7 @@ class SolrDocumentSidecar < ApplicationRecord
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def image_state
|
24
|
-
@
|
24
|
+
@image_state ||= SidecarImageStateMachine.new(
|
25
25
|
self,
|
26
26
|
transition_class: SidecarImageTransition
|
27
27
|
)
|
@@ -36,7 +36,7 @@ class SolrDocumentSidecar < ApplicationRecord
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.image_url
|
39
|
-
Rails.application.routes.url_helpers.rails_blob_path(
|
39
|
+
Rails.application.routes.url_helpers.rails_blob_path(image, only_path: true)
|
40
40
|
end
|
41
41
|
|
42
42
|
private_class_method :initial_state
|
@@ -44,7 +44,7 @@ class SolrDocumentSidecar < ApplicationRecord
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def reimage
|
47
|
-
|
48
|
-
StoreImageJob.perform_later(
|
47
|
+
image.purge if image.attached?
|
48
|
+
StoreImageJob.perform_later(document.id)
|
49
49
|
end
|
50
50
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require
|
2
|
+
|
3
|
+
require 'addressable/uri'
|
4
|
+
require 'mimemagic'
|
4
5
|
|
5
6
|
class ImageService
|
6
7
|
attr_reader :document
|
@@ -9,7 +10,7 @@ class ImageService
|
|
9
10
|
def initialize(document)
|
10
11
|
@document = document
|
11
12
|
|
12
|
-
@metadata =
|
13
|
+
@metadata = {}
|
13
14
|
@metadata['solr_doc_id'] = document.id
|
14
15
|
@metadata['solr_version'] = @document.sidecar.version
|
15
16
|
@metadata['placeheld'] = false
|
@@ -18,9 +19,7 @@ class ImageService
|
|
18
19
|
|
19
20
|
@logger ||= ActiveSupport::TaggedLogging.new(
|
20
21
|
Logger.new(
|
21
|
-
|
22
|
-
Rails.root, '/log/', "image_service_#{Rails.env}.log"
|
23
|
-
)
|
22
|
+
Rails.root.join('log', "image_service_#{Rails.env}.log")
|
24
23
|
)
|
25
24
|
)
|
26
25
|
end
|
@@ -36,29 +35,11 @@ class ImageService
|
|
36
35
|
|
37
36
|
if io_file.nil? || @metadata['placeheld'] == true
|
38
37
|
@document.sidecar.image_state.transition_to!(:placeheld, @metadata)
|
39
|
-
log_output
|
40
38
|
else
|
41
|
-
|
42
|
-
# Pull the mimetype and file extension via MimeMagic
|
43
|
-
mm = MimeMagic.by_magic(File.open(io_file))
|
44
|
-
|
45
|
-
@metadata['MimeMagic_type'] = mm.type
|
46
|
-
@metadata['MimeMagic_mediatype'] = mm.mediatype
|
47
|
-
@metadata['MimeMagic_subtype'] = mm.subtype
|
48
|
-
|
49
|
-
if mm.mediatype == "image"
|
50
|
-
@document.sidecar.image.attach(
|
51
|
-
io: io_file,
|
52
|
-
filename: "#{@document.id}.#{mm.subtype}",
|
53
|
-
content_type: mm.type
|
54
|
-
)
|
55
|
-
@document.sidecar.image_state.transition_to!(:succeeded, @metadata)
|
56
|
-
else
|
57
|
-
@document.sidecar.image_state.transition_to!(:placeheld, @metadata)
|
58
|
-
end
|
59
|
-
|
60
|
-
log_output
|
39
|
+
attach_io(io_file)
|
61
40
|
end
|
41
|
+
|
42
|
+
log_output
|
62
43
|
rescue Exception => invalid
|
63
44
|
@metadata['exception'] = invalid.inspect
|
64
45
|
@document.sidecar.image_state.transition_to!(:failed, @metadata)
|
@@ -74,22 +55,42 @@ class ImageService
|
|
74
55
|
@metadata['service_url'] = service_url
|
75
56
|
@metadata['gblsi_thumbnail_uri'] = gblsi_thumbnail_uri
|
76
57
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
58
|
+
return nil unless image_data && @metadata['placeheld'] == false
|
59
|
+
|
60
|
+
temp_file = Tempfile.new([document_id, '.tmp'])
|
61
|
+
temp_file.binmode
|
62
|
+
temp_file.write(image_data)
|
63
|
+
temp_file.rewind
|
64
|
+
|
65
|
+
@metadata['image_tempfile'] = temp_file.inspect
|
66
|
+
temp_file
|
67
|
+
end
|
68
|
+
|
69
|
+
def attach_io(io)
|
70
|
+
# Remote content-type headers are untrustworthy
|
71
|
+
# Pull the mimetype and file extension via MimeMagic
|
72
|
+
mm = MimeMagic.by_magic(File.open(io))
|
82
73
|
|
83
|
-
|
84
|
-
|
74
|
+
@metadata['MimeMagic_type'] = mm.type
|
75
|
+
@metadata['MimeMagic_mediatype'] = mm.mediatype
|
76
|
+
@metadata['MimeMagic_subtype'] = mm.subtype
|
77
|
+
|
78
|
+
if mm.mediatype == 'image'
|
79
|
+
@document.sidecar.image.attach(
|
80
|
+
io: io,
|
81
|
+
filename: "#{@document.id}.#{mm.subtype}",
|
82
|
+
content_type: mm.type
|
83
|
+
)
|
84
|
+
@document.sidecar.image_state.transition_to!(:succeeded, @metadata)
|
85
85
|
else
|
86
|
-
|
86
|
+
@document.sidecar.image_state.transition_to!(:placeheld, @metadata)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
# Returns geoserver auth credentials if the document is a restriced Local WMS layer.
|
91
91
|
def geoserver_credentials
|
92
92
|
return unless restricted_wms_layer?
|
93
|
+
|
93
94
|
Settings.PROXY_GEOSERVER_AUTH.gsub('Basic ', '')
|
94
95
|
end
|
95
96
|
|
@@ -114,6 +115,7 @@ class ImageService
|
|
114
115
|
# Generates hash containing thumbnail mime_type and image.
|
115
116
|
def image_data
|
116
117
|
return nil unless image_url
|
118
|
+
|
117
119
|
remote_image
|
118
120
|
end
|
119
121
|
|
@@ -123,26 +125,24 @@ class ImageService
|
|
123
125
|
|
124
126
|
uri = Addressable::URI.parse(image_url)
|
125
127
|
|
126
|
-
|
127
|
-
conn = Faraday.new(url: uri.normalize.to_s) do |b|
|
128
|
-
b.use FaradayMiddleware::FollowRedirects
|
129
|
-
b.adapter :net_http
|
130
|
-
end
|
128
|
+
return nil unless uri.scheme.include?('http')
|
131
129
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
else
|
136
|
-
return nil
|
130
|
+
conn = Faraday.new(url: uri.normalize.to_s) do |b|
|
131
|
+
b.use FaradayMiddleware::FollowRedirects
|
132
|
+
b.adapter :net_http
|
137
133
|
end
|
134
|
+
|
135
|
+
conn.options.timeout = timeout
|
136
|
+
conn.authorization :Basic, auth if auth
|
137
|
+
conn.get.body
|
138
138
|
rescue Faraday::Error::ConnectionFailed
|
139
|
-
@metadata['error'] =
|
139
|
+
@metadata['error'] = 'Faraday::Error::ConnectionFailed'
|
140
140
|
@metadata['placeheld'] = true
|
141
|
-
|
141
|
+
nil
|
142
142
|
rescue Faraday::Error::TimeoutError
|
143
|
-
@metadata['error'] =
|
143
|
+
@metadata['error'] = 'Faraday::Error::TimeoutError'
|
144
144
|
@metadata['placeheld'] = true
|
145
|
-
|
145
|
+
nil
|
146
146
|
end
|
147
147
|
|
148
148
|
# Returns the thumbnail url.
|
@@ -179,25 +179,28 @@ class ImageService
|
|
179
179
|
# from the viewer protocol, and if it's loaded, the image_url
|
180
180
|
# method is called.
|
181
181
|
def service_url
|
182
|
-
@service_url ||=
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
182
|
+
@service_url ||=
|
183
|
+
begin
|
184
|
+
return unless @document.available?
|
185
|
+
|
186
|
+
protocol = @document.viewer_protocol
|
187
|
+
if protocol == 'map' || protocol.nil?
|
188
|
+
@metadata['error'] = 'Unsupported viewer protocol'
|
189
|
+
@metadata['placeheld'] = true
|
190
|
+
return nil
|
191
|
+
end
|
192
|
+
"ImageService::#{protocol.camelcase}".constantize.image_url(@document, image_size)
|
193
|
+
rescue NameError
|
194
|
+
@metadata['error'] = 'service_url NameError'
|
187
195
|
@metadata['placeheld'] = true
|
188
196
|
return nil
|
189
197
|
end
|
190
|
-
"ImageService::#{protocol.camelcase}".constantize.image_url(@document, image_size)
|
191
|
-
rescue NameError
|
192
|
-
@metadata['error'] = "service_url NameError"
|
193
|
-
@metadata['placeheld'] = true
|
194
|
-
return nil
|
195
|
-
end
|
196
198
|
end
|
197
199
|
|
198
200
|
# Retreives a url to a static thumbnail from the document's dct_references field, if it exists.
|
199
201
|
def image_reference
|
200
202
|
return nil if @document[@document.references.reference_field].nil?
|
203
|
+
|
201
204
|
JSON.parse(@document[@document.references.reference_field])['http://schema.org/thumbnailUrl']
|
202
205
|
end
|
203
206
|
|
@@ -213,8 +216,8 @@ class ImageService
|
|
213
216
|
|
214
217
|
# Capture metadata within image harvest log
|
215
218
|
def log_output
|
216
|
-
@metadata[
|
217
|
-
@metadata.each do |key,value|
|
219
|
+
@metadata['state'] = @document.sidecar.image_state.current_state
|
220
|
+
@metadata.each do |key, value|
|
218
221
|
@logger.tagged(@document.id, key.to_s) { @logger.info value }
|
219
222
|
end
|
220
223
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
2
4
|
|
3
5
|
describe StoreImageJob, type: :job do
|
4
6
|
let(:document) { SolrDocument.new(document_attributes) }
|
5
7
|
|
6
|
-
describe
|
8
|
+
describe '#perform_later' do
|
7
9
|
let(:document_attributes) { json_data('umn_iiif_jpg') }
|
8
10
|
|
9
|
-
it
|
11
|
+
it 'stores an image' do
|
10
12
|
ActiveJob::Base.queue_adapter = :test
|
11
|
-
expect {
|
12
|
-
StoreImageJob.perform_later(document.id)
|
13
|
-
}.to have_enqueued_job
|
13
|
+
expect { StoreImageJob.perform_later(document.id) }.to have_enqueued_job(StoreImageJob)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/spec/rails_helper.rb
CHANGED
@@ -40,7 +40,7 @@ RSpec.configure do |config|
|
|
40
40
|
DatabaseCleaner.clean_with :truncation
|
41
41
|
end
|
42
42
|
|
43
|
-
config.before
|
43
|
+
config.before do
|
44
44
|
DatabaseCleaner.strategy = if Capybara.current_driver == :rack_test
|
45
45
|
:transaction
|
46
46
|
else
|
@@ -49,7 +49,7 @@ RSpec.configure do |config|
|
|
49
49
|
DatabaseCleaner.start
|
50
50
|
end
|
51
51
|
|
52
|
-
config.after
|
52
|
+
config.after do
|
53
53
|
DatabaseCleaner.clean
|
54
54
|
end
|
55
55
|
|
@@ -4,34 +4,43 @@ require 'rails_helper'
|
|
4
4
|
|
5
5
|
describe ImageService do
|
6
6
|
let(:iiif_document) { SolrDocument.new(json_data('umich_iiif_jpg')) }
|
7
|
-
let(:iiif_imgsvc) {
|
7
|
+
let(:iiif_imgsvc) { described_class.new(iiif_document) }
|
8
8
|
let(:wms_document) { SolrDocument.new(json_data('public_polygon_mit')) }
|
9
|
-
let(:wms_imgsvc) {
|
9
|
+
let(:wms_imgsvc) { described_class.new(wms_document) }
|
10
10
|
let(:thumb_document) { SolrDocument.new(json_data('umn_solr_thumb')) }
|
11
|
-
let(:thumb_imgsvc) {
|
11
|
+
let(:thumb_imgsvc) { described_class.new(thumb_document) }
|
12
12
|
|
13
13
|
# @TODO: bdcbcd3e-f6db-4ee4-b7b7-d75fe35f1d92 - Michigan State - thumbnail_path_ss
|
14
14
|
|
15
15
|
describe '#store' do
|
16
|
-
it '
|
16
|
+
it 'responds to store' do
|
17
17
|
expect(iiif_imgsvc).to respond_to(:store)
|
18
18
|
end
|
19
19
|
|
20
|
-
it '
|
20
|
+
it 'prioritizes settings thumbnail field' do
|
21
21
|
expect(thumb_imgsvc.send(:gblsi_thumbnail_field?)).to be_truthy
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns image_url' do
|
22
25
|
expect(thumb_imgsvc.send(:image_url)).to eq 'https://umedia.lib.umn.edu/sites/default/files/imagecache/square300/reference/562/image/jpeg/1089695.jpg'
|
23
26
|
end
|
24
27
|
|
25
|
-
it '
|
28
|
+
it 'returns references if no settings thumbnail field value' do
|
26
29
|
expect(wms_imgsvc.send(:gblsi_thumbnail_field?)).to be_truthy
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns references without a settings thumbnail field value' do
|
27
33
|
expect(wms_imgsvc.send(:image_url)).to include 'wms'
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
context '#iiif' do
|
37
|
+
context 'when #iiif' do
|
32
38
|
describe '#private' do
|
33
|
-
it '
|
39
|
+
it 'determines :image_url' do
|
34
40
|
expect(iiif_imgsvc.send(:image_url)).to be_kind_of String
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns a URI' do
|
35
44
|
expect(URI(iiif_imgsvc.send(:image_url))).to be_kind_of URI
|
36
45
|
end
|
37
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoblacklight_sidecar_images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Larson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-11-
|
12
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: geoblacklight
|
@@ -191,28 +191,28 @@ dependencies:
|
|
191
191
|
requirements:
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
194
|
+
version: 0.60.0
|
195
195
|
type: :development
|
196
196
|
prerelease: false
|
197
197
|
version_requirements: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 0.
|
201
|
+
version: 0.60.0
|
202
202
|
- !ruby/object:Gem::Dependency
|
203
203
|
name: rubocop-rspec
|
204
204
|
requirement: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 1.
|
208
|
+
version: 1.30.0
|
209
209
|
type: :development
|
210
210
|
prerelease: false
|
211
211
|
version_requirements: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: 1.
|
215
|
+
version: 1.30.0
|
216
216
|
- !ruby/object:Gem::Dependency
|
217
217
|
name: selenium-webdriver
|
218
218
|
requirement: !ruby/object:Gem::Requirement
|