Class: ProxyFetcher::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/proxy_fetcher/configuration.rb

Constant Summary collapse

DEFAULT_USER_AGENT =

rubocop:disable Metrics/LineLength

'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112 Safari/537.36'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



23
24
25
# File 'lib/proxy_fetcher/configuration.rb', line 23

def initialize
  reset!
end

Instance Attribute Details

#http_clientObject

Returns the value of attribute http_client.



4
5
6
# File 'lib/proxy_fetcher/configuration.rb', line 4

def http_client
  @http_client
end

#pool_sizeObject

Returns the value of attribute pool_size.



3
4
5
# File 'lib/proxy_fetcher/configuration.rb', line 3

def pool_size
  @pool_size
end

#providersObject Also known as: provider

Returns the value of attribute providers.



3
4
5
# File 'lib/proxy_fetcher/configuration.rb', line 3

def providers
  @providers
end

#proxy_validatorObject

Returns the value of attribute proxy_validator.



4
5
6
# File 'lib/proxy_fetcher/configuration.rb', line 4

def proxy_validator
  @proxy_validator
end

#timeoutObject

Returns the value of attribute timeout.



3
4
5
# File 'lib/proxy_fetcher/configuration.rb', line 3

def timeout
  @timeout
end

#user_agentObject

Returns the value of attribute user_agent.



3
4
5
# File 'lib/proxy_fetcher/configuration.rb', line 3

def user_agent
  @user_agent
end

Class Method Details

.providers_registryObject



10
11
12
# File 'lib/proxy_fetcher/configuration.rb', line 10

def providers_registry
  @registry ||= ProvidersRegistry.new
end

.register_provider(name, klass) ⇒ Object



14
15
16
# File 'lib/proxy_fetcher/configuration.rb', line 14

def register_provider(name, klass)
  providers_registry.register(name, klass)
end

.registered_providersObject



18
19
20
# File 'lib/proxy_fetcher/configuration.rb', line 18

def registered_providers
  providers_registry.providers.keys
end

Instance Method Details

#reset!Object

Sets default configuration options



28
29
30
31
32
33
34
35
36
# File 'lib/proxy_fetcher/configuration.rb', line 28

def reset!
  @user_agent = DEFAULT_USER_AGENT
  @pool_size = 10
  @timeout = 3
  @http_client = HTTPClient
  @proxy_validator = ProxyValidator

  self.providers = self.class.registered_providers
end