Class: ProxyFetcher::Configuration
- Inherits:
-
Object
- Object
- ProxyFetcher::Configuration
- 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
- DEFAULT_ADAPTER =
:nokogiri
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#http_client ⇒ Object
Returns the value of attribute http_client.
-
#pool_size ⇒ Object
Returns the value of attribute pool_size.
-
#providers ⇒ Object
(also: #provider)
Returns the value of attribute providers.
-
#proxy_validator ⇒ Object
Returns the value of attribute proxy_validator.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Class Method Summary collapse
- .providers_registry ⇒ Object
- .register_provider(name, klass) ⇒ Object
- .registered_providers ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#reset! ⇒ Object
Sets default configuration options.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
25 26 27 |
# File 'lib/proxy_fetcher/configuration.rb', line 25 def initialize reset! end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
4 5 6 |
# File 'lib/proxy_fetcher/configuration.rb', line 4 def adapter @adapter end |
#http_client ⇒ Object
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_size ⇒ Object
Returns the value of attribute pool_size.
3 4 5 |
# File 'lib/proxy_fetcher/configuration.rb', line 3 def pool_size @pool_size end |
#providers ⇒ Object Also known as: provider
Returns the value of attribute providers.
4 5 6 |
# File 'lib/proxy_fetcher/configuration.rb', line 4 def providers @providers end |
#proxy_validator ⇒ Object
Returns the value of attribute proxy_validator.
4 5 6 |
# File 'lib/proxy_fetcher/configuration.rb', line 4 def proxy_validator @proxy_validator end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/proxy_fetcher/configuration.rb', line 3 def timeout @timeout end |
#user_agent ⇒ Object
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_registry ⇒ Object
12 13 14 |
# File 'lib/proxy_fetcher/configuration.rb', line 12 def providers_registry @registry ||= ProvidersRegistry.new end |
.register_provider(name, klass) ⇒ Object
16 17 18 |
# File 'lib/proxy_fetcher/configuration.rb', line 16 def register_provider(name, klass) providers_registry.register(name, klass) end |
.registered_providers ⇒ Object
20 21 22 |
# File 'lib/proxy_fetcher/configuration.rb', line 20 def registered_providers providers_registry.providers.keys end |
Instance Method Details
#reset! ⇒ Object
Sets default configuration options
30 31 32 33 34 35 36 37 38 |
# File 'lib/proxy_fetcher/configuration.rb', line 30 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 |