From 8420b3cda694ba46cff0ff1e99bc49cb8ef62550 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 31 Oct 2019 13:25:58 -0700 Subject: [PATCH] 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