dubdubdub 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dubdubdub"
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
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"]
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
47
47
  "spec/vcr/follow/uri_error.yml",
48
48
  "spec/vcr/get/basic.yml",
49
49
  "spec/vcr/get/doesnt_exist.yml",
50
+ "spec/vcr/get/infinite_redirects.yml",
50
51
  "spec/vcr/get/params.yml",
51
52
  "spec/vcr/get/proxy.yml"
52
53
  ]
@@ -1,6 +1,6 @@
1
1
  class DubDubDub
2
2
  # Version
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
 
5
5
  attr_accessor :client
6
6
 
@@ -125,6 +125,8 @@ class DubDubDub::Client
125
125
  def handle_mechanize_exceptions(&block)
126
126
  begin
127
127
  yield
128
+ rescue Mechanize::RedirectLimitReachedError
129
+ raise DubDubDub::RedirectLimitReachedError
128
130
  rescue Mechanize::ResponseCodeError => e
129
131
  raise DubDubDub::ResponseError.new(e, e.response_code)
130
132
  end
@@ -133,8 +135,11 @@ class DubDubDub::Client
133
135
  def handle_rest_client_exceptions(&block)
134
136
  begin
135
137
  yield
138
+ rescue RestClient::MaxRedirectsReached
139
+ raise DubDubDub::RedirectLimitReachedError
136
140
  rescue RestClient::Exception => e
137
- raise DubDubDub::ResponseError.new(e, e.response.code)
141
+ code = e.response.code if e.response
142
+ raise DubDubDub::ResponseError.new(e, code)
138
143
  end
139
144
 
140
145
  end
@@ -3,6 +3,9 @@ class DubDubDub::Error < RuntimeError; end
3
3
  # URL not properly formatted
4
4
  class DubDubDub::URLFormatError < DubDubDub::Error; end
5
5
 
6
+ # Redirect limit reached
7
+ class DubDubDub::RedirectLimitReachedError < DubDubDub::Error; end
8
+
6
9
  # There was an unhandled response. Contains
7
10
  # a reference to the originating error.
8
11
  class DubDubDub::ResponseError < DubDubDub::Error
@@ -175,7 +175,7 @@ describe DubDubDub do
175
175
  html.css('.ip').text.strip.should == "173.234.181.64"
176
176
  end
177
177
 
178
- it "raises an exception if it doesn't exist", vcr: { cassette_name: "get/doesnt_exist", record: :all } do
178
+ it "raises an exception if it doesn't exist", vcr: { cassette_name: "get/doesnt_exist", record: :once } do
179
179
  lambda { www.get("https://github.com/asdasd/asdasd") }.should raise_error(DubDubDub::ResponseError)
180
180
 
181
181
  begin
@@ -186,6 +186,10 @@ describe DubDubDub do
186
186
  e.message.should_not be_nil
187
187
  end
188
188
  end
189
+
190
+ it "raise the proper exception when exceeding maximum redirects", vcr: { cassette_name: "get/infinite_redirects", record: :once } do
191
+ lambda { www.get("http://wayback.archive.org/web/20050204085854im_/http://www.drpep.com/images/home_19.gif") }.should raise_error(DubDubDub::RedirectLimitReachedError)
192
+ end
189
193
  end
190
194
 
191
195
  describe '#crawl' do
@@ -0,0 +1,412 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://wayback.archive.org/web/20050204085854im_/http://www.drpep.com/images/home_19.gif
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ accept:
11
+ - ! '*/*; q=0.5, application/xml'
12
+ accept-encoding:
13
+ - gzip, deflate
14
+ user-agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 302
19
+ message: Moved Temporarily
20
+ headers:
21
+ server:
22
+ - Tengine/1.3.0
23
+ date:
24
+ - Thu, 24 Jan 2013 03:03:50 GMT
25
+ content-type:
26
+ - image/gif
27
+ connection:
28
+ - keep-alive
29
+ set-cookie:
30
+ - wayback_server=94;Domain=archive.org;Expires=Sat, 23-Feb-13 03:03:50 GMT;
31
+ location:
32
+ - /web/20110715052543im_/http://drpep.com/images/home_19.gif
33
+ content-length:
34
+ - '0'
35
+ x-page-cache:
36
+ - MISS
37
+ body:
38
+ encoding: US-ASCII
39
+ string: ''
40
+ http_version: '1.1'
41
+ recorded_at: Thu, 24 Jan 2013 03:03:50 GMT
42
+ - request:
43
+ method: get
44
+ uri: http://wayback.archive.org/web/20110715052543im_/http:/drpep.com/images/home_19.gif
45
+ body:
46
+ encoding: US-ASCII
47
+ string: ''
48
+ headers:
49
+ accept:
50
+ - ! '*/*; q=0.5, application/xml'
51
+ accept-encoding:
52
+ - gzip, deflate
53
+ cookie:
54
+ - Domain=archive.org; Expires=Sat; wayback_server=94
55
+ user-agent:
56
+ - Ruby
57
+ response:
58
+ status:
59
+ code: 302
60
+ message: Moved Temporarily
61
+ headers:
62
+ server:
63
+ - Tengine/1.3.0
64
+ date:
65
+ - Thu, 24 Jan 2013 03:03:51 GMT
66
+ connection:
67
+ - keep-alive
68
+ location:
69
+ - /web/20110721121019im_/http://drpep.com/images/home_19.gif
70
+ content-length:
71
+ - '0'
72
+ x-page-cache:
73
+ - MISS
74
+ body:
75
+ encoding: US-ASCII
76
+ string: ''
77
+ http_version: '1.1'
78
+ recorded_at: Thu, 24 Jan 2013 03:03:51 GMT
79
+ - request:
80
+ method: get
81
+ uri: http://wayback.archive.org/web/20110721121019im_/http:/drpep.com/images/home_19.gif
82
+ body:
83
+ encoding: US-ASCII
84
+ string: ''
85
+ headers:
86
+ accept:
87
+ - ! '*/*; q=0.5, application/xml'
88
+ accept-encoding:
89
+ - gzip, deflate
90
+ cookie:
91
+ - Domain=archive.org; Expires=Sat; wayback_server=94
92
+ user-agent:
93
+ - Ruby
94
+ response:
95
+ status:
96
+ code: 302
97
+ message: Moved Temporarily
98
+ headers:
99
+ server:
100
+ - Tengine/1.3.0
101
+ date:
102
+ - Thu, 24 Jan 2013 03:03:51 GMT
103
+ connection:
104
+ - keep-alive
105
+ location:
106
+ - /web/20110715052543im_/http://drpep.com/images/home_19.gif
107
+ content-length:
108
+ - '0'
109
+ x-page-cache:
110
+ - MISS
111
+ body:
112
+ encoding: US-ASCII
113
+ string: ''
114
+ http_version: '1.1'
115
+ recorded_at: Thu, 24 Jan 2013 03:03:51 GMT
116
+ - request:
117
+ method: get
118
+ uri: http://wayback.archive.org/web/20110715052543im_/http:/drpep.com/images/home_19.gif
119
+ body:
120
+ encoding: US-ASCII
121
+ string: ''
122
+ headers:
123
+ accept:
124
+ - ! '*/*; q=0.5, application/xml'
125
+ accept-encoding:
126
+ - gzip, deflate
127
+ cookie:
128
+ - Domain=archive.org; Expires=Sat; wayback_server=94
129
+ user-agent:
130
+ - Ruby
131
+ response:
132
+ status:
133
+ code: 302
134
+ message: Moved Temporarily
135
+ headers:
136
+ server:
137
+ - Tengine/1.3.0
138
+ date:
139
+ - Thu, 24 Jan 2013 03:03:51 GMT
140
+ connection:
141
+ - keep-alive
142
+ location:
143
+ - /web/20110721121019im_/http://drpep.com/images/home_19.gif
144
+ content-length:
145
+ - '0'
146
+ x-page-cache:
147
+ - HIT
148
+ body:
149
+ encoding: US-ASCII
150
+ string: ''
151
+ http_version: '1.1'
152
+ recorded_at: Thu, 24 Jan 2013 03:03:51 GMT
153
+ - request:
154
+ method: get
155
+ uri: http://wayback.archive.org/web/20110721121019im_/http:/drpep.com/images/home_19.gif
156
+ body:
157
+ encoding: US-ASCII
158
+ string: ''
159
+ headers:
160
+ accept:
161
+ - ! '*/*; q=0.5, application/xml'
162
+ accept-encoding:
163
+ - gzip, deflate
164
+ cookie:
165
+ - Domain=archive.org; Expires=Sat; wayback_server=94
166
+ user-agent:
167
+ - Ruby
168
+ response:
169
+ status:
170
+ code: 302
171
+ message: Moved Temporarily
172
+ headers:
173
+ server:
174
+ - Tengine/1.3.0
175
+ date:
176
+ - Thu, 24 Jan 2013 03:03:51 GMT
177
+ connection:
178
+ - keep-alive
179
+ location:
180
+ - /web/20110715052543im_/http://drpep.com/images/home_19.gif
181
+ content-length:
182
+ - '0'
183
+ x-page-cache:
184
+ - HIT
185
+ body:
186
+ encoding: US-ASCII
187
+ string: ''
188
+ http_version: '1.1'
189
+ recorded_at: Thu, 24 Jan 2013 03:03:51 GMT
190
+ - request:
191
+ method: get
192
+ uri: http://wayback.archive.org/web/20110715052543im_/http:/drpep.com/images/home_19.gif
193
+ body:
194
+ encoding: US-ASCII
195
+ string: ''
196
+ headers:
197
+ accept:
198
+ - ! '*/*; q=0.5, application/xml'
199
+ accept-encoding:
200
+ - gzip, deflate
201
+ cookie:
202
+ - Domain=archive.org; Expires=Sat; wayback_server=94
203
+ user-agent:
204
+ - Ruby
205
+ response:
206
+ status:
207
+ code: 302
208
+ message: Moved Temporarily
209
+ headers:
210
+ server:
211
+ - Tengine/1.3.0
212
+ date:
213
+ - Thu, 24 Jan 2013 03:03:51 GMT
214
+ connection:
215
+ - keep-alive
216
+ location:
217
+ - /web/20110721121019im_/http://drpep.com/images/home_19.gif
218
+ content-length:
219
+ - '0'
220
+ x-page-cache:
221
+ - HIT
222
+ body:
223
+ encoding: US-ASCII
224
+ string: ''
225
+ http_version: '1.1'
226
+ recorded_at: Thu, 24 Jan 2013 03:03:51 GMT
227
+ - request:
228
+ method: get
229
+ uri: http://wayback.archive.org/web/20110721121019im_/http:/drpep.com/images/home_19.gif
230
+ body:
231
+ encoding: US-ASCII
232
+ string: ''
233
+ headers:
234
+ accept:
235
+ - ! '*/*; q=0.5, application/xml'
236
+ accept-encoding:
237
+ - gzip, deflate
238
+ cookie:
239
+ - Domain=archive.org; Expires=Sat; wayback_server=94
240
+ user-agent:
241
+ - Ruby
242
+ response:
243
+ status:
244
+ code: 302
245
+ message: Moved Temporarily
246
+ headers:
247
+ server:
248
+ - Tengine/1.3.0
249
+ date:
250
+ - Thu, 24 Jan 2013 03:03:51 GMT
251
+ connection:
252
+ - keep-alive
253
+ location:
254
+ - /web/20110715052543im_/http://drpep.com/images/home_19.gif
255
+ content-length:
256
+ - '0'
257
+ x-page-cache:
258
+ - HIT
259
+ body:
260
+ encoding: US-ASCII
261
+ string: ''
262
+ http_version: '1.1'
263
+ recorded_at: Thu, 24 Jan 2013 03:03:51 GMT
264
+ - request:
265
+ method: get
266
+ uri: http://wayback.archive.org/web/20110715052543im_/http:/drpep.com/images/home_19.gif
267
+ body:
268
+ encoding: US-ASCII
269
+ string: ''
270
+ headers:
271
+ accept:
272
+ - ! '*/*; q=0.5, application/xml'
273
+ accept-encoding:
274
+ - gzip, deflate
275
+ cookie:
276
+ - Domain=archive.org; Expires=Sat; wayback_server=94
277
+ user-agent:
278
+ - Ruby
279
+ response:
280
+ status:
281
+ code: 302
282
+ message: Moved Temporarily
283
+ headers:
284
+ server:
285
+ - Tengine/1.3.0
286
+ date:
287
+ - Thu, 24 Jan 2013 03:03:52 GMT
288
+ connection:
289
+ - keep-alive
290
+ location:
291
+ - /web/20110721121019im_/http://drpep.com/images/home_19.gif
292
+ content-length:
293
+ - '0'
294
+ x-page-cache:
295
+ - HIT
296
+ body:
297
+ encoding: US-ASCII
298
+ string: ''
299
+ http_version: '1.1'
300
+ recorded_at: Thu, 24 Jan 2013 03:03:52 GMT
301
+ - request:
302
+ method: get
303
+ uri: http://wayback.archive.org/web/20110721121019im_/http:/drpep.com/images/home_19.gif
304
+ body:
305
+ encoding: US-ASCII
306
+ string: ''
307
+ headers:
308
+ accept:
309
+ - ! '*/*; q=0.5, application/xml'
310
+ accept-encoding:
311
+ - gzip, deflate
312
+ cookie:
313
+ - Domain=archive.org; Expires=Sat; wayback_server=94
314
+ user-agent:
315
+ - Ruby
316
+ response:
317
+ status:
318
+ code: 302
319
+ message: Moved Temporarily
320
+ headers:
321
+ server:
322
+ - Tengine/1.3.0
323
+ date:
324
+ - Thu, 24 Jan 2013 03:03:52 GMT
325
+ connection:
326
+ - keep-alive
327
+ location:
328
+ - /web/20110715052543im_/http://drpep.com/images/home_19.gif
329
+ content-length:
330
+ - '0'
331
+ x-page-cache:
332
+ - HIT
333
+ body:
334
+ encoding: US-ASCII
335
+ string: ''
336
+ http_version: '1.1'
337
+ recorded_at: Thu, 24 Jan 2013 03:03:52 GMT
338
+ - request:
339
+ method: get
340
+ uri: http://wayback.archive.org/web/20110715052543im_/http:/drpep.com/images/home_19.gif
341
+ body:
342
+ encoding: US-ASCII
343
+ string: ''
344
+ headers:
345
+ accept:
346
+ - ! '*/*; q=0.5, application/xml'
347
+ accept-encoding:
348
+ - gzip, deflate
349
+ cookie:
350
+ - Domain=archive.org; Expires=Sat; wayback_server=94
351
+ user-agent:
352
+ - Ruby
353
+ response:
354
+ status:
355
+ code: 302
356
+ message: Moved Temporarily
357
+ headers:
358
+ server:
359
+ - Tengine/1.3.0
360
+ date:
361
+ - Thu, 24 Jan 2013 03:03:52 GMT
362
+ connection:
363
+ - keep-alive
364
+ location:
365
+ - /web/20110721121019im_/http://drpep.com/images/home_19.gif
366
+ content-length:
367
+ - '0'
368
+ x-page-cache:
369
+ - HIT
370
+ body:
371
+ encoding: US-ASCII
372
+ string: ''
373
+ http_version: '1.1'
374
+ recorded_at: Thu, 24 Jan 2013 03:03:52 GMT
375
+ - request:
376
+ method: get
377
+ uri: http://wayback.archive.org/web/20110721121019im_/http:/drpep.com/images/home_19.gif
378
+ body:
379
+ encoding: US-ASCII
380
+ string: ''
381
+ headers:
382
+ accept:
383
+ - ! '*/*; q=0.5, application/xml'
384
+ accept-encoding:
385
+ - gzip, deflate
386
+ cookie:
387
+ - Domain=archive.org; Expires=Sat; wayback_server=94
388
+ user-agent:
389
+ - Ruby
390
+ response:
391
+ status:
392
+ code: 302
393
+ message: Moved Temporarily
394
+ headers:
395
+ server:
396
+ - Tengine/1.3.0
397
+ date:
398
+ - Thu, 24 Jan 2013 03:03:52 GMT
399
+ connection:
400
+ - keep-alive
401
+ location:
402
+ - /web/20110715052543im_/http://drpep.com/images/home_19.gif
403
+ content-length:
404
+ - '0'
405
+ x-page-cache:
406
+ - HIT
407
+ body:
408
+ encoding: US-ASCII
409
+ string: ''
410
+ http_version: '1.1'
411
+ recorded_at: Thu, 24 Jan 2013 03:03:52 GMT
412
+ recorded_with: VCR 2.3.0
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.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -193,6 +193,7 @@ files:
193
193
  - spec/vcr/follow/uri_error.yml
194
194
  - spec/vcr/get/basic.yml
195
195
  - spec/vcr/get/doesnt_exist.yml
196
+ - spec/vcr/get/infinite_redirects.yml
196
197
  - spec/vcr/get/params.yml
197
198
  - spec/vcr/get/proxy.yml
198
199
  homepage: http://github.com/axsuul/dubdubdub
@@ -210,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
211
  version: '0'
211
212
  segments:
212
213
  - 0
213
- hash: 4073235674561133730
214
+ hash: 1726643959394672028
214
215
  required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  none: false
216
217
  requirements: