8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/miteru/crawler.rb', line 8
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.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
|