Class: CIRunner::LogDownloader
- Inherits:
-
Object
- Object
- CIRunner::LogDownloader
- Defined in:
- lib/ci_runner/log_downloader.rb
Overview
A PORO to help download and cache a GitHub CI log.
Instance Method Summary collapse
-
#fetch(&block) ⇒ Pathname
Ask the @check_run to download the log from its CI or retrieve it from disk in case we previously downloaded it.
-
#initialize(check_run) ⇒ LogDownloader
constructor
A new instance of LogDownloader.
Constructor Details
#initialize(check_run) ⇒ LogDownloader
Returns a new instance of LogDownloader.
24 25 26 |
# File 'lib/ci_runner/log_downloader.rb', line 24 def initialize(check_run) @check_run = check_run end |
Instance Method Details
#fetch(&block) ⇒ Pathname
Ask the @check_run to download the log from its CI or retrieve it from disk in case we previously downloaded it.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ci_runner/log_downloader.rb', line 34 def fetch(&block) return cached_log if cached_log error = nil ::CLI::UI.spinner("Downloading CI logs from #{@check_run.provider}", auto_debrief: false) do cache_log(@check_run.download_log) rescue Client::Error, Error => e error = e ::CLI::UI::Spinner::TASK_FAILED end block.call(error) if error cached_log end |