proxy_service 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/proxy_service/mechanize_agent.rb +1 -1
- data/lib/proxy_service/version.rb +1 -1
- data/lib/proxy_service.rb +15 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38cdb59fef090cca25e655130d91518ac3357946
|
4
|
+
data.tar.gz: fbef2837395c170a06f357d15265dc276b3c941e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cc615ca48de232996ce1e7d2d332aab56faca1346b3be171161815991447d4be1e647b126e9cd868a5b9a3ad69dbdbb9908f9442aa33967291cb79ea925d5e6
|
7
|
+
data.tar.gz: 818e762409a5c513f4191d88ea062d0960c65dbf121a284f965da9fb56bfef4cf827d3ca6f64a702b37ff58ad2e2ce68236b72dda63a07fe75a29e6d7e1ad293
|
@@ -17,6 +17,6 @@ class ProxyService::MechanizeAgent < DelegateClass(Mechanize)
|
|
17
17
|
# @param [#ip, #port] proxy object that holds the ip and port
|
18
18
|
def set_proxy(proxy)
|
19
19
|
return unless proxy.ip
|
20
|
-
__getobj__.set_proxy(proxy.ip, proxy.port,
|
20
|
+
__getobj__.set_proxy(proxy.ip, proxy.port, ProxyService.username, ProxyService.password)
|
21
21
|
end
|
22
22
|
end
|
data/lib/proxy_service.rb
CHANGED
@@ -2,28 +2,34 @@ require 'json'
|
|
2
2
|
|
3
3
|
class ProxyService
|
4
4
|
|
5
|
-
# = Class
|
6
|
-
# @example Usage
|
7
|
-
#
|
8
|
-
# ProxyService.new(:queue_name).with_mechanize do |agent|
|
9
|
-
# agent.get('...')
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
|
13
5
|
POLL_PERIOD = 1
|
14
6
|
MAX_FAILURES = 3
|
15
7
|
|
8
|
+
class << self
|
9
|
+
attr_accessor :proxies_enabled, :username, :password
|
10
|
+
|
11
|
+
def configure
|
12
|
+
yield self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
16
|
attr_accessor :source
|
17
17
|
attr_writer :proxies_enabled
|
18
18
|
|
19
19
|
# = Create a new proxy service with for a specific ODS
|
20
20
|
#
|
21
|
+
# @example
|
22
|
+
#
|
23
|
+
# ProxyService.new(:queue_name).with_mechanize do |agent|
|
24
|
+
# agent.get('...')
|
25
|
+
# end
|
26
|
+
#
|
21
27
|
# @param [String|Symbol] source name of the ODS (e.g. :tripadvisor), will look for a queue with that name "proxy/#{source}"
|
22
28
|
# @param [Hash] options
|
23
29
|
# @option options [Boolean] :proxies_enabled override the app configuration
|
24
30
|
def initialize(source, options = {})
|
25
31
|
@source = source
|
26
|
-
@proxies_enabled = options.fetch(:proxies_enabled,
|
32
|
+
@proxies_enabled = options.fetch(:proxies_enabled, !!self.class.proxies_enabled)
|
27
33
|
end
|
28
34
|
|
29
35
|
# @yield [agent] Passes a [proxied] Mechanize agent to the block
|