Module: Space::Core::CLI::LoopStatus

Defined in:
lib/space_core/cli/loop_status.rb

Overview

Compact Architect-Loop status block, derived from a space's own project block in space.yaml — so this carries NO dependency on space_architect. It is shared by the architect --help embed and the space status report. Returns plain lines (callers colourise) and never raises on malformed data.

Class Method Summary collapse

Class Method Details

.current_iteration(project) ⇒ Object



21
22
23
24
25
26
# File 'lib/space_core/cli/loop_status.rb', line 21

def current_iteration(project)
  name = project["current_iteration"]
  return nil unless name

  Array(project["iterations"]).find { |s| s["name"] == name }
end

.lines(project) ⇒ Object

Lines for the compact block, or nil when there is no project block.



12
13
14
15
16
17
18
19
# File 'lib/space_core/cli/loop_status.rb', line 12

def lines(project)
  return nil unless project.is_a?(Hash) && !project.empty?

  rows = ["Project status:  #{project["status"] || "(none)"}"]
  iter = current_iteration(project)
  rows << "Iteration:       #{ordinal(iter)} #{iter["name"]}#{state_of(iter)}" if iter
  rows
end

.ordinal(iter) ⇒ Object



28
29
30
# File 'lib/space_core/cli/loop_status.rb', line 28

def ordinal(iter)
  iter["ordinal"] ? format("I%02d", iter["ordinal"]) : "I--"
end

.state_of(iter) ⇒ Object

Derived loop state for the current iteration. Mirrors the precedence in architect status: a decided verdict wins, then an integrated lane (awaiting-verdict), then dispatched lanes, then a bare freeze, else spec.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/space_core/cli/loop_status.rb', line 35

def state_of(iter)
  verdict = iter["verdict"]
  return verdict if verdict && verdict != "pending"

  lanes = Array(iter["lanes"])
  return "awaiting-verdict" if lanes.any? { |l| l["integration_branch"] }
  return "dispatched" if lanes.any?
  return "frozen #{iter["freeze_sha"][0, 8]}" if iter["freeze_sha"]

  "speccing"
end