Class: Crawlr::Config
- Inherits:
-
Object
- Object
- Crawlr::Config
- Defined in:
- lib/crawlr/config.rb
Overview
Configuration management class for Crawlr scraping sessions.
The Config class centralizes all configuration options for the Crawlr framework, providing sensible defaults while allowing extensive customization of scraping behavior, networking settings, error handling, and crawling policies.
Instance Attribute Summary collapse
- #allow_cookies ⇒ Integer, ...
- #allow_url_revisit ⇒ Integer, ...
- #allowed_domains ⇒ Integer, ...
- #domain_glob ⇒ Integer, ...
- #headers ⇒ Integer, ...
- #ignore_robots_txt ⇒ Integer, ...
- #max_depth ⇒ Integer, ...
- #max_parallelism ⇒ Integer, ...
- #max_retries ⇒ Integer, ...
- #max_visited ⇒ Integer, ...
- #proxies ⇒ Integer, ...
- #proxy_strategy ⇒ Integer, ...
- #random_delay ⇒ Integer, ...
- #retry_backoff ⇒ Integer, ...
- #retry_delay ⇒ Integer, ...
- #retryable_errors ⇒ Integer, ...
- #timeout ⇒ Integer, ...
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
Initializes a new Config instance with the provided options.
-
#to_h ⇒ Hash<Symbol, Object>
Converts the configuration to a hash representation.
Constructor Details
#initialize(options = {}) ⇒ Config
Initializes a new Config instance with the provided options
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/crawlr/config.rb', line 108 def initialize( = {}) initialize_domain_settings() initialize_parallelism_settings() initialize_throttle_settings() initialize_http_settings() initialize_retry_settings() initialize_visit_settings() initialize_proxy_settings() initialize_robots_settings() validate end |
Instance Attribute Details
#allow_cookies ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def @allow_cookies end |
#allow_url_revisit ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def allow_url_revisit @allow_url_revisit end |
#allowed_domains ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def allowed_domains @allowed_domains end |
#domain_glob ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def domain_glob @domain_glob end |
#headers ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def headers @headers end |
#ignore_robots_txt ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def ignore_robots_txt @ignore_robots_txt end |
#max_depth ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def max_depth @max_depth end |
#max_parallelism ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def max_parallelism @max_parallelism end |
#max_retries ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def max_retries @max_retries end |
#max_visited ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def max_visited @max_visited end |
#proxies ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def proxies @proxies end |
#proxy_strategy ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def proxy_strategy @proxy_strategy end |
#random_delay ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def random_delay @random_delay end |
#retry_backoff ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def retry_backoff @retry_backoff end |
#retry_delay ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def retry_delay @retry_delay end |
#retryable_errors ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def retryable_errors @retryable_errors end |
#timeout ⇒ Integer, ...
54 55 56 |
# File 'lib/crawlr/config.rb', line 54 def timeout @timeout end |
Instance Method Details
#to_h ⇒ Hash<Symbol, Object>
Converts the configuration to a hash representation
This method is useful for serialization, debugging, or creating new Config instances with the same settings.
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/crawlr/config.rb', line 135 def to_h attrs = %i[ timeout headers allowed_domains domain_glob allow_cookies max_depth random_delay max_parallelism allow_url_revisit max_retries retry_delay retry_backoff retryable_errors max_visited proxies proxy_strategy ignore_robots_txt ] attrs.each_with_object({}) { |name, hash| hash[name] = instance_variable_get("@#{name}") } end |