eat 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/eat.rb +4 -1
- data/lib/eat/version.rb +1 -1
- data/test/test_eat.rb +4 -0
- metadata +8 -8
data/lib/eat.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'uri'
|
2
|
+
require 'httpclient'
|
2
3
|
|
3
4
|
# http://weblog.jamisbuck.org/2007/2/7/infinity
|
4
5
|
unless defined?(::Infinity)
|
@@ -7,6 +8,8 @@ end
|
|
7
8
|
|
8
9
|
module Eat
|
9
10
|
module ObjectExtensions
|
11
|
+
AGENT_NAME = "Mozilla/5.0 (#{::RUBY_PLATFORM}) Ruby/#{::RUBY_VERSION} HTTPClient/#{::HTTPClient::VERSION} eat/#{::Eat::VERSION}"
|
12
|
+
|
10
13
|
# <tt>url</tt> can be filesystem or http/https
|
11
14
|
#
|
12
15
|
# Options:
|
@@ -39,13 +42,13 @@ module Eat
|
|
39
42
|
end
|
40
43
|
|
41
44
|
when 'http', 'https'
|
42
|
-
require 'httpclient'
|
43
45
|
timeout = options.fetch(:timeout, 2)
|
44
46
|
openssl_verify_mode = options.fetch(:openssl_verify_mode, ::OpenSSL::SSL::VERIFY_PEER)
|
45
47
|
if openssl_verify_mode == 'none'
|
46
48
|
openssl_verify_mode = ::OpenSSL::SSL::VERIFY_NONE
|
47
49
|
end
|
48
50
|
http = ::HTTPClient.new
|
51
|
+
http.agent_name = AGENT_NAME
|
49
52
|
http.redirect_uri_callback = ::Proc.new { |uri, res| ::URI.parse(res.header['location'][0]) }
|
50
53
|
http.transparent_gzip_decompression = true
|
51
54
|
http.receive_timeout = timeout
|
data/lib/eat/version.rb
CHANGED
data/test/test_eat.rb
CHANGED
@@ -78,4 +78,8 @@ class TestEat < Test::Unit::TestCase
|
|
78
78
|
def test_chunks_work_out
|
79
79
|
assert eat('http://www.thinkgeek.com/interests/giftsforhim/60b6/').include?('DOCTYPE HTML PUBLIC')
|
80
80
|
end
|
81
|
+
|
82
|
+
def test_satisfies_sites_that_require_user_agent
|
83
|
+
assert eat('http://www.bestbuy.com').include?('images.bestbuy.com')
|
84
|
+
end
|
81
85
|
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.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-07 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154388200 !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: *
|
24
|
+
version_requirements: *2154388200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: test-unit
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154387780 !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: *
|
35
|
+
version_requirements: *2154387780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154384780 !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: *
|
46
|
+
version_requirements: *2154384780
|
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:
|