fastimage 1.6.2 → 1.6.3

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: 3d922750baf3944066ebd6d111e43f93c53c6295
4
- data.tar.gz: 475ce77b823d27771f51930695bc4a90dcada5f7
3
+ metadata.gz: d53b20cff044a6f154f24155070dc9146cd70ff7
4
+ data.tar.gz: c3e80b5e1bb01f18f73149a19c6772244f7fead1
5
5
  SHA512:
6
- metadata.gz: a16be654c6c2e6d6199ac75f71403b56124b21a65d530e71f8b5f4732122b73cf2a29bf800df2b2e6dc210791754ac3ecfe736a317a4b0763565929ae2920a5f
7
- data.tar.gz: ca50e122cfbec08af5d9f090e1aeefaa56890787168a9c8859b4707d2a5ebae9796a58392ac117b9782d13369c89c28fa2e3e268825042b1d70c04fdce90a50a
6
+ metadata.gz: 1d99e7827d87d3cc564d67130e54c5a7716259796ea1c5bd3513023824e8251af2d80426294577ddd8d58691908e5679d032ec19559f922f86d7890a8a85a104
7
+ data.tar.gz: 758414866ee9b5e278e997afb4954641d27961fbfe4876f96ec6b25db6cb5021f57fd0ab10b68d5be4beb108cbd3fe3491a85a8e25e8138b2e294e06323d957e
data/lib/fastimage.rb CHANGED
@@ -44,6 +44,7 @@ require 'net/https'
44
44
  require 'addressable/uri'
45
45
  require 'fastimage/fbr.rb'
46
46
  require 'delegate'
47
+ require 'pathname'
47
48
 
48
49
  class FastImage
49
50
  attr_reader :size, :type
@@ -264,9 +265,23 @@ class FastImage
264
265
  end
265
266
 
266
267
  def fetch_using_read(readable)
267
- read_fiber = Fiber.new do
268
- while str = readable.read(LocalFileChunkSize)
269
- Fiber.yield str
268
+ # Pathnames respond to read, but always return the first
269
+ # chunk of the file unlike an IO (even though the
270
+ # docuementation for it refers to IO). Need to supply
271
+ # an offset in this case.
272
+ if readable.is_a?(Pathname)
273
+ read_fiber = Fiber.new do
274
+ offset = 0
275
+ while str = readable.read(LocalFileChunkSize, offset)
276
+ Fiber.yield str
277
+ offset += LocalFileChunkSize
278
+ end
279
+ end
280
+ else
281
+ read_fiber = Fiber.new do
282
+ while str = readable.read(LocalFileChunkSize)
283
+ Fiber.yield str
284
+ end
270
285
  end
271
286
  end
272
287
 
Binary file
data/test/test.rb CHANGED
@@ -25,7 +25,7 @@ GoodFixtures = {
25
25
  "exif_orientation.jpg"=>[:jpeg, [600, 450]],
26
26
  "infinite.jpg"=>[:jpeg, [160,240]],
27
27
  "orient_2.jpg"=>[:jpeg, [230,408]]
28
- }
28
+ }
29
29
 
30
30
  BadFixtures = [
31
31
  "faulty.jpg",
@@ -234,4 +234,13 @@ class FastImageTest < Test::Unit::TestCase
234
234
  size = FastImage.size(HTTPSImage)
235
235
  assert_equal HTTPSImageInfo[1], size
236
236
  end
237
+
238
+ require 'pathname'
239
+ def test_should_handle_pathname
240
+ # bad.jpg does not have the size info in the first 256 bytes
241
+ # so this tests if we are able to read past that using a
242
+ # Pathname (which has a different API from an IO).
243
+ path = Pathname.new(File.join(FixturePath, "bad.jpg"))
244
+ assert_equal([500,500], FastImage.size(path))
245
+ end
237
246
  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.2
4
+ version: 1.6.3
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-04-29 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -84,6 +84,7 @@ files:
84
84
  - README.textile
85
85
  - lib/fastimage.rb
86
86
  - lib/fastimage/fbr.rb
87
+ - test/fixtures/bad.jpg
87
88
  - test/fixtures/exif_orientation.jpg
88
89
  - test/fixtures/faulty.jpg
89
90
  - test/fixtures/folder with spaces/test.bmp