fastimage 1.6.4 → 1.6.5

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: 0c3ac7db254b241861f6b263dec85059a91802a6
4
- data.tar.gz: 12ab9b17386c9d8cc62dff0924e273f3bd5da81c
3
+ metadata.gz: 3ee43e5740dcf6818e5c8d1125fad36e1bda9f57
4
+ data.tar.gz: 8b86b676562492da1da645cf7f94210aa0c71666
5
5
  SHA512:
6
- metadata.gz: f0593a2af86dc99f70711b94a8950d0e58716dc7849592dfcd54be3cd19fff5f9d217961db54b774b33d6ec5241ff0789896f2130b474a74736b2d6def43825d
7
- data.tar.gz: c813c61137248cf2005c406c1ce9d0d3e860929b4dd3c6ecc80bba2dbe4d010dbb14d939e5e049269c35ed6d6ebb0d451107e0b1022a048762fe02f5dcb86be4
6
+ metadata.gz: 7dea06d67cd7f9de2b06581cd130e52da3e2cca037214ca481326dc6340006e288186b734d392ea26c13a6a8a0ebd41d8dda0d7c9ada19448f5de6d4758a00b3
7
+ data.tar.gz: 9082130cc32246bd4fed77d9f6012029f5660f66049aa07b940eb56f5ecac14c7688e0d962a8343fcc3cb75eab44cb871ea9617fb586a2a6c5b85ed053f52f32
@@ -53,8 +53,6 @@ class FastImage
53
53
 
54
54
  class FastImageException < StandardError # :nodoc:
55
55
  end
56
- class MoreCharsNeeded < FastImageException # :nodoc:
57
- end
58
56
  class UnknownImageType < FastImageException # :nodoc:
59
57
  end
60
58
  class ImageFetchFailure < FastImageException # :nodoc:
@@ -237,6 +235,21 @@ class FastImage
237
235
  end
238
236
  end
239
237
 
238
+ case res['content-encoding']
239
+ when 'deflate', 'gzip', 'x-gzip'
240
+ begin
241
+ gzip = Zlib::GzipReader.new(FiberStream.new(read_fiber))
242
+ rescue FiberError, Zlib::GzipFile::Error
243
+ raise CannotParseImage
244
+ end
245
+
246
+ read_fiber = Fiber.new do
247
+ while data = gzip.readline
248
+ Fiber.yield data
249
+ end
250
+ end
251
+ end
252
+
240
253
  parse_packets FiberStream.new(read_fiber)
241
254
 
242
255
  break # needed to actively quit out of the fetch
Binary file
@@ -56,6 +56,12 @@ BadFixtures.each do |fn|
56
56
  FakeWeb.register_uri(:get, "#{TestUrl}#{fn}", :body => File.join(FixturePath, fn))
57
57
  end
58
58
 
59
+ GzipTestImg = "gzipped.jpg"
60
+ FakeWeb.register_uri(:get, "#{TestUrl}#{GzipTestImg}", :body => File.join(FixturePath, GzipTestImg), :content_encoding => "gzip")
61
+ GzipTestImgTruncated = "truncated_gzipped.jpg"
62
+ FakeWeb.register_uri(:get, "#{TestUrl}#{GzipTestImgTruncated}", :body => File.join(FixturePath, GzipTestImgTruncated), :content_encoding => "gzip")
63
+ GzipTestImgSize = [970, 450]
64
+
59
65
  class FastImageTest < Test::Unit::TestCase
60
66
  def test_should_report_type_correctly
61
67
  GoodFixtures.each do |fn, info|
@@ -258,4 +264,16 @@ class FastImageTest < Test::Unit::TestCase
258
264
  assert_equal info[1], FastImage.size(stringio)
259
265
  end
260
266
  end
267
+
268
+ def test_gzipped_file
269
+ url = "http://example.nowhere/#{GzipTestImg}"
270
+ assert_equal([970, 450], FastImage.size(url))
271
+ end
272
+
273
+ def test_truncated_gzipped_file
274
+ url = "http://example.nowhere/#{GzipTestImgTruncated}"
275
+ assert_raises(FastImage::SizeNotFound) do
276
+ FastImage.size(url, :raise_on_failure => true)
277
+ end
278
+ end
261
279
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -88,6 +88,7 @@ files:
88
88
  - test/fixtures/exif_orientation.jpg
89
89
  - test/fixtures/faulty.jpg
90
90
  - test/fixtures/folder with spaces/test.bmp
91
+ - test/fixtures/gzipped.jpg
91
92
  - test/fixtures/infinite.jpg
92
93
  - test/fixtures/man.ico
93
94
  - test/fixtures/orient_2.jpg
@@ -103,6 +104,7 @@ files:
103
104
  - test/fixtures/test2.tiff
104
105
  - test/fixtures/test3.jpg
105
106
  - test/fixtures/test4.jpg
107
+ - test/fixtures/truncated_gzipped.jpg
106
108
  - test/test.rb
107
109
  homepage: http://github.com/sdsykes/fastimage
108
110
  licenses: