Sha256: 6e308144e558c71fcee710f824b73392efffa9e040e846b82d7d514d797f6ac9
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Miteru class Crawler < Service # # @param [Miteru::Website] website # def call(website) Try[OpenSSL::SSL::SSLError, ::HTTP::Error, Addressable::URI::InvalidURIError] do Miteru.logger.info("Website:#{website.truncated_url} has #{website.kits.length} kit(s).") return unless website.has_kits? notify website return unless auto_download? website.kits.each do |kit| downloader = Downloader.new(kit) result = downloader.result if result.success? Miteru.logger.info("Kit:#{kit.truncated_url} downloaded as #{result.value!}") else Miteru.logger.warn("Kit:#{kit.truncated_url} failed to download - #{result.failure}") end end end.recover { nil }.value! end private def auto_download? Miteru.config.auto_download end def notify(website) Parallel.each(notifiers) { |notifier| notifier.call(website) } end # # @return [Array<Miteru::Notifiers::Base>] # def notifiers @notifiers ||= Miteru.notifiers.map(&:new) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
miteru-2.0.1 | lib/miteru/crawler.rb |
miteru-2.0.0 | lib/miteru/crawler.rb |