riiif 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2267ef01c3a2abbf3991710ef5c4c9f6ac55500c
4
- data.tar.gz: 13fc80e6e72c789bac048f66fc020d8a0cb2e314
3
+ metadata.gz: 905d7f9639fc63f7764759b985ea235a4e369645
4
+ data.tar.gz: e73244b575876cd67008082a497a5cc9d339777f
5
5
  SHA512:
6
- metadata.gz: 0d45589ca6d5e13de6d7a40a61b09c48e9d062118c1845d9fd786e7d8f5066980d9e1adb8d1a4b1df7b419a6729248fec8bc8ea6338d0e9216324a94d9cec7eb
7
- data.tar.gz: 64600eb8e05f1f613b7a039ed6c25b36f5f87d75f1993b9dad667ae3eea9e47e5fe9b66200ef4a03f3fc96862e307cdc2adf936e69609206e02cd4014562553b
6
+ metadata.gz: f4e8952000bb0374601d4b6d33e4d5428d721c69f30ef8bf5400e86021a4ce8214e764858401eb74779fe69380f51201ff968a3b678ae879caa7b066e2c7d77c
7
+ data.tar.gz: 4b46ed4fd0b9d004123b7fd181702a89f25019a9c891b6573b891ca0c6b0c1432a5814963b65d6cc4a25f63df8c84d7be2027d05e71c12efd6cd9db961237652
@@ -1,3 +1,4 @@
1
+ require 'digest/md5'
1
2
  module Riiif
2
3
  class Image
3
4
 
@@ -16,7 +17,10 @@ module Riiif
16
17
 
17
18
  def render(args)
18
19
  options = decode_options!(args)
19
- Rails.cache.fetch(options.merge(id: id), compress: true, expires_in: 3.days) do
20
+ # Use a MD5 digest to ensure the keys aren't too long.
21
+ digest = Digest::MD5.hexdigest(options.merge(id: id).to_s)
22
+ puts digest
23
+ Rails.cache.fetch(digest, compress: true, expires_in: 3.days) do
20
24
  image.extract(options)
21
25
  end
22
26
  end
@@ -6,9 +6,9 @@
6
6
  prefixUrl: "/assets/openseadragon/",
7
7
  tileSources: [{
8
8
  "image_host": "http://localhost:8080/image-service",
9
- "identifier": "irises",
10
- "width": 4264,
11
- "height": 3282,
9
+ "identifier": "<%= @image.id %>",
10
+ "width": <%= @image.info[:width] %>,
11
+ "height": <%= @image.info[:height] %>,
12
12
  "scale_factors": [1, 2, 3, 4, 5],
13
13
  "tile_width": 1024,
14
14
  "tile_height": 1024,
@@ -1,8 +1,8 @@
1
1
  Riiif::Engine.routes.draw do
2
2
  ALLOW_DOTS ||= /[\w.]+/
3
- PERCENTAGE ||= /(pct:)?[\w.]+/
3
+ SIZES ||= /(pct:)?[\w.,]+/
4
4
  get "/:id/:region/:size/:rotation/:quality(.:format)" => "images#show",
5
- constraints: { rotation: ALLOW_DOTS, size: PERCENTAGE}
5
+ constraints: { rotation: ALLOW_DOTS, size: SIZES}
6
6
  get "/:id/info(.:format)" => "images#info", :constraints => { :format => /json/}
7
7
  get "/:id/view(.:format)" => "images#view"
8
8
  end
@@ -12,7 +12,7 @@ module Riiif
12
12
  end
13
13
 
14
14
  def self.pattern(id)
15
- raise ArgumentException, "Invalid characters in id `#{id}`" unless /^\w+$/.match(id)
15
+ raise ArgumentException, "Invalid characters in id `#{id}`" unless /^[\w-]+$/.match(id)
16
16
  ::File.join(base_path, "#{id}.{#{input_types.join(',')}}")
17
17
  end
18
18
 
@@ -1,3 +1,3 @@
1
1
  module Riiif
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -8,4 +8,8 @@ describe Riiif::FileSystemFileResolver do
8
8
  it "should get the jpeg2000 file" do
9
9
  expect(subject.find('world')).to eq Riiif::FileSystemFileResolver.root + '/spec/samples/world.jp2'
10
10
  end
11
+
12
+ it "should accept ids with dashes" do
13
+ subject.pattern('foo-bar-baz')
14
+ end
11
15
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "routes" do
4
4
  routes { Riiif::Engine.routes }
5
5
 
6
- describe 'for mogrification' do
6
+ describe 'for conversion' do
7
7
  it "routes GET /abcd1234/full/full/0/native.jpg" do
8
8
  expect(
9
9
  get: "/abcd1234/full/full/0/native.jpg"
@@ -12,13 +12,27 @@ describe "routes" do
12
12
  quality: 'native', format: 'jpg')
13
13
  end
14
14
 
15
- it "routes requests with dots" do
15
+ it "routes requests with floating point percent size" do
16
16
  expect(
17
17
  get: "/abcd1234/full/pct:12.5/22.5/native.jpg"
18
18
  ).to route_to(controller: "riiif/images", id: 'abcd1234', action: "show",
19
19
  region: 'full', size: 'pct:12.5', rotation: '22.5',
20
20
  quality: 'native', format: 'jpg')
21
21
  end
22
+ it "routes requests with pixel size" do
23
+ expect(
24
+ get: "/abcd1234/full/100,50/22.5/native.jpg"
25
+ ).to route_to(controller: "riiif/images", id: 'abcd1234', action: "show",
26
+ region: 'full', size: '100,50', rotation: '22.5',
27
+ quality: 'native', format: 'jpg')
28
+ end
29
+ it "routes requests with dashes in the id" do
30
+ expect(
31
+ get: "/abcd-1234-5678/full/full/0/native.jpg"
32
+ ).to route_to(controller: "riiif/images", id: 'abcd-1234-5678', action: "show",
33
+ region: 'full', size: 'full', rotation: '0',
34
+ quality: 'native', format: 'jpg')
35
+ end
22
36
  end
23
37
 
24
38
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-16 00:00:00.000000000 Z
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler