Class: Html2rss::FeedResolution::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/feed_resolution.rb

Overview

Internal tournament runner (keeps Html2rss::FeedResolution a Zeitwerk namespace module).

Instance Method Summary collapse

Constructor Details

#initialize(entry_url:, response:, session:, config:, articles:, surface_category: nil) ⇒ Runner

rubocop:disable Metrics/ParameterLists -- tournament context stays co-located

Parameters:

Raises:

  • (ArgumentError)


196
197
198
199
200
201
202
203
204
205
# File 'lib/html2rss/feed_resolution.rb', line 196

def initialize(entry_url:, response:, session:, config:, articles:, surface_category: nil)
  raise ArgumentError, 'articles must be an Array' unless articles.is_a?(Array)

  @entry_url = Html2rss::Url.from_absolute(entry_url)
  @response = response
  @session = session
  @config = config
  @articles = articles
  @surface_category = surface_category
end

Instance Method Details

#callResult

rubocop:disable Metrics/AbcSize, Metrics/MethodLength -- policy → candidates → probe → select

Returns:



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/html2rss/feed_resolution.rb', line 211

def call
  return skip(:policy_skip) unless Policy.resolve?(
    config:, articles:, surface_category:
  )

  candidates = CandidateGenerator.call(
    entry_url:,
    response:,
    max: max_probes
  )
  return skip(:no_candidates) if candidates.empty?

  scored = probe_candidates(candidates)
  winner = Scorer.pick_winner(scored:, entry_articles_count: articles.size)
  return skip(:no_winner, probe_count: scored.size) unless winner

  apply(winner, probe_count: scored.size)
end