fastimage 1.6.2 → 1.6.3
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.
- checksums.yaml +4 -4
- data/lib/fastimage.rb +18 -3
- data/test/fixtures/bad.jpg +0 -0
- data/test/test.rb +10 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53b20cff044a6f154f24155070dc9146cd70ff7
|
4
|
+
data.tar.gz: c3e80b5e1bb01f18f73149a19c6772244f7fead1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
268
|
-
|
269
|
-
|
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.
|
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-
|
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
|