riiif 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aef3da010f8f0debef74aab318475a9563005c3904544ee159567b904e51c610
4
- data.tar.gz: 53c1e7c6ffcd6f9b345fae4f4bb295059e8ff280c449e4e3eec1959e9ae36126
3
+ metadata.gz: b5d2036dfb026731136b7eba93e3ede1943246aeac921a6db93cc76c6a1cfa8f
4
+ data.tar.gz: fd36f9c29b4beffb389259f3c1d66650f6f2b9963f0c243cfb6f0140736b72e7
5
5
  SHA512:
6
- metadata.gz: 3326d9199c7bf9f3e3b51da13d8a1cd9abd4c5b8633f451c92e17c57eea39698c5bdc2d5192d71bfd00ab8d721076377e18bb60241e93bb9d8a6dbb01fb941d9
7
- data.tar.gz: 700b1ee4398a39f444593ddc01067784448007df22a4e4a87df06bacc886a466f3d7de5694bccd4d77fda3aab9835e672c66d376b5b6bfca7bb302d41be839d4
6
+ metadata.gz: 25e4d827a9033f80d3a803c3b47891b703bfc27dbff125b464b3a0096f6900c8f90eeb42e59bd80e7c59c79d2fe75e000adb69932489840899b52cea8aeba1c2
7
+ data.tar.gz: f226dd80245c3f7aebd8923980ef54d31faa3abf4829fc530ad297991642b1235c346c219dbb2bbbeaf6936d6e4979bca976b977f2271a01b8a6b2369dfccf5e
@@ -0,0 +1,42 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: CI
9
+
10
+ on:
11
+ push:
12
+ branches:
13
+ - master
14
+ pull_request:
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby: ['2.7', '3.0']
22
+ rails: ['6.1.4.6', '7.0.2.2']
23
+ include:
24
+ - ruby: '2.7'
25
+ rails: '5.2.3'
26
+ - ruby: '2.7'
27
+ rails: '6.0.0'
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ - name: Set up Ruby
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ - name: Install dependencies
35
+ run: bundle install
36
+ env:
37
+ RAILS_VERSION: ${{ matrix.rails }}
38
+ - name: Run tests
39
+ run: bundle exec rake
40
+ env:
41
+ RAILS_VERSION: ${{ matrix.rails }}
42
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
data/.rubocop_todo.yml CHANGED
@@ -1,16 +1,54 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-02-23 11:28:05 -0600 using RuboCop version 0.52.1.
3
+ # on 2022-02-28 10:01:41 -0800 using RuboCop version 0.85.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 2
9
+ # Offense count: 6
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
12
+ # SupportedHashRocketStyles: key, separator, table
13
+ # SupportedColonStyles: key, separator, table
14
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
15
+ Layout/HashAlignment:
16
+ Exclude:
17
+ - 'spec/controllers/riiif/images_controller_spec.rb'
18
+
19
+ # Offense count: 62
20
+ # Cop supports --auto-correct.
21
+ # Configuration parameters: EnforcedStyle.
22
+ # SupportedStyles: normal, indented_internal_methods
23
+ Layout/IndentationConsistency:
24
+ Exclude:
25
+ - 'app/controllers/riiif/images_controller.rb'
26
+ - 'app/resolvers/riiif/file_system_file_resolver.rb'
27
+ - 'app/resolvers/riiif/http_file_resolver.rb'
28
+ - 'app/services/riiif/crop.rb'
29
+ - 'app/services/riiif/imagemagick_command_factory.rb'
30
+ - 'app/services/riiif/kakadu_command_factory.rb'
31
+ - 'app/services/riiif/resize.rb'
32
+ - 'app/transformers/riiif/kakadu_transformer.rb'
33
+
34
+ # Offense count: 62
35
+ # Cop supports --auto-correct.
36
+ # Configuration parameters: Width, IgnoredPatterns.
37
+ Layout/IndentationWidth:
38
+ Exclude:
39
+ - 'app/controllers/riiif/images_controller.rb'
40
+ - 'app/resolvers/riiif/file_system_file_resolver.rb'
41
+ - 'app/resolvers/riiif/http_file_resolver.rb'
42
+ - 'app/services/riiif/crop.rb'
43
+ - 'app/services/riiif/imagemagick_command_factory.rb'
44
+ - 'app/services/riiif/kakadu_command_factory.rb'
45
+ - 'app/services/riiif/resize.rb'
46
+ - 'app/transformers/riiif/kakadu_transformer.rb'
47
+
48
+ # Offense count: 1
10
49
  # Configuration parameters: AllowSafeAssignment.
11
50
  Lint/AssignmentInCondition:
12
51
  Exclude:
13
- - 'app/models/riiif/file.rb'
14
52
  - 'app/resolvers/riiif/http_file_resolver.rb'
15
53
 
16
54
  # Offense count: 1
@@ -18,27 +56,26 @@ Lint/DuplicateMethods:
18
56
  Exclude:
19
57
  - 'app/resolvers/riiif/http_file_resolver.rb'
20
58
 
21
- # Offense count: 1
22
- Lint/HandleExceptions:
59
+ # Offense count: 2
60
+ # Configuration parameters: AllowComments.
61
+ Lint/SuppressedException:
23
62
  Exclude:
63
+ - 'app/controllers/riiif/images_controller.rb'
24
64
  - 'spec/models/riiif/http_file_resolver_spec.rb'
25
65
 
26
- # Offense count: 1
27
- Lint/UselessAssignment:
28
- Exclude:
29
- - 'app/models/riiif/file.rb'
30
-
31
66
  # Offense count: 21
32
67
  # Configuration parameters: CountComments, ExcludedMethods.
68
+ # ExcludedMethods: refine
33
69
  Metrics/BlockLength:
34
- Max: 233
70
+ Max: 237
35
71
 
36
72
  # Offense count: 1
73
+ # Configuration parameters: IgnoredMethods.
37
74
  Metrics/CyclomaticComplexity:
38
75
  Max: 7
39
76
 
40
77
  # Offense count: 3
41
- # Configuration parameters: CountComments.
78
+ # Configuration parameters: CountComments, ExcludedMethods.
42
79
  Metrics/MethodLength:
43
80
  Max: 18
44
81
 
@@ -47,12 +84,20 @@ Metrics/MethodLength:
47
84
  Metrics/ParameterLists:
48
85
  Max: 6
49
86
 
87
+ # Offense count: 3
88
+ # Cop supports --auto-correct.
89
+ Performance/RegexpMatch:
90
+ Exclude:
91
+ - 'app/resolvers/riiif/file_system_file_resolver.rb'
92
+ - 'app/services/riiif/imagemagick_command_factory.rb'
93
+
50
94
  # Offense count: 1
51
95
  RSpec/DescribeClass:
52
96
  Exclude:
53
97
  - 'spec/routing/resize_routes_spec.rb'
54
98
 
55
99
  # Offense count: 2
100
+ # Cop supports --auto-correct.
56
101
  # Configuration parameters: SkipBlocks, EnforcedStyle.
57
102
  # SupportedStyles: described_class, explicit
58
103
  RSpec/DescribedClass:
@@ -67,9 +112,11 @@ RSpec/ExampleLength:
67
112
  - 'spec/models/riiif/http_file_resolver_spec.rb'
68
113
  - 'spec/transformers/riiif/kakadu_transformer_spec.rb'
69
114
 
70
- # Offense count: 1
115
+ # Offense count: 2
116
+ # Cop supports --auto-correct.
71
117
  RSpec/LeadingSubject:
72
118
  Exclude:
119
+ - 'spec/controllers/riiif/images_controller_spec.rb'
73
120
  - 'spec/transformers/riiif/kakadu_transformer_spec.rb'
74
121
 
75
122
  # Offense count: 43
@@ -78,7 +125,8 @@ RSpec/LeadingSubject:
78
125
  RSpec/MessageSpies:
79
126
  EnforcedStyle: receive
80
127
 
81
- # Offense count: 23
128
+ # Offense count: 24
129
+ # Configuration parameters: IgnoreSharedExamples.
82
130
  RSpec/NamedSubject:
83
131
  Exclude:
84
132
  - 'spec/controllers/riiif/images_controller_spec.rb'
@@ -93,18 +141,51 @@ RSpec/RepeatedExample:
93
141
  - 'spec/controllers/riiif/images_controller_spec.rb'
94
142
 
95
143
  # Offense count: 7
96
- # Configuration parameters: IgnoreSymbolicNames.
144
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
97
145
  RSpec/VerifiedDoubles:
98
146
  Exclude:
99
147
  - 'spec/controllers/riiif/images_controller_spec.rb'
100
148
  - 'spec/services/riiif/imagemagick_command_factory_spec.rb'
101
149
  - 'spec/services/riiif/kakadu_command_factory_spec.rb'
102
150
 
151
+ # Offense count: 2
152
+ # Cop supports --auto-correct.
153
+ # Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
154
+ Rails/Blank:
155
+ Exclude:
156
+ - 'spec/controllers/riiif/images_controller_spec.rb'
157
+
103
158
  # Offense count: 1
159
+ # Configuration parameters: EnforcedStyle.
160
+ # SupportedStyles: slashes, arguments
104
161
  Rails/FilePath:
105
162
  Exclude:
106
163
  - 'spec/models/riiif/akubra_system_file_resolver_spec.rb'
107
164
 
165
+ # Offense count: 37
166
+ # Cop supports --auto-correct.
167
+ # Configuration parameters: EnforcedStyle.
168
+ # SupportedStyles: always, always_true, never
169
+ Style/FrozenStringLiteralComment:
170
+ Enabled: false
171
+
172
+ # Offense count: 2
173
+ # Cop supports --auto-correct.
174
+ # Configuration parameters: EnforcedStyle.
175
+ # SupportedStyles: literals, strict
176
+ Style/MutableConstant:
177
+ Exclude:
178
+ - 'lib/riiif/routes.rb'
179
+
180
+ # Offense count: 1
181
+ # Cop supports --auto-correct.
182
+ # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
183
+ # SupportedStyles: predicate, comparison
184
+ Style/NumericPredicate:
185
+ Exclude:
186
+ - 'spec/**/*'
187
+ - 'app/services/riiif/imagemagick_command_factory.rb'
188
+
108
189
  # Offense count: 4
109
190
  # Cop supports --auto-correct.
110
191
  # Configuration parameters: PreferredDelimiters.
@@ -114,3 +195,15 @@ Style/PercentLiteralDelimiters:
114
195
  - 'app/resolvers/riiif/file_system_file_resolver.rb'
115
196
  - 'spec/controllers/riiif/images_controller_spec.rb'
116
197
  - 'spec/models/riiif/http_file_resolver_spec.rb'
198
+
199
+ # Offense count: 1
200
+ # Cop supports --auto-correct.
201
+ Style/RedundantBegin:
202
+ Exclude:
203
+ - 'app/resolvers/riiif/http_file_resolver.rb'
204
+
205
+ # Offense count: 1
206
+ # Cop supports --auto-correct.
207
+ Style/RedundantFreeze:
208
+ Exclude:
209
+ - 'app/services/riiif/imagemagick_command_factory.rb'
@@ -14,7 +14,7 @@ module Riiif
14
14
 
15
15
  # @return [Boolean] true if the id matches the regex
16
16
  def validate_identifier(id:, regex: identifier_regex)
17
- return true if id =~ regex
17
+ return true if id.to_s =~ regex
18
18
  Rails.logger.warn "Invalid characters in id `#{id}`"
19
19
  false
20
20
  end
@@ -63,7 +63,7 @@ module Riiif
63
63
  benchmark("Riiif downloaded #{url}") do
64
64
  ::File.atomic_write(file_name, cache_path) do |local|
65
65
  begin
66
- Kernel.open(url, download_opts) do |remote|
66
+ handler.open(url, **download_opts) do |remote|
67
67
  while chunk = remote.read(8192)
68
68
  local.write(chunk)
69
69
  end
@@ -85,6 +85,14 @@ module Riiif
85
85
  def ensure_cache_path(path)
86
86
  FileUtils.makedirs(path) unless ::File.exist?(path)
87
87
  end
88
+
89
+ def handler
90
+ if url.match?(URI.regexp)
91
+ URI
92
+ else
93
+ Kernel
94
+ end
95
+ end
88
96
  end
89
97
 
90
98
  protected
data/lib/riiif/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Riiif
2
- VERSION = '2.3.0'.freeze
2
+ VERSION = '2.4.0'.freeze
3
3
  end
data/riiif.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'railties', '>= 4.2', '<7'
21
+ spec.add_dependency 'railties', '>= 4.2', '<8'
22
22
  spec.add_dependency 'deprecation', '>= 1.0.0'
23
23
  spec.add_dependency 'iiif-image-api', '>= 0.1.0'
24
24
 
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'engine_cart', '~> 2.0'
28
28
  spec.add_development_dependency 'rspec-rails'
29
29
  spec.add_development_dependency 'sqlite3'
30
- spec.add_development_dependency 'bixby', '~> 1.0.0'
30
+ spec.add_development_dependency 'bixby', '~> 3.0'
31
31
  spec.add_development_dependency 'coveralls'
32
32
  end
@@ -24,9 +24,9 @@ RSpec.describe Riiif::ImagesController do
24
24
  it 'sends images to the service' do
25
25
  image = double
26
26
  expect(Riiif::Image).to receive(:new).with('abcd1234').and_return(image)
27
- expect(image).to receive(:render).with('region' => 'full', 'size' => 'full',
27
+ expect(image).to receive(:render).with({ 'region' => 'full', 'size' => 'full',
28
28
  'rotation' => '0', 'quality' => 'default',
29
- 'format' => 'jpg').and_return('IMAGEDATA')
29
+ 'format' => 'jpg' }).and_return('IMAGEDATA')
30
30
  get :show, params: { id: 'abcd1234', action: 'show', region: 'full', size: 'full',
31
31
  rotation: '0', quality: 'default', format: 'jpg' }
32
32
  expect(response).to be_successful
@@ -102,9 +102,9 @@ RSpec.describe Riiif::ImagesController do
102
102
  raise Riiif::ImageNotFoundError unless file.present?
103
103
  not_found_image
104
104
  end.twice
105
- expect(not_found_image).to receive(:render).with('region' => 'full', 'size' => 'full',
105
+ expect(not_found_image).to receive(:render).with({ 'region' => 'full', 'size' => 'full',
106
106
  'rotation' => '0', 'quality' => 'default',
107
- 'format' => 'jpg').and_return('default-image-data')
107
+ 'format' => 'jpg' }).and_return('default-image-data')
108
108
 
109
109
  get :show, params: { id: 'bad_id', action: 'show', region: 'full', size: 'full',
110
110
  rotation: '0', quality: 'default', format: 'jpg' }
@@ -118,9 +118,9 @@ RSpec.describe Riiif::ImagesController do
118
118
  raise Riiif::ImageNotFoundError unless file.present?
119
119
  not_found_image
120
120
  end.twice
121
- expect(not_found_image).to receive(:render).with('region' => 'full', 'size' => 'full',
121
+ expect(not_found_image).to receive(:render).with({ 'region' => 'full', 'size' => 'full',
122
122
  'rotation' => '0', 'quality' => 'default',
123
- 'format' => 'jpg').and_return('default-image-data')
123
+ 'format' => 'jpg' }).and_return('default-image-data')
124
124
 
125
125
  get :show, params: { id: 'bad_id', action: 'show', region: 'full', size: 'full',
126
126
  rotation: '0', quality: 'default', format: 'jpg' }
@@ -155,7 +155,7 @@ RSpec.describe Riiif::ImagesController do
155
155
  get :info, params: { id: 'abcd1234', format: 'json' }
156
156
  expect(response).to be_successful
157
157
  expect(json).to eq '@context' => 'http://iiif.io/api/image/2/context.json',
158
- '@id' => 'http://test.host/abcd1234',
158
+ '@id' => Rails.version > '6.1' ? 'http://test.host/images/abcd1234' : 'http://test.host/abcd1234',
159
159
  'width' => 6000,
160
160
  'height' => 4000,
161
161
  'format' => 'JPEG',
@@ -78,5 +78,12 @@ describe Riiif::FileSystemFileResolver do
78
78
  expect(subject).to be_nil
79
79
  end
80
80
  end
81
+
82
+ context 'as an integer' do
83
+ let(:id) { 1 }
84
+ it 'converts it to a string before parsing' do
85
+ expect { subject }.not_to raise_error
86
+ end
87
+ end
81
88
  end
82
89
  end
@@ -28,6 +28,9 @@ RSpec.describe Riiif::Image do
28
28
  end
29
29
 
30
30
  it 'is able to override the file used for the Image' do
31
+ allow(Riiif::CommandRunner).to receive(:execute)
32
+ .with("identify -format '%h %w %m %[channels]' #{filename}[0]").and_return('400 800')
33
+
31
34
  img = described_class.new('some_id', Riiif::File.new(filename))
32
35
  expect(img.id).to eq 'some_id'
33
36
  expect(img.info).to eq Riiif::ImageInformation.new(width: 800, height: 400)
@@ -35,6 +38,9 @@ RSpec.describe Riiif::Image do
35
38
 
36
39
  describe 'info' do
37
40
  it 'returns the data' do
41
+ allow(Riiif::CommandRunner).to receive(:execute)
42
+ .with("identify -format '%h %w %m %[channels]' #{filename}[0]").and_return('400 800')
43
+
38
44
  expect(subject.info).to eq Riiif::ImageInformation.new(width: 800, height: 400)
39
45
  end
40
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riiif
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-01 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: deprecation
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -134,14 +134,14 @@ dependencies:
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: 1.0.0
137
+ version: '3.0'
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 1.0.0
144
+ version: '3.0'
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: coveralls
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -163,11 +163,11 @@ executables: []
163
163
  extensions: []
164
164
  extra_rdoc_files: []
165
165
  files:
166
+ - ".github/workflows/ruby.yml"
166
167
  - ".gitignore"
167
168
  - ".rspec"
168
169
  - ".rubocop.yml"
169
170
  - ".rubocop_todo.yml"
170
- - ".travis.yml"
171
171
  - CHANGELOG
172
172
  - Gemfile
173
173
  - LICENSE
@@ -218,7 +218,7 @@ homepage: https://github.com/curationexperts/riiif
218
218
  licenses:
219
219
  - APACHE2
220
220
  metadata: {}
221
- post_install_message:
221
+ post_install_message:
222
222
  rdoc_options: []
223
223
  require_paths:
224
224
  - lib
@@ -233,8 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubygems_version: 3.1.2
237
- signing_key:
236
+ rubygems_version: 3.2.32
237
+ signing_key:
238
238
  specification_version: 4
239
239
  summary: A rails engine that support IIIF requests
240
240
  test_files:
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- notifications:
2
- email: false
3
-
4
- before_install:
5
- - gem update --system
6
-
7
- rvm:
8
- - 2.6.3
9
-
10
- env:
11
- - "RAILS_VERSION=5.2.3"
12
- - "RAILS_VERSION=6.0.0"
13
-
14
- sudo: false
15
- language: ruby
16
- dist: trusty