dubdubdub 0.3.4 → 0.3.5
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.
- data/dubdubdub.gemspec +2 -2
- data/lib/dubdubdub.rb +1 -1
- data/lib/dubdubdub/client.rb +4 -6
- data/spec/dubdubdub_spec.rb +23 -0
- metadata +3 -3
data/dubdubdub.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "dubdubdub"
|
|
8
|
-
s.version = "0.3.
|
|
8
|
+
s.version = "0.3.5"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["James Hu"]
|
|
12
|
-
s.date = "2013-03
|
|
12
|
+
s.date = "2013-04-03"
|
|
13
13
|
s.description = "A library that provides web utility methods with proxification."
|
|
14
14
|
s.email = "axsuul@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/dubdubdub.rb
CHANGED
data/lib/dubdubdub/client.rb
CHANGED
|
@@ -99,10 +99,8 @@ class DubDubDub::Client
|
|
|
99
99
|
|
|
100
100
|
# Helper method to browse by using a GET request via Mechanize
|
|
101
101
|
def browse(url, *args)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
mechanize.get(url, *args)
|
|
105
|
-
end
|
|
102
|
+
handle_mechanize_exceptions do
|
|
103
|
+
mechanize.get(url, *args)
|
|
106
104
|
end
|
|
107
105
|
end
|
|
108
106
|
|
|
@@ -124,7 +122,7 @@ class DubDubDub::Client
|
|
|
124
122
|
|
|
125
123
|
def handle_mechanize_exceptions(&block)
|
|
126
124
|
begin
|
|
127
|
-
yield
|
|
125
|
+
handle_net_http_exceptions { yield }
|
|
128
126
|
rescue Mechanize::RedirectLimitReachedError => e
|
|
129
127
|
raise DubDubDub::RedirectLimitReachedError
|
|
130
128
|
rescue Mechanize::ResponseCodeError => e
|
|
@@ -134,7 +132,7 @@ class DubDubDub::Client
|
|
|
134
132
|
|
|
135
133
|
def handle_rest_client_exceptions(&block)
|
|
136
134
|
begin
|
|
137
|
-
yield
|
|
135
|
+
handle_net_http_exceptions { yield }
|
|
138
136
|
rescue RestClient::MaxRedirectsReached => e
|
|
139
137
|
raise DubDubDub::RedirectLimitReachedError
|
|
140
138
|
rescue RestClient::Exception => e
|
data/spec/dubdubdub_spec.rb
CHANGED
|
@@ -190,6 +190,29 @@ describe DubDubDub do
|
|
|
190
190
|
it "raise the proper exception when exceeding maximum redirects", vcr: { cassette_name: "get/infinite_redirects", record: :once } do
|
|
191
191
|
lambda { www.get("http://wayback.archive.org/web/20050204085854im_/http://www.drpep.com/images/home_19.gif") }.should raise_error(DubDubDub::RedirectLimitReachedError)
|
|
192
192
|
end
|
|
193
|
+
|
|
194
|
+
it "raises proper timeout exception if it times out", vcr: { cassette_name: "get/timeout", record: :once } do
|
|
195
|
+
pending "Long running test, comment out to run it"
|
|
196
|
+
ip_address = "4.4.4.4"
|
|
197
|
+
lambda { www.get(ip_address) }.should raise_error(DubDubDub::ResponseError)
|
|
198
|
+
|
|
199
|
+
begin
|
|
200
|
+
www.get(ip_address)
|
|
201
|
+
rescue DubDubDub::ResponseError => e
|
|
202
|
+
e.code.should == 408
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it "raises proper exception if domain doesn't resolve", vcr: { cassette_name: "get/domain_unresolvable", record: :once } do
|
|
207
|
+
domain = "balhblahlbal123123123123.com"
|
|
208
|
+
lambda { www.get(domain) }.should raise_error(DubDubDub::ResponseError)
|
|
209
|
+
|
|
210
|
+
begin
|
|
211
|
+
www.get(domain)
|
|
212
|
+
rescue DubDubDub::ResponseError => e
|
|
213
|
+
e.code.should == 404
|
|
214
|
+
end
|
|
215
|
+
end
|
|
193
216
|
end
|
|
194
217
|
|
|
195
218
|
describe '#crawl' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dubdubdub
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.5
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-03
|
|
12
|
+
date: 2013-04-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rest-client
|
|
@@ -211,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
211
211
|
version: '0'
|
|
212
212
|
segments:
|
|
213
213
|
- 0
|
|
214
|
-
hash:
|
|
214
|
+
hash: -3903339609961508869
|
|
215
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
216
|
none: false
|
|
217
217
|
requirements:
|