Skip to content

Commit

Permalink
Rename HTTPFileResolver => HttpFileResolver to match Zeitwerk convent…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
cbeer committed Oct 31, 2019
1 parent 7ec63cd commit 8420b3c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
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 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 8420b3c

Please sign in to comment.