Class: RepoTender::UI::JsonReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/repo_tender/ui/json_reporter.rb

Overview

Emits one JSON object per event line (12-factor style) to ‘out`. Every object carries at minimum: “event”, “t” (ISO8601 timestamp), plus event-specific keys (ref, status, error, total, summary).

Instance Method Summary collapse

Constructor Details

#initialize(out) ⇒ JsonReporter

Returns a new instance of JsonReporter.



13
14
15
16
# File 'lib/repo_tender/ui/json_reporter.rb', line 13

def initialize(out)
  @out = out
  @out.sync = true
end

Instance Method Details

#attach(task) ⇒ Object



18
# File 'lib/repo_tender/ui/json_reporter.rb', line 18

def attach(task) = nil

#detachObject



19
# File 'lib/repo_tender/ui/json_reporter.rb', line 19

def detach = nil

#listing_finishedObject



23
# File 'lib/repo_tender/ui/json_reporter.rb', line 23

def listing_finished = emit(event: "listing_finished")

#listing_started(total:) ⇒ Object



21
# File 'lib/repo_tender/ui/json_reporter.rb', line 21

def listing_started(total:) = emit(event: "listing_started", total: total)

#org_listed(ref, count:) ⇒ Object



22
# File 'lib/repo_tender/ui/json_reporter.rb', line 22

def org_listed(ref, count:) = emit(event: "org_listed", org: ref.name, count: count)

#repo_failed(ref, error) ⇒ Object



29
# File 'lib/repo_tender/ui/json_reporter.rb', line 29

def repo_failed(ref, error) = emit(event: "repo_failed", ref: ref, error: error.to_s)

#repo_finished(ref, status, action:, commits: 0) ⇒ Object



28
# File 'lib/repo_tender/ui/json_reporter.rb', line 28

def repo_finished(ref, status, action:, commits: 0) = emit(event: "repo_finished", ref: ref, status: status, action: action, commits: commits)

#repo_phase(ref, phase) ⇒ Object



27
# File 'lib/repo_tender/ui/json_reporter.rb', line 27

def repo_phase(ref, phase) = emit(event: "repo_phase", ref: ref, phase: phase)

#repo_started(ref) ⇒ Object



26
# File 'lib/repo_tender/ui/json_reporter.rb', line 26

def repo_started(ref) = emit(event: "repo_started", ref: ref)

#run_finished(summary) ⇒ Object



30
# File 'lib/repo_tender/ui/json_reporter.rb', line 30

def run_finished(summary) = emit(event: "run_finished", summary: summary)

#run_started(total:) ⇒ Object



25
# File 'lib/repo_tender/ui/json_reporter.rb', line 25

def run_started(total:) = emit(event: "run_started", total: total)