djatoka 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/djatoka.gemspec +1 -1
- data/lib/djatoka/iiif_request.rb +13 -1
- data/test/test_iiif_request.rb +16 -3
- data/test/test_metadata.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59e0ba03ce37604d72aa86517019131b632c8f0e
|
4
|
+
data.tar.gz: 52d429c2b801b25bb36b5b6e6af66349de3d785a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0077434610f5f51e42ab590357cb321c86c666d78767c6da56b2d0e41b8bf27decf56df4afc6ef64da24c4e7066f483bf0883f49a64c56d08ad1f9b27defb6f1
|
7
|
+
data.tar.gz: feab7d2d08dc2a8870a3054b802d14345a934715268426c9cdfeb80749c6d9ec40e1db833f6c0b79b6352af12c9cba948b7dd8cb028d6ea5a3950ffa042f7d6a
|
data/djatoka.gemspec
CHANGED
data/lib/djatoka/iiif_request.rb
CHANGED
@@ -106,14 +106,22 @@ module Djatoka
|
|
106
106
|
end
|
107
107
|
|
108
108
|
region = @resolver.region(@id)
|
109
|
+
metadata = @resolver.metadata(@id).perform
|
109
110
|
|
110
111
|
if(@iiif_params[:region] =~ /^(\d+),(\d+),(\d+),(\d+)$/)
|
111
112
|
region.region("#{$2},#{$1},#{$4},#{$3}")
|
113
|
+
elsif(@iiif_params[:region] =~ /^pct:([\d\.]+),([\d\.]+),([\d\.]+),([\d\.]+)$/)
|
114
|
+
x = (($1.to_f / 100.0) * metadata.width.to_f).to_i
|
115
|
+
y = (($2.to_f / 100.0) * metadata.height.to_f).to_i
|
116
|
+
w = (($3.to_f / 100.0) * metadata.width.to_f).to_i
|
117
|
+
h = (($4.to_f / 100.0) * metadata.height.to_f).to_i
|
118
|
+
region.region([y, x, h, w])
|
112
119
|
elsif(!(@iiif_params[:region] =~ /^full$/i))
|
113
120
|
raise IiifInvalidParam.new "region", @iiif_params[:region]
|
114
121
|
end
|
115
122
|
|
116
123
|
s = @iiif_params[:size]
|
124
|
+
|
117
125
|
case s
|
118
126
|
when /^full$/i
|
119
127
|
s #noop
|
@@ -126,7 +134,11 @@ module Djatoka
|
|
126
134
|
region.scale(dj_scale.to_s)
|
127
135
|
when /^(\d+),(\d+)$/
|
128
136
|
region.scale("#{$1},#{$2}")
|
129
|
-
|
137
|
+
when /^!(\d+),(\d+)$/
|
138
|
+
ratio = [$1.to_f / metadata.width.to_f, $2.to_f / metadata.height.to_f].min
|
139
|
+
width = (ratio * metadata.width.to_f).to_i
|
140
|
+
height = (ratio * metadata.height.to_f).to_i
|
141
|
+
region.scale([width, height])
|
130
142
|
else
|
131
143
|
raise IiifInvalidParam.new "size", s
|
132
144
|
end
|
data/test/test_iiif_request.rb
CHANGED
@@ -12,9 +12,9 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
|
|
12
12
|
@region = @req.region('full').size('full').rotation('0').quality('default').format('jpg').djatoka_region
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
should 'set id properly' do
|
16
|
+
assert_equal @identifier, @region.rft_id
|
17
|
+
end
|
18
18
|
|
19
19
|
should 'set region to nil from full' do
|
20
20
|
assert_nil @region.query.region
|
@@ -44,6 +44,11 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
|
|
44
44
|
assert_equal '20,10,100,50', reg.query.region
|
45
45
|
end
|
46
46
|
|
47
|
+
should 'set pct:x,y,w,h requests' do
|
48
|
+
reg = @req.region('pct:10.5,20,30.8,40').djatoka_region
|
49
|
+
assert_equal '674,537,1348,1576', reg.query.region
|
50
|
+
end
|
51
|
+
|
47
52
|
should 'raise an exception if the region does not fit the x,y,w,h format, or is not "full"' do
|
48
53
|
assert_raise Djatoka::IiifInvalidParam do
|
49
54
|
@req.region('blah').djatoka_region
|
@@ -79,6 +84,14 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
|
|
79
84
|
assert_equal '1024,768', reg.query.scale
|
80
85
|
end
|
81
86
|
|
87
|
+
should 'set "!w,h" requests to the correct scale value' do
|
88
|
+
reg = @req.size('!1024,768').djatoka_region
|
89
|
+
assert_equal '1024,674', reg.query.scale
|
90
|
+
|
91
|
+
reg = @req.size('!1024,500').djatoka_region
|
92
|
+
assert_equal '759,500', reg.query.scale
|
93
|
+
end
|
94
|
+
|
82
95
|
should 'raise an exception if the value cannot be parsed into a Float' do
|
83
96
|
assert_raise Djatoka::IiifInvalidParam do
|
84
97
|
@req.size('pct:0.75').djatoka_region
|
data/test/test_metadata.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djatoka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Ronallo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: '0'
|
214
214
|
requirements: []
|
215
215
|
rubyforge_project: djatoka
|
216
|
-
rubygems_version: 2.4.
|
216
|
+
rubygems_version: 2.4.5
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: Djatoka image server helpers for Ruby and Rails.
|
@@ -233,4 +233,3 @@ test_files:
|
|
233
233
|
- test/test_region.rb
|
234
234
|
- test/test_resolver.rb
|
235
235
|
- test/test_view_helpers.rb
|
236
|
-
has_rdoc:
|