dubdubdub 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,81 @@
1
- dubdubdub
1
+ DubDubDub
2
2
  =========
3
3
 
4
- Networking dubstep.
4
+ World wide web dubstep... and this is our [theme song](http://www.youtube.com/watch?v=OR6AV9yJPoM).
5
+
6
+ Description
7
+ ===========
8
+
9
+ So what the hell this? This is a layer for two very useful http libraries: [rest-client](https://github.com/archiloque/rest-client) and [mechanize](https://github.com/sparklemotion/mechanize). If you do any sort of web crawling, browsing, URL following and want to consolidate all your tools in one library, then this one's for you. And if you're serious about that stuff, you're probably using proxies. `DubDubDub` makes it easy to configure proxies for everything you do.
10
+
11
+ Install
12
+ =======
13
+
14
+ ```
15
+ gem install dubdubdub
16
+ ```
17
+
18
+ Basics
19
+ ======
20
+
21
+ ```ruby
22
+ www = DubDubDub.new
23
+
24
+ # Uses rest-client and returns a Nokogiri::Document
25
+ www.crawl "http://google.com"
26
+
27
+ # Uses mechanize and returns a Mechanize::Page
28
+ www.browse "http://google.com"
29
+
30
+ # Follows and returns the end URL
31
+ www.follow "http://bit.ly/abcdefg"
32
+
33
+ # Be RESTful
34
+ www.get "http://google.com"
35
+ www.post "http://google.com", {}
36
+ www.delete "http://google.com", {}
37
+ ```
38
+
39
+ Proxies
40
+ =======
41
+
42
+ ```ruby
43
+ www = DubDubDub.new(proxy: "1.2.3.4:80")
44
+
45
+ # Now all requests will use the proxy
46
+ www.crawl "http://google.com"
47
+ ```
48
+
49
+ Configuration
50
+ =============
51
+
52
+ Set a global proxy to use.
53
+
54
+ ```ruby
55
+ DubDubDub.configure do |config|
56
+ config.proxy = "1.2.3.4:8080"
57
+ end
58
+
59
+ www = DubDubDub.new(proxy: true)
60
+ ```
61
+
62
+ Be fancy and customize the proxies you want to use by passing in a block which will be called when using a proxy.
63
+
64
+ ```ruby
65
+ DubDubDub.configure do |config|
66
+ config.proxy do
67
+ ["1.2.3.4:8080", "1.2.3.4:80"].sample
68
+ end
69
+ end
70
+
71
+ www = DubDubDub.new(proxy: true)
72
+ www.proxy # => 1.2.3.4:8080 OR 1.2.3.4:80
73
+ ```
74
+
75
+ Ignore all proxies (useful for testing).
76
+
77
+ ```ruby
78
+ DubDubDub.configure do |config|
79
+ config.ignore_proxy = true
80
+ end
81
+ ```
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.0"
8
+ s.version = "0.3.1"
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 = "2012-12-04"
12
+ s.date = "2012-12-23"
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
@@ -1,6 +1,6 @@
1
1
  class DubDubDub
2
2
  # Version
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
 
5
5
  attr_accessor :client
6
6
 
@@ -1,6 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'nokogiri'
3
3
  require 'mechanize'
4
+ require 'rest-client'
4
5
 
5
6
  class DubDubDub::Client
6
7
  attr_accessor :proxy_host, :proxy_port, :proxy_user, :proxy_password
@@ -78,11 +78,13 @@ class DubDubDub::ResponseError < DubDubDub::Error
78
78
  @code = code.to_i
79
79
  end
80
80
 
81
- def message
81
+ def status_message
82
82
  STATUSES[code.to_i]
83
83
  end
84
84
 
85
85
  def to_s
86
- "#{code}: #{message} => #{error.class.name}: #{error.message}"
86
+ "#{code}: #{status_message} => #{error.class.name}: #{error.message}"
87
87
  end
88
+
89
+ alias :message :to_s
88
90
  end
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.0
4
+ version: 0.3.1
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: 2012-12-04 00:00:00.000000000 Z
12
+ date: 2012-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  segments:
210
210
  - 0
211
- hash: -785216853355672732
211
+ hash: 4360410541068935812
212
212
  required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  none: false
214
214
  requirements: