httpthumbnailer 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +4 -3
- data/Gemfile.lock +12 -12
- data/README.md +242 -68
- data/Rakefile +8 -2
- data/VERSION +1 -1
- data/bin/httpthumbnailer +35 -7
- data/lib/httpthumbnailer/error_reporter.rb +4 -2
- data/lib/httpthumbnailer/ownership.rb +54 -0
- data/lib/httpthumbnailer/plugin.rb +87 -0
- data/lib/httpthumbnailer/plugin/thumbnailer.rb +22 -427
- data/lib/httpthumbnailer/plugin/thumbnailer/service.rb +163 -0
- data/lib/httpthumbnailer/plugin/thumbnailer/service/built_in_plugins.rb +134 -0
- data/lib/httpthumbnailer/plugin/thumbnailer/service/images.rb +295 -0
- data/lib/httpthumbnailer/plugin/thumbnailer/service/magick.rb +208 -0
- data/lib/httpthumbnailer/thumbnail_specs.rb +130 -37
- data/lib/httpthumbnailer/thumbnailer.rb +29 -11
- metadata +30 -81
- data/.rspec +0 -1
- data/features/httpthumbnailer.feature +0 -24
- data/features/identify.feature +0 -31
- data/features/step_definitions/httpthumbnailer_steps.rb +0 -159
- data/features/support/env.rb +0 -106
- data/features/support/test-large.jpg +0 -0
- data/features/support/test-transparent.png +0 -0
- data/features/support/test.jpg +0 -0
- data/features/support/test.png +0 -0
- data/features/support/test.txt +0 -1
- data/features/thumbnail.feature +0 -269
- data/features/thumbnails.feature +0 -158
- data/httpthumbnailer.gemspec +0 -121
- data/load_test/extralarge.jpg +0 -0
- data/load_test/large.jpg +0 -0
- data/load_test/large.png +0 -0
- data/load_test/load_test-374846090-1.1.0-rc1-identify-only.csv +0 -3
- data/load_test/load_test-374846090-1.1.0-rc1.csv +0 -11
- data/load_test/load_test-cd9679c.csv +0 -10
- data/load_test/load_test-v0.3.1.csv +0 -10
- data/load_test/load_test.jmx +0 -733
- data/load_test/medium.jpg +0 -0
- data/load_test/small.jpg +0 -0
- data/load_test/soak_test-ac0c6bcbe5e-broken-libjpeg-tatoos.csv +0 -11
- data/load_test/soak_test-cd9679c.csv +0 -10
- data/load_test/soak_test-f98334a-tatoos.csv +0 -11
- data/load_test/soak_test.jmx +0 -754
- data/load_test/tiny.jpg +0 -0
- data/load_test/v0.0.13-loading.csv +0 -7
- data/load_test/v0.0.13.csv +0 -7
- data/load_test/v0.0.14-no-optimization.csv +0 -10
- data/load_test/v0.0.14.csv +0 -10
- data/spec/image_processing_spec.rb +0 -148
- data/spec/plugin_thumbnailer_spec.rb +0 -318
- data/spec/spec_helper.rb +0 -14
- data/spec/support/square_even.png +0 -0
- data/spec/support/square_odd.png +0 -0
- data/spec/support/test_image.rb +0 -16
- data/spec/thumbnail_specs_spec.rb +0 -43
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpthumbnailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jakub Pastuszek
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: unicorn-cuba-base
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
19
|
+
version: '1.6'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
26
|
+
version: '1.6'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rmagick
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec-mocks
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,23 +69,20 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: cucumber
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
75
|
+
version: '1.3'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
82
|
+
version: '1.3'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: capybara
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,23 +97,26 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: jeweler
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ! '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: 1.8.8
|
104
|
+
- - ~>
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '1.8'
|
118
107
|
type: :development
|
119
108
|
prerelease: false
|
120
109
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
110
|
requirements:
|
123
|
-
- -
|
111
|
+
- - ! '>='
|
124
112
|
- !ruby/object:Gem::Version
|
125
113
|
version: 1.8.8
|
114
|
+
- - ~>
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.8'
|
126
117
|
- !ruby/object:Gem::Dependency
|
127
118
|
name: httpclient
|
128
119
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
120
|
requirements:
|
131
121
|
- - ~>
|
132
122
|
- !ruby/object:Gem::Version
|
@@ -134,7 +124,6 @@ dependencies:
|
|
134
124
|
type: :development
|
135
125
|
prerelease: false
|
136
126
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
127
|
requirements:
|
139
128
|
- - ~>
|
140
129
|
- !ruby/object:Gem::Version
|
@@ -142,7 +131,6 @@ dependencies:
|
|
142
131
|
- !ruby/object:Gem::Dependency
|
143
132
|
name: rdoc
|
144
133
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
134
|
requirements:
|
147
135
|
- - ~>
|
148
136
|
- !ruby/object:Gem::Version
|
@@ -150,7 +138,6 @@ dependencies:
|
|
150
138
|
type: :development
|
151
139
|
prerelease: false
|
152
140
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
141
|
requirements:
|
155
142
|
- - ~>
|
156
143
|
- !ruby/object:Gem::Version
|
@@ -158,7 +145,6 @@ dependencies:
|
|
158
145
|
- !ruby/object:Gem::Dependency
|
159
146
|
name: multipart-parser
|
160
147
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
148
|
requirements:
|
163
149
|
- - ~>
|
164
150
|
- !ruby/object:Gem::Version
|
@@ -166,7 +152,6 @@ dependencies:
|
|
166
152
|
type: :development
|
167
153
|
prerelease: false
|
168
154
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
155
|
requirements:
|
171
156
|
- - ~>
|
172
157
|
- !ruby/object:Gem::Version
|
@@ -174,7 +159,6 @@ dependencies:
|
|
174
159
|
- !ruby/object:Gem::Dependency
|
175
160
|
name: daemon
|
176
161
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
162
|
requirements:
|
179
163
|
- - ~>
|
180
164
|
- !ruby/object:Gem::Version
|
@@ -182,12 +166,14 @@ dependencies:
|
|
182
166
|
type: :development
|
183
167
|
prerelease: false
|
184
168
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
169
|
requirements:
|
187
170
|
- - ~>
|
188
171
|
- !ruby/object:Gem::Version
|
189
172
|
version: '1.1'
|
190
|
-
description:
|
173
|
+
description: Statless HTTP server that provides API for thumbnailing images with different
|
174
|
+
aspect ratio keeping methods, applying image edits (like rotate, crop, blur, pixelate,
|
175
|
+
etc.), identification of image format and size and more. It is using ImageMagick
|
176
|
+
or GraphicsMagick via RMagick gem as the image processing library.
|
191
177
|
email: jpastuszek@gmail.com
|
192
178
|
executables:
|
193
179
|
- httpthumbnailer
|
@@ -197,7 +183,6 @@ extra_rdoc_files:
|
|
197
183
|
- README.md
|
198
184
|
files:
|
199
185
|
- .document
|
200
|
-
- .rspec
|
201
186
|
- Gemfile
|
202
187
|
- Gemfile.lock
|
203
188
|
- LICENSE.txt
|
@@ -205,74 +190,38 @@ files:
|
|
205
190
|
- Rakefile
|
206
191
|
- VERSION
|
207
192
|
- bin/httpthumbnailer
|
208
|
-
- features/httpthumbnailer.feature
|
209
|
-
- features/identify.feature
|
210
|
-
- features/step_definitions/httpthumbnailer_steps.rb
|
211
|
-
- features/support/env.rb
|
212
|
-
- features/support/test-large.jpg
|
213
|
-
- features/support/test-transparent.png
|
214
|
-
- features/support/test.jpg
|
215
|
-
- features/support/test.png
|
216
|
-
- features/support/test.txt
|
217
|
-
- features/thumbnail.feature
|
218
|
-
- features/thumbnails.feature
|
219
|
-
- httpthumbnailer.gemspec
|
220
193
|
- lib/httpthumbnailer/error_reporter.rb
|
194
|
+
- lib/httpthumbnailer/ownership.rb
|
195
|
+
- lib/httpthumbnailer/plugin.rb
|
221
196
|
- lib/httpthumbnailer/plugin/thumbnailer.rb
|
197
|
+
- lib/httpthumbnailer/plugin/thumbnailer/service.rb
|
198
|
+
- lib/httpthumbnailer/plugin/thumbnailer/service/built_in_plugins.rb
|
199
|
+
- lib/httpthumbnailer/plugin/thumbnailer/service/images.rb
|
200
|
+
- lib/httpthumbnailer/plugin/thumbnailer/service/magick.rb
|
222
201
|
- lib/httpthumbnailer/thumbnail_specs.rb
|
223
202
|
- lib/httpthumbnailer/thumbnailer.rb
|
224
|
-
- load_test/extralarge.jpg
|
225
|
-
- load_test/large.jpg
|
226
|
-
- load_test/large.png
|
227
|
-
- load_test/load_test-374846090-1.1.0-rc1-identify-only.csv
|
228
|
-
- load_test/load_test-374846090-1.1.0-rc1.csv
|
229
|
-
- load_test/load_test-cd9679c.csv
|
230
|
-
- load_test/load_test-v0.3.1.csv
|
231
|
-
- load_test/load_test.jmx
|
232
|
-
- load_test/medium.jpg
|
233
|
-
- load_test/small.jpg
|
234
|
-
- load_test/soak_test-ac0c6bcbe5e-broken-libjpeg-tatoos.csv
|
235
|
-
- load_test/soak_test-cd9679c.csv
|
236
|
-
- load_test/soak_test-f98334a-tatoos.csv
|
237
|
-
- load_test/soak_test.jmx
|
238
|
-
- load_test/tiny.jpg
|
239
|
-
- load_test/v0.0.13-loading.csv
|
240
|
-
- load_test/v0.0.13.csv
|
241
|
-
- load_test/v0.0.14-no-optimization.csv
|
242
|
-
- load_test/v0.0.14.csv
|
243
|
-
- spec/image_processing_spec.rb
|
244
|
-
- spec/plugin_thumbnailer_spec.rb
|
245
|
-
- spec/spec_helper.rb
|
246
|
-
- spec/support/square_even.png
|
247
|
-
- spec/support/square_odd.png
|
248
|
-
- spec/support/test_image.rb
|
249
|
-
- spec/thumbnail_specs_spec.rb
|
250
203
|
homepage: http://github.com/jpastuszek/httpthumbnailer
|
251
204
|
licenses:
|
252
205
|
- MIT
|
206
|
+
metadata: {}
|
253
207
|
post_install_message:
|
254
208
|
rdoc_options: []
|
255
209
|
require_paths:
|
256
210
|
- lib
|
257
211
|
required_ruby_version: !ruby/object:Gem::Requirement
|
258
|
-
none: false
|
259
212
|
requirements:
|
260
213
|
- - ! '>='
|
261
214
|
- !ruby/object:Gem::Version
|
262
215
|
version: '0'
|
263
|
-
segments:
|
264
|
-
- 0
|
265
|
-
hash: -2315585188832359526
|
266
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
|
-
none: false
|
268
217
|
requirements:
|
269
218
|
- - ! '>='
|
270
219
|
- !ruby/object:Gem::Version
|
271
220
|
version: '0'
|
272
221
|
requirements: []
|
273
222
|
rubyforge_project:
|
274
|
-
rubygems_version:
|
223
|
+
rubygems_version: 2.4.7
|
275
224
|
signing_key:
|
276
|
-
specification_version:
|
277
|
-
summary: HTTP thumbnailing
|
225
|
+
specification_version: 4
|
226
|
+
summary: HTTP API server for image thumbnailing, editing and format conversion
|
278
227
|
test_files: []
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
@@ -1,24 +0,0 @@
|
|
1
|
-
Feature: HTTP server
|
2
|
-
It should behave like valid HTTP server
|
3
|
-
|
4
|
-
Background:
|
5
|
-
Given httpthumbnailer server is running at http://localhost:3100/
|
6
|
-
|
7
|
-
Scenario: Reporitng of missing resource for GET
|
8
|
-
When I do GET request http://localhost:3100/blah
|
9
|
-
Then response status should be 404
|
10
|
-
And response content type should be text/plain
|
11
|
-
And response body should be CRLF endend lines
|
12
|
-
"""
|
13
|
-
request for URI '/blah' was not handled by the server
|
14
|
-
"""
|
15
|
-
|
16
|
-
Scenario: Reporitng of missing resource for PUT
|
17
|
-
When I do PUT request http://localhost:3100/blah/thumbnails/crop,0,0,PNG/fit,0,0,JPG/pad,0,0,JPEG
|
18
|
-
Then response status should be 404
|
19
|
-
And response content type should be text/plain
|
20
|
-
And response body should be CRLF endend lines
|
21
|
-
"""
|
22
|
-
request for URI '/blah/thumbnails/crop,0,0,PNG/fit,0,0,JPG/pad,0,0,JPEG' was not handled by the server
|
23
|
-
"""
|
24
|
-
|
data/features/identify.feature
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
Feature: Identify API endpoint
|
2
|
-
Identify API allows for image identification.
|
3
|
-
|
4
|
-
Background:
|
5
|
-
Given httpthumbnailer server is running at http://localhost:3100/
|
6
|
-
|
7
|
-
@identify
|
8
|
-
Scenario: Identifying of image mime type
|
9
|
-
Given test.jpg file content as request body
|
10
|
-
When I do PUT request http://localhost:3100/identify
|
11
|
-
Then response status should be 200
|
12
|
-
And response content type should be application/json
|
13
|
-
And response body should be JSON encoded
|
14
|
-
And response JSON should contain key mimeType of value image/jpeg
|
15
|
-
Given test.png file content as request body
|
16
|
-
When I do PUT request http://localhost:3100/identify
|
17
|
-
Then response status should be 200
|
18
|
-
And response content type should be application/json
|
19
|
-
And response body should be JSON encoded
|
20
|
-
And response JSON should contain key mimeType of value image/png
|
21
|
-
|
22
|
-
@identify
|
23
|
-
Scenario: Identifying of image width and height
|
24
|
-
Given test-large.jpg file content as request body
|
25
|
-
When I do PUT request http://localhost:3100/identify
|
26
|
-
Then response status should be 200
|
27
|
-
And response content type should be application/json
|
28
|
-
And response body should be JSON encoded
|
29
|
-
And response JSON should contain key width of integer value 9911
|
30
|
-
And response JSON should contain key height of integer value 14000
|
31
|
-
|
@@ -1,159 +0,0 @@
|
|
1
|
-
Given /httpthumbnailer server is running at (.*)/ do |url|
|
2
|
-
log = support_dir + 'server.log'
|
3
|
-
cmd = "bundle exec #{script('httpthumbnailer')} -f -d -l #{log} -w 1"
|
4
|
-
start_server(cmd, '/tmp/httpthumbnailer.pid', log, url)
|
5
|
-
end
|
6
|
-
|
7
|
-
Given /(.*) file content as request body/ do |file|
|
8
|
-
@request_body = File.open(support_dir + file){|f| f.read }
|
9
|
-
end
|
10
|
-
|
11
|
-
When /I do (.*) request (.*)/ do |method, url|
|
12
|
-
@response = http_client.request(method, url, nil, @request_body)
|
13
|
-
end
|
14
|
-
|
15
|
-
When /I save response body/ do
|
16
|
-
@saved_response_body = @response.body
|
17
|
-
end
|
18
|
-
|
19
|
-
Then /^([^ ]+) header should be (.*)/ do |header, value|
|
20
|
-
@response.header[header].should_not be_empty
|
21
|
-
@response.header[header].first.should == value
|
22
|
-
end
|
23
|
-
|
24
|
-
Then /I should get multipart response/ do
|
25
|
-
@response.header['Content-Type'].first.should match /^multipart/
|
26
|
-
parser = MultipartParser::Reader.new(MultipartParser::Reader.extract_boundary_value(@response.header['Content-Type'].last))
|
27
|
-
@response_multipart = []
|
28
|
-
|
29
|
-
parser.on_part do |part|
|
30
|
-
part_struct = OpenStruct.new
|
31
|
-
part_struct.headers = part.headers
|
32
|
-
|
33
|
-
part_struct.body = ''
|
34
|
-
part.on_data do |data|
|
35
|
-
part_struct.body << data
|
36
|
-
end
|
37
|
-
|
38
|
-
part.on_end do
|
39
|
-
@response_multipart << part_struct
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
parser.write @response.body
|
44
|
-
|
45
|
-
parser.ended?.should be_true
|
46
|
-
@response_multipart.should_not be_empty
|
47
|
-
end
|
48
|
-
|
49
|
-
Then /response body should be CRLF endend lines like/ do |body|
|
50
|
-
@response.body.should match(body)
|
51
|
-
@response.body.each_line do |line|
|
52
|
-
line[-2,2].should == "\r\n"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Then /response body should be CRLF endend lines$/ do |body|
|
57
|
-
@response.body.should == body.gsub("\n", "\r\n") + "\r\n"
|
58
|
-
end
|
59
|
-
|
60
|
-
Then /response status should be (.*)/ do |status|
|
61
|
-
@response.status.should == status.to_i
|
62
|
-
end
|
63
|
-
|
64
|
-
Then /response content type should be (.*)/ do |content_type|
|
65
|
-
@response.header['Content-Type'].first.should == content_type
|
66
|
-
end
|
67
|
-
|
68
|
-
Then /response mime type should be (.*)/ do |mime_type|
|
69
|
-
step "response content type should be #{mime_type}"
|
70
|
-
end
|
71
|
-
|
72
|
-
Then /^([^ ]+) part (.*) header should be (.*)/ do |part, header, value|
|
73
|
-
@response_multipart[part_no(part)].headers[header.downcase].should == value
|
74
|
-
end
|
75
|
-
|
76
|
-
Then /^([^ ]+) part body should be CRLF endend lines$/ do |part, body|
|
77
|
-
@response_multipart[part_no(part)].body.should == body.gsub("\n", "\r\n")
|
78
|
-
end
|
79
|
-
|
80
|
-
Then /^([^ ]+) part body should be CRLF endend lines like$/ do |part, body|
|
81
|
-
pbody = @response_multipart[part_no(part)].body
|
82
|
-
pbody.should match(body)
|
83
|
-
end
|
84
|
-
|
85
|
-
Then /response should contain (.*) image of size (.*)x(.*)/ do |format, width, height|
|
86
|
-
mime = @response.header['Content-Type'].first
|
87
|
-
data = @response.body
|
88
|
-
fail("expecte image got #{mime}: #{data}") unless mime =~ /^image\//
|
89
|
-
|
90
|
-
@image.destroy! if @image
|
91
|
-
@image = Magick::Image.from_blob(data).first
|
92
|
-
|
93
|
-
@image.format.should == format
|
94
|
-
@image.columns.should == width.to_i
|
95
|
-
@image.rows.should == height.to_i
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
Then /(.*) part should contain (.*) image of size (.*)x(.*)/ do |part, format, width, height|
|
100
|
-
mime = @response_multipart[part_no(part)].headers['content-type']
|
101
|
-
data = @response_multipart[part_no(part)].body
|
102
|
-
|
103
|
-
mime.should match /^image\//
|
104
|
-
data.should_not be_empty
|
105
|
-
|
106
|
-
@image.destroy! if @image
|
107
|
-
@image = Magick::Image.from_blob(data).first
|
108
|
-
|
109
|
-
@image.format.should == format
|
110
|
-
@image.columns.should == width.to_i
|
111
|
-
@image.rows.should == height.to_i
|
112
|
-
end
|
113
|
-
|
114
|
-
Then /saved response body will be smaller than response body/ do
|
115
|
-
@saved_response_body.length.should < @response.body.length
|
116
|
-
end
|
117
|
-
|
118
|
-
And /response will be saved as (.*) for human inspection/ do |file|
|
119
|
-
data = @response.body
|
120
|
-
(support_dir + file).open('w'){|f| f.write(data)}
|
121
|
-
end
|
122
|
-
|
123
|
-
And /(.*) part body will be saved as (.*) for human inspection/ do |part, file|
|
124
|
-
data = @response_multipart[part_no(part)].body
|
125
|
-
(support_dir + file).open('w'){|f| f.write(data)}
|
126
|
-
end
|
127
|
-
|
128
|
-
And /that image pixel at (.*)x(.*) should be of color (.*)/ do |x, y, color|
|
129
|
-
@image.pixel_color(x.to_i, y.to_i).to_color.sub(/^#/, '0x').should == color
|
130
|
-
end
|
131
|
-
|
132
|
-
And /that image should be (.*) bit image/ do |bits|
|
133
|
-
if @image.depth < 8
|
134
|
-
(@image.depth * 8).should == bits.to_i # newer versions return 1 for 8 bit?!
|
135
|
-
else
|
136
|
-
@image.depth.should == bits.to_i
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
And /there should be no leaked images/ do
|
141
|
-
Integer(http_client.get_content("http://localhost:3100/stats/images_loaded").strip).should == 0
|
142
|
-
end
|
143
|
-
|
144
|
-
And /there should be maximum (.*) images loaded during single request/ do |max|
|
145
|
-
Integer(http_client.get_content("http://localhost:3100/stats/max_images_loaded").strip).should <= max.to_i
|
146
|
-
end
|
147
|
-
|
148
|
-
And /response body should be JSON encoded/ do
|
149
|
-
@json = JSON.load(@response.body)
|
150
|
-
end
|
151
|
-
|
152
|
-
And /response JSON should contain key (.*) of value (.*)/ do |key, value|
|
153
|
-
@json[key].should == value
|
154
|
-
end
|
155
|
-
|
156
|
-
And /response JSON should contain key (.*) of integer value (.*)/ do |key, value|
|
157
|
-
@json[key].should == value.to_i
|
158
|
-
end
|
159
|
-
|