fastimage 1.2.13 → 1.2.14

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.
@@ -201,6 +201,8 @@ class FastImage
201
201
  res.read_body do |str|
202
202
  break if parse_packet(str)
203
203
  end
204
+
205
+ break # needed to actively quit out of the fetch
204
206
  end
205
207
  end
206
208
 
@@ -26,6 +26,12 @@ BadFixtures = [
26
26
 
27
27
  TestUrl = "http://example.nowhere/"
28
28
 
29
+ # this image fetch allows me to really test that fastimage is truly fast
30
+ # but it's not ideal relying on external resources and connectivity speed
31
+ LargeImage = "http://upload.wikimedia.org/wikipedia/commons/b/b4/Mardin_1350660_1350692_33_images.jpg"
32
+ LargeImageInfo = [:jpeg, [9545, 6623]]
33
+ LargeImageFetchLimit = 2 # seconds
34
+
29
35
  GoodFixtures.each do |fn, info|
30
36
  FakeWeb.register_uri(:get, "#{TestUrl}#{fn}", :body => File.join(FixturePath, fn))
31
37
  end
@@ -172,4 +178,17 @@ class FastImageTest < Test::Unit::TestCase
172
178
  resp['Location'] = to
173
179
  FakeWeb.register_uri(:get, from, :response=>resp)
174
180
  end
181
+
182
+ def test_should_fetch_info_of_large_image_faster_than_downloading_the_whole_thing
183
+ time = Time.now
184
+ size = FastImage.size(LargeImage)
185
+ size_time = Time.now
186
+ assert size_time - time < LargeImageFetchLimit
187
+ assert_equal LargeImageInfo[1], size
188
+ time = Time.now
189
+ type = FastImage.type(LargeImage)
190
+ type_time = Time.now
191
+ assert type_time - time < LargeImageFetchLimit
192
+ assert_equal LargeImageInfo[0], type
193
+ end
175
194
  end
metadata CHANGED
@@ -1,38 +1,27 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
- version: !ruby/object:Gem::Version
4
- hash: 5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.14
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 13
10
- version: 1.2.13
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Stephen Sykes
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-03-22 00:00:00 +02:00
19
- default_executable:
12
+ date: 2013-03-07 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description: FastImage finds the size or type of an image given its uri by fetching as little as needed.
14
+ description: FastImage finds the size or type of an image given its uri by fetching
15
+ as little as needed.
23
16
  email: sdsykes@gmail.com
24
17
  executables: []
25
-
26
18
  extensions: []
27
-
28
- extra_rdoc_files:
19
+ extra_rdoc_files:
29
20
  - README
30
21
  - README.textile
31
- files:
22
+ files:
32
23
  - README
33
24
  - README.textile
34
- - Rakefile
35
- - VERSION.yml
36
25
  - lib/fastimage.rb
37
26
  - test/fixtures/faulty.jpg
38
27
  - test/fixtures/test.bmp
@@ -42,40 +31,32 @@ files:
42
31
  - test/fixtures/test.png
43
32
  - test/fixtures/test2.jpg
44
33
  - test/fixtures/test3.jpg
34
+ - test/fixtures/folder with spaces/test.bmp
45
35
  - test/test.rb
46
- has_rdoc: true
47
36
  homepage: http://github.com/sdsykes/fastimage
48
37
  licenses: []
49
-
50
38
  post_install_message:
51
- rdoc_options:
39
+ rdoc_options:
52
40
  - --charset=UTF-8
53
- require_paths:
41
+ require_paths:
54
42
  - lib
55
- required_ruby_version: !ruby/object:Gem::Requirement
43
+ required_ruby_version: !ruby/object:Gem::Requirement
56
44
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
64
- required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
50
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- hash: 3
70
- segments:
71
- - 0
72
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
73
55
  requirements: []
74
-
75
56
  rubyforge_project:
76
- rubygems_version: 1.6.2
57
+ rubygems_version: 1.8.23
77
58
  signing_key:
78
59
  specification_version: 3
79
60
  summary: FastImage - Image info fast
80
- test_files:
61
+ test_files:
81
62
  - test/test.rb
data/Rakefile DELETED
@@ -1,18 +0,0 @@
1
- require 'rake'
2
-
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |s|
6
- s.name = "fastimage"
7
- s.summary = "FastImage - Image info fast"
8
- s.email = "sdsykes@gmail.com"
9
- s.homepage = "http://github.com/sdsykes/fastimage"
10
- s.description = "FastImage finds the size or type of an image given its uri by fetching as little as needed."
11
- s.authors = ["Stephen Sykes"]
12
- s.files = FileList["[A-Z]*", "{lib,test}/**/*"]
13
- end
14
- Jeweler::GemcutterTasks.new
15
- rescue LoadError
16
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://
17
- gems.github.com"
18
- end
@@ -1,5 +0,0 @@
1
- ---
2
- :patch: 10
3
- :major: 1
4
- :build:
5
- :minor: 2