dubdubdub 0.3.9 → 0.4.0
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.
- checksums.yaml +4 -4
- data/dubdubdub.gemspec +2 -2
- data/lib/dubdubdub.rb +1 -1
- data/lib/dubdubdub/client.rb +18 -6
- data/spec/dubdubdub_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 539019bb4ef032b1ed9e449a1bbfbbd81bd6259f
|
|
4
|
+
data.tar.gz: 5b51570cb2465086030f59776633ea8c22d0c719
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: faf635beb4993d2f7580ad4b0c593584d6ce48c51a428c4d1137a99a4fc1f67b19c77942c2773b99348728094003bece00d19d2af14704881e5ca5411ad86ff1
|
|
7
|
+
data.tar.gz: b6b4934910f0ff2510a892f915d4af707fca85b5918ef20406eb6b6dea60d1dda00badf16ce515d7667b4d659000a4f12faddd8f6829f16d099ea585e28259b5
|
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.
|
|
8
|
+
s.version = "0.4.0"
|
|
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 = "2014-
|
|
12
|
+
s.date = "2014-11-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
|
@@ -4,7 +4,10 @@ require 'mechanize'
|
|
|
4
4
|
require 'rest-client'
|
|
5
5
|
|
|
6
6
|
class DubDubDub::Client
|
|
7
|
-
attr_accessor :proxy_host,
|
|
7
|
+
attr_accessor :proxy_host,
|
|
8
|
+
:proxy_port,
|
|
9
|
+
:proxy_username,
|
|
10
|
+
:proxy_password
|
|
8
11
|
|
|
9
12
|
def initialize(options = {})
|
|
10
13
|
default_options = {
|
|
@@ -36,15 +39,24 @@ class DubDubDub::Client
|
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
def proxy=(url)
|
|
39
|
-
|
|
42
|
+
matches = url.match(/(?:(?<username>[^\:]+)\:(?<password>[^\@]+)\@)?(?<host>[\.0-9]+|localhost)(?:\:(?<port>[0-9]+))?/)
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
self.
|
|
43
|
-
self.
|
|
44
|
+
self.proxy_host = matches[:host]
|
|
45
|
+
self.proxy_port = matches[:port] || 80
|
|
46
|
+
self.proxy_username = matches[:username]
|
|
47
|
+
self.proxy_password = matches[:password]
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def proxy
|
|
47
|
-
|
|
51
|
+
if proxy_host and proxy_port
|
|
52
|
+
address = "#{proxy_host}:#{proxy_port}"
|
|
53
|
+
|
|
54
|
+
if proxy_username and proxy_password
|
|
55
|
+
address.prepend("#{proxy_username}:#{proxy_password}@")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
address
|
|
48
60
|
end
|
|
49
61
|
|
|
50
62
|
def proxy?
|
data/spec/dubdubdub_spec.rb
CHANGED
|
@@ -31,6 +31,17 @@ describe DubDubDub do
|
|
|
31
31
|
www.proxy_port.should == 80
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
it "can specify user and password for proxy" do
|
|
35
|
+
address = "user:pass@203.131.212.166:55555"
|
|
36
|
+
|
|
37
|
+
www = DubDubDub.new(proxy: address)
|
|
38
|
+
www.proxy_host.should == "203.131.212.166"
|
|
39
|
+
www.proxy_port.should == 55555
|
|
40
|
+
www.proxy_username.should == "user"
|
|
41
|
+
www.proxy_password.should == "pass"
|
|
42
|
+
www.proxy.should == address
|
|
43
|
+
end
|
|
44
|
+
|
|
34
45
|
it "can configure to use a proxy globally" do
|
|
35
46
|
DubDubDub.configure do |config|
|
|
36
47
|
config.proxy = "localhost:8000"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dubdubdub
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Hu
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|