apache_image_resizer 0.0.3 → 0.0.4
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.
- data/README +1 -1
- data/lib/apache/image_resizer/util.rb +8 -9
- data/lib/apache/image_resizer/version.rb +1 -1
- data/spec/apache/image_resizer_spec.rb +16 -0
- metadata +5 -5
data/README
CHANGED
@@ -149,12 +149,11 @@ module Apache
|
|
149
149
|
match, directives, max = Regexp.last_match, {}, @max_dim
|
150
150
|
|
151
151
|
if o = match[3]
|
152
|
-
|
152
|
+
wh = [o.to_f, match[4].to_f]
|
153
|
+
xy = match.values_at(5, 6)
|
153
154
|
|
154
|
-
if
|
155
|
-
directives[:offset] = xy.map! { |i|
|
156
|
-
i.tr!('pm', '+-').to_f
|
157
|
-
}.concat(args)
|
155
|
+
if wh.all? { |i| 0 < i && i <= max }
|
156
|
+
directives[:offset] = xy.map! { |i| i.tr!('pm', '+-').to_f }.concat(wh)
|
158
157
|
else
|
159
158
|
return
|
160
159
|
end
|
@@ -163,13 +162,13 @@ module Apache
|
|
163
162
|
if w = match[1]
|
164
163
|
h = match[2]
|
165
164
|
|
166
|
-
|
167
|
-
|
165
|
+
wh = [w.to_f]
|
166
|
+
wh << h.to_f if h
|
168
167
|
|
169
168
|
max *= 2 if o
|
170
169
|
|
171
|
-
if
|
172
|
-
directives[:resize] =
|
170
|
+
if wh.all? { |i| 0 < i && i <= max }
|
171
|
+
directives[:resize] = wh
|
173
172
|
else
|
174
173
|
return
|
175
174
|
end
|
@@ -44,6 +44,22 @@ describe Apache::ImageResizer do
|
|
44
44
|
@uri %= 'r10000'
|
45
45
|
end
|
46
46
|
|
47
|
+
it_should :decline, 'Zero width', 'Invalid Directives' do
|
48
|
+
@uri %= 'r0x100'
|
49
|
+
end
|
50
|
+
|
51
|
+
it_should :decline, 'Zero height', 'Invalid Directives' do
|
52
|
+
@uri %= 'r100x0'
|
53
|
+
end
|
54
|
+
|
55
|
+
it_should :decline, 'Zero width offset', 'Invalid Directives' do
|
56
|
+
@uri %= 'o0x100p0p0'
|
57
|
+
end
|
58
|
+
|
59
|
+
it_should :decline, 'Zero height offset', 'Invalid Directives' do
|
60
|
+
@uri %= 'o100x0p0p0'
|
61
|
+
end
|
62
|
+
|
47
63
|
it_should :decline, 'Read Error: Magick::ImageMagickError' do
|
48
64
|
mock_uri(path = '/source-path')
|
49
65
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apache_image_resizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jens Wille
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-17 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rmagick
|
@@ -102,7 +102,7 @@ licenses: []
|
|
102
102
|
post_install_message:
|
103
103
|
rdoc_options:
|
104
104
|
- --title
|
105
|
-
- apache_image_resizer Application documentation (v0.0.
|
105
|
+
- apache_image_resizer Application documentation (v0.0.4)
|
106
106
|
- --line-numbers
|
107
107
|
- --main
|
108
108
|
- README
|