riiif 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/riiif/image.rb +15 -2
- data/config/routes.rb +5 -2
- data/lib/riiif/version.rb +1 -1
- data/spec/routing/resize_routes_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b43fe6591b40519b5eaf7678c4b732bcae87e79
|
4
|
+
data.tar.gz: 2c0d7e9b9e59f6e2886ab0830f3479bb09cabd29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed34ce6c02744acc1cc74ea0d66ec2361aaca0578bfb9e6cc9742826088ac2edc7bef6f4755247f808d266b1eb659fcd08821797e548e0d4728a291d09f1c85
|
7
|
+
data.tar.gz: 173080fd02eab35a999c52fdddf229ff416509c03471e0cdb666dfc5f26045fe6e2289cbbdcdbd22bc7210b481e3c1788b380930a98da2959a47aedc86a62df6
|
data/app/models/riiif/image.rb
CHANGED
@@ -2,9 +2,20 @@ require 'digest/md5'
|
|
2
2
|
module Riiif
|
3
3
|
class Image
|
4
4
|
|
5
|
-
class_attribute :file_resolver
|
5
|
+
class_attribute :file_resolver, :info_service
|
6
6
|
self.file_resolver = FileSystemFileResolver
|
7
7
|
|
8
|
+
# this is the default info service
|
9
|
+
# returns a hash with the original image dimensions.
|
10
|
+
# You can set your own lambda if you want different behavior
|
11
|
+
# example:
|
12
|
+
# {:height=>390, :width=>600}
|
13
|
+
self.info_service = lambda do |id, image|
|
14
|
+
Rails.cache.fetch(Image.cache_key(id, { info: true }), compress: true, expires_in: 3.days) do
|
15
|
+
image.info
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
8
19
|
OUTPUT_FORMATS = %W{jpg png}
|
9
20
|
|
10
21
|
attr_reader :id, :image
|
@@ -23,7 +34,9 @@ module Riiif
|
|
23
34
|
end
|
24
35
|
end
|
25
36
|
|
26
|
-
|
37
|
+
def info
|
38
|
+
info_service.call(id, image)
|
39
|
+
end
|
27
40
|
|
28
41
|
def self.cache_key(id, options)
|
29
42
|
str = options.merge(id: id).delete_if {|_, v| v.nil?}.to_s
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
Riiif::Engine.routes.draw do
|
2
2
|
ALLOW_DOTS ||= /[\w.]+/
|
3
3
|
SIZES ||= /(pct:)?[\w.,]+/
|
4
|
-
get "/:id/:region/:size/:rotation/:quality
|
5
|
-
constraints: { rotation: ALLOW_DOTS, size: SIZES}
|
4
|
+
get "/:id/:region/:size/:rotation/:quality.:format" => "images#show",
|
5
|
+
constraints: { rotation: ALLOW_DOTS, size: SIZES },
|
6
|
+
defaults: { format: 'jpg', rotation: '0', region: 'full', quality: 'native' },
|
7
|
+
as: 'image'
|
8
|
+
|
6
9
|
get "/:id/info.json" => "images#info", defaults: { format: 'json' }, as: 'info'
|
7
10
|
get "/:id/view(.:format)" => "images#view"
|
8
11
|
end
|
data/lib/riiif/version.rb
CHANGED
@@ -33,6 +33,16 @@ describe "routes" do
|
|
33
33
|
region: 'full', size: 'full', rotation: '0',
|
34
34
|
quality: 'native', format: 'jpg')
|
35
35
|
end
|
36
|
+
|
37
|
+
describe "route helper" do
|
38
|
+
it "takes all the options" do
|
39
|
+
expect(image_path('abcd1234', region: 'full', size: '100,50', rotation: '22.5', quality: 'native',
|
40
|
+
format: 'jpg')).to eq '/image-service/abcd1234/full/100,50/22.5/native.jpg'
|
41
|
+
end
|
42
|
+
it "has defaults" do
|
43
|
+
expect(image_path('abcd1234', size: '100,50')).to eq '/image-service/abcd1234/full/100,50/0/native.jpg'
|
44
|
+
end
|
45
|
+
end
|
36
46
|
end
|
37
47
|
|
38
48
|
describe "for info" do
|
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: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|