Class: Onair::Report
- Inherits:
-
Data
- Object
- Data
- Onair::Report
- Defined in:
- lib/onair/report.rb
Overview
What renderers consume. Pure domain logic — all IO goes through the injected git wrapper; render output must be derivable from this alone.
delta: :current, Integer (commits behind), or nil (diverged/unknown — silence over speculation). pinned: a newer build succeeded but is not what's running. mine: the local user's commit just below someone else's deployed head. commits: sha => CommitInfo (or nil when absent locally) for every sha a renderer may need to describe.
Instance Attribute Summary collapse
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#mine ⇒ Object
readonly
Returns the value of attribute mine.
-
#pinned ⇒ Object
readonly
Returns the value of attribute pinned.
-
#remote_head ⇒ Object
readonly
Returns the value of attribute remote_head.
-
#snapshot ⇒ Object
readonly
Returns the value of attribute snapshot.
Class Method Summary collapse
Instance Attribute Details
#commits ⇒ Object (readonly)
Returns the value of attribute commits
13 14 15 |
# File 'lib/onair/report.rb', line 13 def commits @commits end |
#delta ⇒ Object (readonly)
Returns the value of attribute delta
13 14 15 |
# File 'lib/onair/report.rb', line 13 def delta @delta end |
#mine ⇒ Object (readonly)
Returns the value of attribute mine
13 14 15 |
# File 'lib/onair/report.rb', line 13 def mine @mine end |
#pinned ⇒ Object (readonly)
Returns the value of attribute pinned
13 14 15 |
# File 'lib/onair/report.rb', line 13 def pinned @pinned end |
#remote_head ⇒ Object (readonly)
Returns the value of attribute remote_head
13 14 15 |
# File 'lib/onair/report.rb', line 13 def remote_head @remote_head end |
#snapshot ⇒ Object (readonly)
Returns the value of attribute snapshot
13 14 15 |
# File 'lib/onair/report.rb', line 13 def snapshot @snapshot end |
Class Method Details
.build(snapshot:, remote_head:, git:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/onair/report.rb', line 14 def self.build(snapshot:, remote_head:, git:) # Pinned is judged before the stale pending is dropped: during the # stale window the newest *succeeded* build is still the previous # deploy, which must not read as a rollback. pinned = pinned?(snapshot) snapshot = drop_stale_pending(snapshot) deployed_sha = snapshot.deployed&.sha mine = compute_mine(snapshot, git) commits = [deployed_sha, snapshot.pending&.sha, mine&.sha].compact.uniq .to_h { |sha| [sha, git.commit_info(sha)] } new( snapshot: snapshot, remote_head: remote_head, delta: compute_delta(deployed_sha, remote_head, git), pinned: pinned, mine: mine, commits: commits ) end |