luminati 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/luminati.rb +3 -2
- data/lib/luminati/client.rb +17 -8
- data/lib/luminati/errors.rb +3 -0
- data/luminati.gemspec +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9adc62b4fd44c0b0e920daf365d0ccc4af9388b8
|
4
|
+
data.tar.gz: cf70c9548e92575255cd5df94710e7cd8998fee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efebc81f6a72f0ca7cb1cd43121c9aaa21c9148b4554e61bc1ec96856ed742d7a6fca96c0491acc44f63dc6e301c6406493a0a6295b77f3c1b88f05aa197c463
|
7
|
+
data.tar.gz: 757cc46a7f860a163ec39e53cd93167cac9e077c37818d91fd76cbb2777f39e0e72be55f84aba56dc92c0436334921d33b3a688af238d24fd21af1088b58958d
|
data/lib/luminati.rb
CHANGED
data/lib/luminati/client.rb
CHANGED
@@ -2,7 +2,7 @@ require 'faraday'
|
|
2
2
|
|
3
3
|
module Luminati
|
4
4
|
class Client
|
5
|
-
attr_accessor :username, :password, :zone, :port, :urls
|
5
|
+
attr_accessor :username, :password, :zone, :port, :urls, :regexes
|
6
6
|
|
7
7
|
def initialize(username, password, zone: :gen, port: 22225)
|
8
8
|
self.username = username
|
@@ -14,6 +14,10 @@ module Luminati
|
|
14
14
|
self.urls = {
|
15
15
|
master_proxy: "http://client.luminati.io/api/get_super_proxy"
|
16
16
|
}
|
17
|
+
|
18
|
+
self.regexes = {
|
19
|
+
failed_auth: /failed\sauth/i
|
20
|
+
}
|
17
21
|
end
|
18
22
|
|
19
23
|
def get_connection(country: nil, dns_resolution: :remote, session: nil)
|
@@ -38,20 +42,16 @@ module Luminati
|
|
38
42
|
def fetch_master_proxy(country: nil)
|
39
43
|
arguments = {raw: 1}
|
40
44
|
arguments.merge!(country: country) if country
|
41
|
-
|
42
|
-
response = get_response(self.urls[:master_proxy], arguments)
|
43
|
-
proxy = (response && response.body) ? response.body : nil
|
45
|
+
proxy = get_response(self.urls[:master_proxy], arguments)
|
44
46
|
end
|
45
47
|
|
46
48
|
def fetch_master_proxies(limit: 10)
|
47
49
|
arguments = {format: :json, limit: limit}
|
48
|
-
|
49
|
-
proxies = (response && response.body) ? response.body : nil
|
50
|
+
proxies = get_response(self.urls[:master_proxy], arguments)
|
50
51
|
end
|
51
52
|
|
52
53
|
def ping_master_proxy(address, port: self.port)
|
53
54
|
response = get_response("http://#{address}:#{port}/ping")
|
54
|
-
return (response && response.body) ? response.body : nil
|
55
55
|
end
|
56
56
|
|
57
57
|
def ping_master_proxies(proxies, port: self.port)
|
@@ -70,7 +70,7 @@ module Luminati
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def format_username(username)
|
73
|
-
username
|
73
|
+
username = (username =~ /-zone-([a-z0-9]*)/i).nil? ? "#{username}-zone-#{self.zone}" : username
|
74
74
|
end
|
75
75
|
|
76
76
|
def get_response(url, arguments = {}, options = {})
|
@@ -78,10 +78,19 @@ module Luminati
|
|
78
78
|
|
79
79
|
connection = build_connection(options)
|
80
80
|
response = connection.get(url, arguments)
|
81
|
+
response = (response && response.body) ? response.body : nil
|
82
|
+
|
83
|
+
check_response_for_errors(response)
|
81
84
|
|
82
85
|
return response
|
83
86
|
end
|
84
87
|
|
88
|
+
def check_response_for_errors(response)
|
89
|
+
if (response && response.is_a?(String) && response.present?)
|
90
|
+
raise Luminati::FailedAuthError, "Failed to authenticate your account with Luminati.io. Please check your credentials or the contract for your account." if response =~ self.regexes[:failed_auth]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
85
94
|
def build_connection(options = {})
|
86
95
|
options.merge!(:ssl => {:verify => false})
|
87
96
|
|
data/luminati.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'luminati'
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.2'
|
7
7
|
|
8
8
|
s.homepage = "https://github.com/Agiley/Luminati"
|
9
9
|
s.email = "sebastian@agiley.se"
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
Rakefile
|
27
27
|
lib/luminati.rb
|
28
28
|
lib/luminati/client.rb
|
29
|
+
lib/luminati/errors.rb
|
29
30
|
luminati.gemspec
|
30
31
|
spec/spec_helper.rb
|
31
32
|
]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luminati
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Johnsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- Rakefile
|
80
80
|
- lib/luminati.rb
|
81
81
|
- lib/luminati/client.rb
|
82
|
+
- lib/luminati/errors.rb
|
82
83
|
- luminati.gemspec
|
83
84
|
- spec/spec_helper.rb
|
84
85
|
homepage: https://github.com/Agiley/Luminati
|