fastimage 1.8.1 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,37 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: addressable
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.3'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 2.3.5
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '2.3'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 2.3.5
33
- - !ruby/object:Gem::Dependency
34
- name: fakeweb
14
+ name: fakeweb-fi
35
15
  requirement: !ruby/object:Gem::Requirement
36
16
  requirements:
37
17
  - - "~>"
@@ -50,14 +30,14 @@ dependencies:
50
30
  requirements:
51
31
  - - ">="
52
32
  - !ruby/object:Gem::Version
53
- version: '0'
33
+ version: '10.5'
54
34
  type: :development
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
37
  requirements:
58
38
  - - ">="
59
39
  - !ruby/object:Gem::Version
60
- version: '0'
40
+ version: '10.5'
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: rdoc
63
43
  requirement: !ruby/object:Gem::Requirement
@@ -97,39 +77,11 @@ files:
97
77
  - MIT-LICENSE
98
78
  - README.textile
99
79
  - lib/fastimage.rb
100
- - lib/fastimage/fbr.rb
101
- - test/fixtures/bad.jpg
102
- - test/fixtures/exif_orientation.jpg
103
- - test/fixtures/faulty.jpg
104
- - test/fixtures/folder with spaces/test.bmp
105
- - test/fixtures/gzipped.jpg
106
- - test/fixtures/infinite.jpg
107
- - test/fixtures/man.ico
108
- - test/fixtures/orient_2.jpg
109
- - test/fixtures/test.bmp
110
- - test/fixtures/test.cur
111
- - test/fixtures/test.gif
112
- - test/fixtures/test.jpg
113
- - test/fixtures/test.png
114
- - test/fixtures/test.psd
115
- - test/fixtures/test.svg
116
- - test/fixtures/test.tiff
117
- - test/fixtures/test2.bmp
118
- - test/fixtures/test2.jpg
119
- - test/fixtures/test2.tiff
120
- - test/fixtures/test3.jpg
121
- - test/fixtures/test4.jpg
122
- - test/fixtures/test_partial_viewport.svg
123
- - test/fixtures/truncated_gzipped.jpg
124
- - test/fixtures/webp_vp8.webp
125
- - test/fixtures/webp_vp8l.webp
126
- - test/fixtures/webp_vp8x.webp
127
- - test/test.rb
128
80
  homepage: http://github.com/sdsykes/fastimage
129
81
  licenses:
130
82
  - MIT
131
83
  metadata: {}
132
- post_install_message:
84
+ post_install_message:
133
85
  rdoc_options:
134
86
  - "--charset=UTF-8"
135
87
  require_paths:
@@ -138,17 +90,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
90
  requirements:
139
91
  - - ">="
140
92
  - !ruby/object:Gem::Version
141
- version: '0'
93
+ version: 1.9.2
142
94
  required_rubygems_version: !ruby/object:Gem::Requirement
143
95
  requirements:
144
96
  - - ">="
145
97
  - !ruby/object:Gem::Version
146
98
  version: '0'
147
99
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 2.4.5
150
- signing_key:
100
+ rubygems_version: 3.2.3
101
+ signing_key:
151
102
  specification_version: 4
152
103
  summary: FastImage - Image info fast
153
- test_files:
154
- - test/test.rb
104
+ test_files: []
data/lib/fastimage/fbr.rb DELETED
@@ -1,66 +0,0 @@
1
- # Poor Man's Fiber (API compatible Thread based Fiber implementation for Ruby 1.8)
2
- # (c) 2008 Aman Gupta (tmm1)
3
-
4
- unless defined? Fiber
5
- require 'thread'
6
-
7
- class FiberError < StandardError; # :nodoc:
8
- end
9
-
10
- class Fiber # :nodoc:
11
- def initialize
12
- raise ArgumentError, 'new Fiber requires a block' unless block_given?
13
-
14
- @yield = Queue.new
15
- @resume = Queue.new
16
-
17
- @thread = Thread.new{ @yield.push [yield(*@resume.pop)] }
18
- @thread.abort_on_exception = true
19
- @thread[:fiber] = self
20
- end
21
- attr_reader :thread
22
-
23
- def resume *args
24
- raise FiberError, 'dead fiber called' unless @thread.alive?
25
- @resume.push(args)
26
- result = @yield.pop
27
- result.size > 1 ? result : result.first
28
- end
29
-
30
- def yield *args
31
- @yield.push(args)
32
- result = @resume.pop
33
- result.size > 1 ? result : result.first
34
- end
35
-
36
- def self.yield *args
37
- if fiber = Thread.current[:fiber]
38
- fiber.yield(*args)
39
- else
40
- raise FiberError, 'not inside a fiber'
41
- end
42
- end
43
-
44
- def self.current
45
- if Thread.current == Thread.main
46
- return Thread.main[:fiber] ||= RootFiber.new
47
- end
48
-
49
- Thread.current[:fiber] or raise FiberError, 'not inside a fiber'
50
- end
51
-
52
- def inspect
53
- "#<#{self.class}:0x#{self.object_id.to_s(16)}>"
54
- end
55
- end
56
-
57
- class RootFiber < Fiber # :nodoc:
58
- def initialize
59
- # XXX: what is a root fiber anyway?
60
- end
61
-
62
- def self.yield *args
63
- raise FiberError, "can't yield from root fiber"
64
- end
65
- end
66
- end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,43 +0,0 @@
1
- <?xml version="1.0"?>
2
-
3
- <svg version="1.1"
4
- xmlns="http://www.w3.org/2000/svg"
5
- xmlns:xlink="http://www.w3.org/1999/xlink"
6
- width="200" height="300"
7
- style="background-color: #D2B48C;"
8
- onload="loaded()">
9
- <script type="text/javascript"><![CDATA[
10
- function loaded() {
11
- // change onloadFunc to point to your real onload function that you
12
- // want called when the page is truly ready
13
- var onloadFunc = doload;
14
-
15
- if (top.svgweb) {
16
- top.svgweb.addOnLoad(onloadFunc, true, window);
17
- } else {
18
- onloadFunc();
19
- }
20
- }
21
-
22
- function doload() {
23
- // developers original onload handler
24
-
25
- // add an event listener to our circle; on* style events added right
26
- // to the markup are not yet supported
27
- var circle = document.getElementById('myCircle');
28
- circle.addEventListener('mousedown', function(evt) {
29
- alert('You pressed the mouse button on our circle: ' + evt.target.id);
30
- }, false);
31
- }
32
- ]]></script>
33
- <g id="myGroup"
34
- fill="blue"
35
- style="font-size: 18px; text-anchor: middle; font-family: serif;">
36
- <circle id="myCircle"
37
- cx="100" cy="75" r="50"
38
- stroke="firebrick"
39
- stroke-width="3" />
40
- <text x="100" y="155">Hello World</text>
41
- <text x="100" y="175">From An SVG File!</text>
42
- </g>
43
- </svg>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,9 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="860" viewBox="0 0 215 100">
2
- <path d="M4.8 72.6C8.4 77.2 40.3 78.8 48 73.8 64.9 77.7 98.6 75.9 97.7 69.2 97 63.2 -16.4 46.1 4.8 72.6zM114.8 69.3C130.6 78.8 162 75.7 167.9 73.8 173.6 80.6 209.4 79.6 211.3 74.3 213.2 68.8 90.7 18.1 114.8 69.3z" style="fill:#cfcfcf"/>
3
- <path d="M67.9 31.1C42.1 30.4 27.6 58.1 34.8 66.4 44.4 77.6 89.3 73.7 95.7 67.1 105.3 57.4 93.5 31.7 67.9 31.1z" style="fill:#cca776;stroke:#715835"/>
4
- <path d="M25.7 43.9C2.8 43.8 -0.2 64.2 4.5 71.6 7.4 76.3 42.2 76.8 47.1 70.9 52.5 64.4 49 44 25.7 43.9z" style="fill:#ffe2af;stroke:#daa240"/>
5
- <path d="M141.8 33.1C108.7 32.1 105.2 59.2 112.9 67.3 121.1 76 163.9 75.9 170.9 67.9 177.5 60.2 175.1 34.2 141.8 33.1z" style="fill:#a7dcc1;stroke:#5ba67e"/>
6
- <path d="M188.8 43.6C166.1 43.1 160 64.7 165.9 71.8 171.6 78.6 203.4 78 209.3 72.3 215.6 66.1 211 44.1 188.8 43.6z" style="fill:#ffd1ba;stroke:#cc7f58"/>
7
- <path d="M141.6 2.5C118.4 2 105.7 25 115 34.5 120.9 40.5 160.2 41.3 166.4 34.3 174.1 25.6 164.6 3 141.6 2.5z" style="fill:#fbf499;stroke:#cbc238"/>
8
- <path d="M31.3 54.6C32.6 56.7 32.6 58.1 33 60.9M37.4 60.2C37.5 57.4 37 56.4 36 54.5M84.1 56.3C83.8 53.4 83.3 50.4 81.7 47.5M90.5 56.3C90.3 53.3 89.9 50.2 88.4 47.2M121.5 53C121.1 50.2 121.7 47.3 123 44.4M127.3 53.5C126.8 50.7 127.7 47.8 129.3 44.9M125.1 15.9C125.1 13.3 125.9 11.4 126.9 8.8M132.8 8.6C131.9 11 131 13.5 131.1 15.9M174.8 53.3C173.5 55.9 172.5 58.6 172.6 61.6M181.4 53.5C180 55.4 178.6 60.4 179.7 62.1" style="fill:none;stroke:#000000;stroke-width:1.25;stroke-linecap:round"/>
9
- </svg>
Binary file
Binary file
Binary file
Binary file
data/test/test.rb DELETED
@@ -1,323 +0,0 @@
1
- require 'rubygems'
2
-
3
- require 'test/unit'
4
-
5
- PathHere = File.dirname(__FILE__)
6
- $LOAD_PATH.unshift File.join(PathHere, "..", "lib")
7
-
8
- require 'fastimage'
9
- require 'fakeweb'
10
-
11
- FixturePath = File.join(PathHere, "fixtures")
12
-
13
- GoodFixtures = {
14
- "test.bmp"=>[:bmp, [40, 27]],
15
- "test2.bmp"=>[:bmp, [1920, 1080]],
16
- "test.gif"=>[:gif, [17, 32]],
17
- "test.jpg"=>[:jpeg, [882, 470]],
18
- "test.png"=>[:png, [30, 20]],
19
- "test2.jpg"=>[:jpeg, [250, 188]],
20
- "test3.jpg"=>[:jpeg, [630, 367]],
21
- "test4.jpg"=>[:jpeg, [1485, 1299]],
22
- "test.tiff"=>[:tiff, [85, 67]],
23
- "test2.tiff"=>[:tiff, [333, 225]],
24
- "test.psd"=>[:psd, [17, 32]],
25
- "exif_orientation.jpg"=>[:jpeg, [600, 450]],
26
- "infinite.jpg"=>[:jpeg, [160,240]],
27
- "orient_2.jpg"=>[:jpeg, [230,408]],
28
- "favicon.ico" => [:ico, [16, 16]],
29
- "man.ico" => [:ico, [48, 48]],
30
- "test.cur" => [:cur, [32, 32]],
31
- "webp_vp8x.webp" => [:webp, [386, 395]],
32
- "webp_vp8l.webp" => [:webp, [386, 395]],
33
- "webp_vp8.webp" => [:webp, [550, 368]],
34
- "test.svg" => [:svg, [200, 300]],
35
- "test_partial_viewport.svg" => [:svg, [860, 400]]
36
- }
37
-
38
- BadFixtures = [
39
- "faulty.jpg",
40
- "test_rgb.ct",
41
- "test.xml"
42
- ]
43
- # man.ico courtesy of http://www.iconseeker.com/search-icon/artists-valley-sample/business-man-blue.html
44
- # test_rgb.ct courtesy of http://fileformats.archiveteam.org/wiki/Scitex_CT
45
- # test.cur courtesy of http://mimidestino.deviantart.com/art/Clash-Of-Clans-Dragon-Cursor-s-Punteros-489070897
46
-
47
- TestUrl = "http://example.nowhere/"
48
-
49
- # this image fetch allows me to really test that fastimage is truly fast
50
- # but it's not ideal relying on external resources and connectivity speed
51
- LargeImage = "http://upload.wikimedia.org/wikipedia/commons/b/b4/Mardin_1350660_1350692_33_images.jpg"
52
- LargeImageInfo = [:jpeg, [9545, 6623]]
53
- LargeImageFetchLimit = 2 # seconds
54
-
55
- HTTPSImage = "https://upload.wikimedia.org/wikipedia/commons/b/b4/Mardin_1350660_1350692_33_images.jpg"
56
- HTTPSImageInfo = [:jpeg, [9545, 6623]]
57
-
58
- GoodFixtures.each do |fn, info|
59
- FakeWeb.register_uri(:get, "#{TestUrl}#{fn}", :body => File.join(FixturePath, fn))
60
- end
61
- BadFixtures.each do |fn|
62
- FakeWeb.register_uri(:get, "#{TestUrl}#{fn}", :body => File.join(FixturePath, fn))
63
- end
64
-
65
- GzipTestImg = "gzipped.jpg"
66
- FakeWeb.register_uri(:get, "#{TestUrl}#{GzipTestImg}", :body => File.join(FixturePath, GzipTestImg), :content_encoding => "gzip")
67
- GzipTestImgTruncated = "truncated_gzipped.jpg"
68
- FakeWeb.register_uri(:get, "#{TestUrl}#{GzipTestImgTruncated}", :body => File.join(FixturePath, GzipTestImgTruncated), :content_encoding => "gzip")
69
- GzipTestImgSize = [970, 450]
70
-
71
- class FastImageTest < Test::Unit::TestCase
72
- def test_should_report_type_correctly
73
- GoodFixtures.each do |fn, info|
74
- assert_equal info[0], FastImage.type(TestUrl + fn)
75
- assert_equal info[0], FastImage.type(TestUrl + fn, :raise_on_failure=>true)
76
- end
77
- end
78
-
79
- def test_should_report_size_correctly
80
- GoodFixtures.each do |fn, info|
81
- assert_equal info[1], FastImage.size(TestUrl + fn)
82
- assert_equal info[1], FastImage.size(TestUrl + fn, :raise_on_failure=>true)
83
- end
84
- end
85
-
86
- def test_should_return_nil_on_fetch_failure
87
- assert_nil FastImage.size(TestUrl + "does_not_exist")
88
- end
89
-
90
- def test_should_return_nil_for_faulty_jpeg_where_size_cannot_be_found
91
- assert_nil FastImage.size(TestUrl + "faulty.jpg")
92
- end
93
-
94
- def test_should_return_nil_when_image_type_not_known
95
- assert_nil FastImage.size(TestUrl + "test_rgb.ct")
96
- end
97
-
98
- def test_should_return_nil_if_timeout_occurs
99
- assert_nil FastImage.size("http://example.com/does_not_exist", :timeout=>0.001)
100
- end
101
-
102
- def test_should_raise_when_asked_to_when_size_cannot_be_found
103
- assert_raises(FastImage::SizeNotFound) do
104
- FastImage.size(TestUrl + "faulty.jpg", :raise_on_failure=>true)
105
- end
106
- end
107
-
108
- def test_should_raise_when_asked_to_when_timeout_occurs
109
- assert_raises(FastImage::ImageFetchFailure) do
110
- FastImage.size("http://example.com/does_not_exist", :timeout=>0.001, :raise_on_failure=>true)
111
- end
112
- end
113
-
114
- def test_should_raise_when_asked_to_when_file_does_not_exist
115
- assert_raises(FastImage::ImageFetchFailure) do
116
- FastImage.size("http://www.google.com/does_not_exist_at_all", :raise_on_failure=>true)
117
- end
118
- end
119
-
120
- def test_should_raise_when_asked_when_image_type_not_known
121
- assert_raises(FastImage::UnknownImageType) do
122
- FastImage.size(TestUrl + "test_rgb.ct", :raise_on_failure=>true)
123
- end
124
- end
125
-
126
- def test_should_raise_unknown_image_typ_when_file_is_non_svg_xml
127
- assert_raises(FastImage::UnknownImageType) do
128
- FastImage.size(TestUrl + "test.xml", :raise_on_failure=>true)
129
- end
130
- end
131
-
132
- def test_should_report_type_correctly_for_local_files
133
- GoodFixtures.each do |fn, info|
134
- assert_equal info[0], FastImage.type(File.join(FixturePath, fn))
135
- end
136
- end
137
-
138
- def test_should_report_size_correctly_for_local_files
139
- GoodFixtures.each do |fn, info|
140
- assert_equal info[1], FastImage.size(File.join(FixturePath, fn))
141
- end
142
- end
143
-
144
- def test_should_report_type_correctly_for_ios
145
- GoodFixtures.each do |fn, info|
146
- File.open(File.join(FixturePath, fn), "r") do |io|
147
- assert_equal info[0], FastImage.type(io)
148
- end
149
- end
150
- end
151
-
152
- def test_should_report_size_correctly_for_ios
153
- GoodFixtures.each do |fn, info|
154
- File.open(File.join(FixturePath, fn), "r") do |io|
155
- assert_equal info[1], FastImage.size(io)
156
- end
157
- end
158
- end
159
-
160
- def test_should_report_size_correctly_on_io_object_twice
161
- GoodFixtures.each do |fn, info|
162
- File.open(File.join(FixturePath, fn), "r") do |io|
163
- assert_equal info[1], FastImage.size(io)
164
- assert_equal info[1], FastImage.size(io)
165
- end
166
- end
167
- end
168
-
169
- def test_should_report_size_correctly_for_local_files_with_path_that_has_spaces
170
- Dir.chdir(PathHere) do
171
- assert_equal GoodFixtures["test.bmp"][1], FastImage.size(File.join("fixtures", "folder with spaces", "test.bmp"))
172
- end
173
- end
174
-
175
- def test_should_return_nil_on_fetch_failure_for_local_path
176
- assert_nil FastImage.size("does_not_exist")
177
- end
178
-
179
- def test_should_return_nil_for_faulty_jpeg_where_size_cannot_be_found_for_local_file
180
- assert_nil FastImage.size(File.join(FixturePath, "faulty.jpg"))
181
- end
182
-
183
- def test_should_return_nil_when_image_type_not_known_for_local_file
184
- assert_nil FastImage.size(File.join(FixturePath, "test_rgb.ct"))
185
- end
186
-
187
- def test_should_raise_when_asked_to_when_size_cannot_be_found_for_local_file
188
- assert_raises(FastImage::SizeNotFound) do
189
- FastImage.size(File.join(FixturePath, "faulty.jpg"), :raise_on_failure=>true)
190
- end
191
- end
192
-
193
- def test_should_handle_permanent_redirect
194
- url = "http://example.com/foo.jpeg"
195
- register_redirect(url, TestUrl + GoodFixtures.keys.first)
196
- assert_equal GoodFixtures[GoodFixtures.keys.first][1], FastImage.size(url, :raise_on_failure=>true)
197
- end
198
-
199
- def test_should_handle_permanent_redirect_4_times
200
- first_url = "http://example.com/foo.jpeg"
201
- register_redirect(first_url, "http://example.com/foo2.jpeg")
202
- register_redirect("http://example.com/foo2.jpeg", "http://example.com/foo3.jpeg")
203
- register_redirect("http://example.com/foo3.jpeg", "http://example.com/foo4.jpeg")
204
- register_redirect("http://example.com/foo4.jpeg", TestUrl + GoodFixtures.keys.first)
205
- assert_equal GoodFixtures[GoodFixtures.keys.first][1], FastImage.size(first_url, :raise_on_failure=>true)
206
- end
207
-
208
- def test_should_raise_on_permanent_redirect_5_times
209
- first_url = "http://example.com/foo.jpeg"
210
- register_redirect(first_url, "http://example.com/foo2.jpeg")
211
- register_redirect("http://example.com/foo2.jpeg", "http://example.com/foo3.jpeg")
212
- register_redirect("http://example.com/foo3.jpeg", "http://example.com/foo4.jpeg")
213
- register_redirect("http://example.com/foo4.jpeg", "http://example.com/foo5.jpeg")
214
- register_redirect("http://example.com/foo5.jpeg", TestUrl + GoodFixtures.keys.first)
215
- assert_raises(FastImage::ImageFetchFailure) do
216
- FastImage.size(first_url, :raise_on_failure=>true)
217
- end
218
- end
219
-
220
- def test_should_handle_permanent_redirect_with_relative_url
221
- url = "http://example.nowhere/foo.jpeg"
222
- register_redirect(url, "/" + GoodFixtures.keys.first)
223
- assert_equal GoodFixtures[GoodFixtures.keys.first][1], FastImage.size(url, :raise_on_failure=>true)
224
- end
225
-
226
- def register_redirect(from, to)
227
- resp = Net::HTTPMovedPermanently.new(1.0, 302, "Moved")
228
- resp['Location'] = to
229
- FakeWeb.register_uri(:get, from, :response=>resp)
230
- end
231
-
232
- def test_should_fetch_info_of_large_image_faster_than_downloading_the_whole_thing
233
- time = Time.now
234
- size = FastImage.size(LargeImage)
235
- size_time = Time.now
236
- assert size_time - time < LargeImageFetchLimit
237
- assert_equal LargeImageInfo[1], size
238
- time = Time.now
239
- type = FastImage.type(LargeImage)
240
- type_time = Time.now
241
- assert type_time - time < LargeImageFetchLimit
242
- assert_equal LargeImageInfo[0], type
243
- end
244
-
245
- # This test doesn't actually test the proxy function, but at least
246
- # it excercises the code. You could put anything in the http_proxy and it would still pass.
247
- # Any ideas on how to actually test this?
248
- def test_should_fetch_via_proxy
249
- file = "test.gif"
250
- actual_size = GoodFixtures[file][1]
251
- ENV['http_proxy'] = "http://my.proxy.host:8080"
252
- size = FastImage.size(TestUrl + file)
253
- ENV['http_proxy'] = nil
254
- assert_equal actual_size, size
255
- end
256
-
257
- def test_should_fetch_via_proxy_option
258
- file = "test.gif"
259
- actual_size = GoodFixtures[file][1]
260
- size = FastImage.size(TestUrl + file, :proxy => "http://my.proxy.host:8080")
261
- assert_equal actual_size, size
262
- end
263
-
264
- def test_should_handle_https_image
265
- size = FastImage.size(HTTPSImage)
266
- assert_equal HTTPSImageInfo[1], size
267
- end
268
-
269
- require 'pathname'
270
- def test_should_handle_pathname
271
- # bad.jpg does not have the size info in the first 256 bytes
272
- # so this tests if we are able to read past that using a
273
- # Pathname (which has a different API from an IO).
274
- path = Pathname.new(File.join(FixturePath, "bad.jpg"))
275
- assert_equal([500,500], FastImage.size(path))
276
- end
277
-
278
- def test_should_report_type_and_size_correctly_for_stringios
279
- GoodFixtures.each do |fn, info|
280
- string = File.read(File.join(FixturePath, fn))
281
- stringio = StringIO.new(string)
282
- assert_equal info[0], FastImage.type(stringio)
283
- assert_equal info[1], FastImage.size(stringio)
284
- end
285
- end
286
-
287
- def test_gzipped_file
288
- url = "http://example.nowhere/#{GzipTestImg}"
289
- assert_equal([970, 450], FastImage.size(url))
290
- end
291
-
292
- def test_truncated_gzipped_file
293
- url = "http://example.nowhere/#{GzipTestImgTruncated}"
294
- assert_raises(FastImage::SizeNotFound) do
295
- FastImage.size(url, :raise_on_failure => true)
296
- end
297
- end
298
-
299
- def test_cant_access_shell
300
- url = "|echo>shell_test"
301
- %x{rm -f shell_test}
302
- FastImage.size(url)
303
- assert_raises(Errno::ENOENT) do
304
- File.open("shell_test")
305
- end
306
- ensure
307
- %x{rm -f shell_test}
308
- end
309
-
310
- def test_content_length
311
- url = "#{TestUrl}with_content_length.gif"
312
- FakeWeb.register_uri(:get, url, :body => File.join(FixturePath, "test.jpg"), :content_length => 52)
313
-
314
- assert_equal 52, FastImage.new(url).content_length
315
- end
316
-
317
- def test_content_length_not_provided
318
- url = "#{TestUrl}without_content_length.gif"
319
- FakeWeb.register_uri(:get, url, :body => File.join(FixturePath, "test.jpg"))
320
-
321
- assert_equal nil, FastImage.new(url).content_length
322
- end
323
- end