Class: Agentilda::Reporter
- Inherits:
-
Object
- Object
- Agentilda::Reporter
- Defined in:
- lib/agentilda/reporter.rb
Overview
/spec-status — every plan, its state in icon and words, and its pull
requests as clickable links.
#render returns a string and prints nothing. Whoever calls it decides where it goes, which keeps the table pipeable.
Constant Summary collapse
- HEADINGS =
Columns, so the header and the rows cannot drift apart.
["Plan", "⬇", "Status", "Feature", "Pull Requests"].freeze
- ORDINAL_WIDTH =
Cells given to the plan number: "018.01" with room to grow.
7- EMOJI_WIDTH =
Cells given to a status icon. Emoji vary in both character count and display width, so the cell is padded to this by UI.fit rather than trusted to be any particular size — see the note there.
2- STATE_WIDTH =
Cells given to a pull request's state, so the URLs line up beneath each other whichever states the tree happens to contain.
PullRequests::STATES.map { |_, label| UI.display_width(label) }.max
Instance Attribute Summary collapse
- #tree ⇒ Agentilda::Tree readonly
Instance Method Summary collapse
-
#inconsistent ⇒ Array<Agentilda::Subject>
Plans whose folder name their contents do not justify.
-
#initialize(tree:) ⇒ Reporter
constructor
A new instance of Reporter.
-
#render ⇒ String
The whole table, newline-terminated.
-
#totals ⇒ Hash{Symbol => Integer}
How many plans sit in each state.
Constructor Details
#initialize(tree:) ⇒ Reporter
Returns a new instance of Reporter.
26 27 28 |
# File 'lib/agentilda/reporter.rb', line 26 def initialize(tree:) @tree = tree end |
Instance Attribute Details
#tree ⇒ Agentilda::Tree (readonly)
31 32 33 |
# File 'lib/agentilda/reporter.rb', line 31 def tree @tree end |
Instance Method Details
#inconsistent ⇒ Array<Agentilda::Subject>
Plans whose folder name their contents do not justify.
48 |
# File 'lib/agentilda/reporter.rb', line 48 def inconsistent = tree.subjects.reject(&:consistent?) |
#render ⇒ String
Returns the whole table, newline-terminated.
34 35 36 37 38 |
# File 'lib/agentilda/reporter.rb', line 34 def render return "No plans found in #{tree.dir}\n" if tree.subjects.empty? [header, *tree.subjects.flat_map { |s| rows_for(s) }, "", ].join("\n") + "\n" end |
#totals ⇒ Hash{Symbol => Integer}
Returns how many plans sit in each state.
41 42 43 |
# File 'lib/agentilda/reporter.rb', line 41 def totals tree.subjects.each_with_object(Hash.new(0)) { |s, h| h[s.status.key] += 1 } end |