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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fe64c3a39411580b172dee7b78d3881eb4c6adb
4
- data.tar.gz: bef4e0293b96c681fff87a4ed1aee82bc0d5b596
3
+ metadata.gz: 38cdb59fef090cca25e655130d91518ac3357946
4
+ data.tar.gz: fbef2837395c170a06f357d15265dc276b3c941e
5
5
  SHA512:
6
- metadata.gz: 8a32016d854eb268db463e123fa387e593cd15517ec87858851f5b5b64c1affdef403f8092d1133a7396606283f49cf4d4cd21753d04d985824dd0d8392f6211
7
- data.tar.gz: adb5c27511b1b19aae97da7df82acf0c1ad51604bba504d02cb8d2c99f937e0fc70ed59d264197d422fbcdbc3f04e334b4121a30ceaf9cf3a92a6dfbd4fd9f55
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, Rails.application.config.proxies.user, Rails.application.config.proxies.password)
20
+ __getobj__.set_proxy(proxy.ip, proxy.port, ProxyService.username, ProxyService.password)
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  class ProxyService
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  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, false) # Rails.application.config.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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley