Class: Html2rss::Capture
- Inherits:
-
Object
- Object
- Html2rss::Capture
- Defined in:
- lib/html2rss/capture.rb
Overview
Analyzes a URL and produces a reusable feed config hash with derived CSS selectors.
Uses the auto-source pipeline to extract articles, then traces back through SST segments to build items + attribute selectors suitable for a static feed config.
Defined Under Namespace
Classes: CaptureResult
Class Method Summary collapse
-
.build(url, strategy: :auto) ⇒ CaptureResult
Analyzes a URL and builds a reusable feed config.
Instance Method Summary collapse
-
#build ⇒ CaptureResult
Runs the capture pipeline.
-
#initialize(url, strategy: :auto, **options) ⇒ Capture
constructor
A new instance of Capture.
Constructor Details
#initialize(url, strategy: :auto, **options) ⇒ Capture
Returns a new instance of Capture.
46 47 48 49 50 51 52 53 54 |
# File 'lib/html2rss/capture.rb', line 46 def initialize(url, strategy: :auto, **) @url = url @strategy = strategy @items_selector_hint = .delete(:items_selector) @max_redirects = .delete(:max_redirects) @max_requests = .delete(:max_requests) @limit = .delete(:limit) @local_file_path = .delete(:local_file_path) end |
Class Method Details
.build(url, strategy: :auto) ⇒ CaptureResult
Analyzes a URL and builds a reusable feed config.
32 33 34 |
# File 'lib/html2rss/capture.rb', line 32 def build(url, strategy: :auto, **) new(url, strategy:, **).build end |
Instance Method Details
#build ⇒ CaptureResult
Runs the capture pipeline.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/html2rss/capture.rb', line 60 def build # rubocop:disable Metrics/MethodLength response = fetch_response articles = extract_articles(response) selectors = derive_selectors(response, articles) config = { channel: build_channel(response), selectors: selectors.empty? ? nil : selectors, ** }.compact CaptureResult.new( config:, articles_count: articles.size, channel_title: channel_title_from(response) ) end |