Class: DataChecks::StatusPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/data_checks/status_printer.rb

Instance Method Summary collapse

Constructor Details

#initialize(io = $stdout) ⇒ StatusPrinter

Returns a new instance of StatusPrinter.



5
6
7
# File 'lib/data_checks/status_printer.rb', line 5

def initialize(io = $stdout)
  @io = io
end

Instance Method Details



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/data_checks/status_printer.rb', line 9

def print
  runs = DataChecks::CheckRun.all.to_a
  counts = Hash.new { |h, k| h[k] = 0 }

  DataChecks.config.checks.each do |check|
    run = runs.find { |r| r.name == check.name }

    if run
      counts[run.status] += 1

      formatted_time = run.last_run_at.to_formatted_s(:db)
      @io.puts("Check #{check.name} (at #{formatted_time}) - #{run.status.titleize}")
    else
      counts["not_ran"] += 1
      @io.puts("Check #{check.name} - Not ran yet")
    end
  end

  @io.puts
  print_summary(counts)
end