Skip to content

Commit

Permalink
Merge pull request #127 from curationexperts/rails6
Browse files Browse the repository at this point in the history
Test against Rails 5 and 6
  • Loading branch information
jcoyne authored Oct 31, 2019
2 parents 0a67cdd + 8420b3c commit 2c812f4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ before_install:
- gem update --system

rvm:
- 2.4.0
- 2.6.3

env:
- "RAILS_VERSION=5.2.3"
- "RAILS_VERSION=6.0.0"

sudo: false
language: ruby
dist: trusty
9 changes: 1 addition & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ else
end
end

case ENV['RAILS_VERSION']
when /^4.2/
gem 'responders', '~> 2.0'
gem 'sass-rails', '>= 5.0'
gem 'coffee-rails', '~> 4.1.0'
when /^4.[01]/
gem 'sass-rails', '< 5.0'
end
gem 'sass-rails', '~> 5.0'
end
# END ENGINE_CART BLOCK
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ When the Id passed in is "foo_image", then it will look for an image file using
### Images retrieved over HTTP
It's preferable to use files on the filesystem, because this avoids the overhead of downloading the file. If this is unavoidable, Riiif can be configured to fetch files from the network. To enable this behavior, configure Riiif to use an alternative resolver:
```
Riiif::Image.file_resolver = Riiif::HTTPFileResolver.new
Riiif::Image.file_resolver = Riiif::HttpFileResolver.new
```
Then we configure the resolver with a mechanism for mapping the provided id to a url:
```
Expand Down Expand Up @@ -154,7 +154,7 @@ Create an initializer like this in `config/initializers/riiif_initializer.rb`

```ruby
# Tell RIIIF to get files via HTTP (not from the local disk)
Riiif::Image.file_resolver = Riiif::HTTPFileResolver.new
Riiif::Image.file_resolver = Riiif::HttpFileResolver.new

# This tells RIIIF how to resolve the identifier to a URI in Fedora
Riiif::Image.file_resolver.id_to_uri = lambda do |id|
Expand Down
4 changes: 2 additions & 2 deletions app/resolvers/riiif/http_file_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
require 'active_support/core_ext/file/atomic'

module Riiif
class HTTPFileResolver
class HttpFileResolver
# Set a lambda that maps the first parameter (id) to a URL
# Example:
#
# resolver = Riiif::HTTPFileResolver.new
# resolver = Riiif::HttpFileResolver.new
# resolver.id_to_uri = lambda do |id|
# "http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/#{id}.jpg/600px-#{id}.jpg"
# end
Expand Down
2 changes: 2 additions & 0 deletions lib/riiif.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ImageNotFoundError < Error; end
# This error is raised when Riiif can't convert an image
class ConversionError < Error; end

HTTPFileResolver = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Riiif::HTTPFileResolver', 'Riiif::HttpFileResolver')

mattr_accessor :not_found_image # the image to use when a lookup fails
mattr_accessor :unauthorized_image # the image to use when a user doesn't have access

Expand Down
2 changes: 1 addition & 1 deletion riiif.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_dependency 'railties', '>= 4.2', '<6'
spec.add_dependency 'railties', '>= 4.2', '<7'
spec.add_dependency 'deprecation', '>= 1.0.0'
spec.add_dependency 'iiif-image-api', '~> 0.1.0'
spec.add_development_dependency 'bundler'
Expand Down
2 changes: 1 addition & 1 deletion spec/models/riiif/http_file_resolver_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Riiif::HTTPFileResolver do
describe Riiif::HttpFileResolver do
subject { described_class.new }

before do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/riiif/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
end
end

context 'using HTTPFileResolver' do
context 'using HttpFileResolver' do
before do
described_class.file_resolver = Riiif::HTTPFileResolver.new
described_class.file_resolver = Riiif::HttpFileResolver.new
described_class.file_resolver.id_to_uri = lambda do |id|
"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/#{id}.jpg/600px-#{id}.jpg"
end
Expand Down

0 comments on commit 2c812f4

Please sign in to comment.