eat 0.1.6 → 0.1.7

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.
Files changed (4) hide show
  1. data/lib/eat.rb +13 -7
  2. data/lib/eat/version.rb +1 -1
  3. data/test/test_eat.rb +4 -0
  4. metadata +7 -7
data/lib/eat.rb CHANGED
@@ -9,9 +9,11 @@ unless defined?(::Infinity)
9
9
  end
10
10
 
11
11
  module Eat
12
+ # httpclient 2.2.3 inserts the platform info for you, albeit with problems
13
+ # AGENT_NAME = "Mozilla/5.0 (#{::RUBY_PLATFORM}) Ruby/#{::RUBY_VERSION} HTTPClient/#{::HTTPClient::VERSION} eat/#{::Eat::VERSION}"
14
+ AGENT_NAME = "eat/#{::Eat::VERSION}"
15
+
12
16
  module ObjectExtensions
13
- AGENT_NAME = "Mozilla/5.0 (#{::RUBY_PLATFORM}) Ruby/#{::RUBY_VERSION} HTTPClient/#{::HTTPClient::VERSION} eat/#{::Eat::VERSION}"
14
-
15
17
  # <tt>url</tt> can be filesystem or http/https
16
18
  #
17
19
  # Options:
@@ -57,11 +59,15 @@ module Eat
57
59
  if uri.scheme == 'https'
58
60
  http.ssl_config.verify_mode = openssl_verify_mode
59
61
  end
60
- catch :stop do
61
- http.get_content(uri.to_s) do |chunk|
62
- body << chunk
63
- read_so_far += chunk.length
64
- throw :stop if read_so_far > limit
62
+ if limit == ::Infinity
63
+ body << http.get_content(uri.to_s)
64
+ else
65
+ catch :stop do
66
+ http.get_content(uri.to_s) do |chunk|
67
+ body << chunk
68
+ read_so_far += chunk.length
69
+ throw :stop if read_so_far > limit
70
+ end
65
71
  end
66
72
  end
67
73
  end
@@ -1,3 +1,3 @@
1
1
  module Eat
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -82,4 +82,8 @@ class TestEat < Test::Unit::TestCase
82
82
  def test_satisfies_sites_that_require_user_agent
83
83
  assert eat('http://www.bestbuy.com').include?('images.bestbuy.com')
84
84
  end
85
+
86
+ def test_more_chunks
87
+ assert eat('http://www.ebay.com/itm/ws/eBayISAPI.dll?ViewItem&item=260910713854?_trksid=p5197.m1256&_trkparms=clkid%3D4726644202417880745').include?('<title>')
88
+ end
85
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
16
- requirement: &2177093680 !ruby/object:Gem::Requirement
16
+ requirement: &2164292480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2177093680
24
+ version_requirements: *2164292480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: test-unit
27
- requirement: &2177093180 !ruby/object:Gem::Requirement
27
+ requirement: &2164292060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2177093180
35
+ version_requirements: *2164292060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2177092500 !ruby/object:Gem::Requirement
38
+ requirement: &2164291640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2177092500
46
+ version_requirements: *2164291640
47
47
  description: A (better?) replacement for open-uri. Gets the contents of local and
48
48
  remote files as a String, no questions asked.
49
49
  email: