Class: RailsInformant::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_informant/doctor.rb

Overview

The informant:doctor channel: reports the integration state, prints the fix, refreshes the drift flag, and returns a process exit code (nonzero on stale or error) so it doubles as a CI signal. A thin wrapper over Integration that never raises out — a diagnostic must not crash the run it reports on.

Instance Method Summary collapse

Constructor Details

#initialize(integration: Integration.new, io: $stdout) ⇒ Doctor

Returns a new instance of Doctor.



9
10
11
12
# File 'lib/rails_informant/doctor.rb', line 9

def initialize(integration: Integration.new, io: $stdout)
  @integration = integration
  @io = io
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rails_informant/doctor.rb', line 14

def run
  status = @integration.status
  @integration.write_drift_flag stale: status == :stale
  @io.puts report_for(status)
  exit_code_for status
rescue StandardError => e
  # An unexpected failure must exit nonzero, not 0 — a doctor wired into CI
  # to gate drift must never report a false green when it could not check.
  @io.puts "[Informant] doctor could not complete: #{e.message}"
  1
end