From 8b8eeebe9d9abfd40ea141fc6e5eadb3b3565e42 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Wed, 30 Oct 2019 16:36:30 -0700 Subject: [PATCH 1/4] Test against Rails 5 and 6 --- .travis.yml | 6 +++++- Gemfile | 8 ++------ riiif.gemspec | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd20622..ac64449 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,11 @@ 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 diff --git a/Gemfile b/Gemfile index a994fc3..552ce19 100644 --- a/Gemfile +++ b/Gemfile @@ -29,12 +29,8 @@ else 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' + when /^5\./ + gem 'sass-rails', '~> 5.0' end end # END ENGINE_CART BLOCK diff --git a/riiif.gemspec b/riiif.gemspec index 57facb0..c22039b 100644 --- a/riiif.gemspec +++ b/riiif.gemspec @@ -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' From a5412a53558f2f19f609ddcd09e2d27fc3f188e0 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 31 Oct 2019 10:56:12 -0700 Subject: [PATCH 2/4] Try pinning travis to trusty --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ac64449..8465265 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,4 @@ env: sudo: false language: ruby +dist: trusty From 7ec63cd4bea5347485178bd7e1d7683029253767 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 31 Oct 2019 11:10:05 -0700 Subject: [PATCH 3/4] Pin to sass-rails 5 for now --- Gemfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 552ce19..59d0913 100644 --- a/Gemfile +++ b/Gemfile @@ -28,9 +28,6 @@ else end end - case ENV['RAILS_VERSION'] - when /^5\./ - gem 'sass-rails', '~> 5.0' - end + gem 'sass-rails', '~> 5.0' end # END ENGINE_CART BLOCK From 8420b3cda694ba46cff0ff1e99bc49cb8ef62550 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 31 Oct 2019 13:25:58 -0700 Subject: [PATCH 4/4] Rename HTTPFileResolver => HttpFileResolver to match Zeitwerk conventions --- README.md | 4 ++-- app/resolvers/riiif/http_file_resolver.rb | 4 ++-- lib/riiif.rb | 2 ++ spec/models/riiif/http_file_resolver_spec.rb | 2 +- spec/models/riiif/image_spec.rb | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 954df07..bbc4c4b 100644 --- a/README.md +++ b/README.md @@ -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: ``` @@ -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| diff --git a/app/resolvers/riiif/http_file_resolver.rb b/app/resolvers/riiif/http_file_resolver.rb index 6b2dacc..397568e 100644 --- a/app/resolvers/riiif/http_file_resolver.rb +++ b/app/resolvers/riiif/http_file_resolver.rb @@ -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 diff --git a/lib/riiif.rb b/lib/riiif.rb index 08137da..1b4b3c7 100644 --- a/lib/riiif.rb +++ b/lib/riiif.rb @@ -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 diff --git a/spec/models/riiif/http_file_resolver_spec.rb b/spec/models/riiif/http_file_resolver_spec.rb index 3695211..6899f3d 100644 --- a/spec/models/riiif/http_file_resolver_spec.rb +++ b/spec/models/riiif/http_file_resolver_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Riiif::HTTPFileResolver do +describe Riiif::HttpFileResolver do subject { described_class.new } before do diff --git a/spec/models/riiif/image_spec.rb b/spec/models/riiif/image_spec.rb index 43caad6..a089965 100644 --- a/spec/models/riiif/image_spec.rb +++ b/spec/models/riiif/image_spec.rb @@ -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