lib/html2rss/auto_source/channel.rb in html2rss-0.13.0 vs lib/html2rss/auto_source/channel.rb in html2rss-0.14.0

- old
+ new

@@ -8,33 +8,39 @@ # 2. the HTTP response class Channel ## # # @param parsed_body [Nokogiri::HTML::Document] The parsed HTML document. - # @param response [Faraday::Response] The URL of the HTML document. - def initialize(parsed_body, url:, response:, articles: []) + # @param url [Addressable::URI] The URL of the channel. + # @param headers [Hash<String, String>] the http headers + # @param articles [Array<Html2rss::AutoSource::Article>] The articles. + def initialize(parsed_body, url:, headers:, articles: [], stylesheets: []) @parsed_body = parsed_body @url = url - @response = response + @headers = headers @articles = articles + @stylesheets = stylesheets end + attr_writer :articles + attr_reader :stylesheets + def url = extract_url def title = extract_title def language = extract_language def description = extract_description def image = extract_image def ttl = extract_ttl - def last_build_date = response.headers['last-modified'] + def last_build_date = headers['last-modified'] def generator "html2rss V. #{::Html2rss::VERSION} (using auto_source scrapers: #{scraper_counts})" end private - attr_reader :parsed_body, :response + attr_reader :parsed_body, :headers def extract_url @url.normalize.to_s end @@ -56,10 +62,10 @@ url = parsed_body.at_css('meta[property="og:image"]')&.[]('content') Html2rss::Utils.sanitize_url(url) if url end def extract_ttl - ttl = response.headers['cache-control']&.match(/max-age=(\d+)/)&.[](1) + ttl = headers['cache-control']&.match(/max-age=(\d+)/)&.[](1) return unless ttl ttl.to_i.fdiv(60).ceil end