Module: Aireview::ContextBudget
- Defined in:
- lib/aireview/context_budget.rb
Overview
Fits the review context into a character budget and remembers what was left out. The MR and Jira sections are cut to their limits keeping the beginning, the diff by whole files, then by whole hunks; a hunk is never cut inside.
Defined Under Namespace
Classes: Coverage, Packed, Packer
Constant Summary collapse
- NOT_SHOWN_LIST_LIMIT =
The paths that did not fit are listed at the end of the diff; the list is capped so that it does not eat the budget itself.
20- TRAILER_RESERVE_CHARS =
400
Class Method Summary collapse
- .pack_entries(entries, budget:, coverage:) ⇒ Object
-
.truncate_section(text, limit:, label:, coverage:) ⇒ Object
The beginning matters more than the end: requirements and acceptance criteria usually live there.
Class Method Details
.pack_entries(entries, budget:, coverage:) ⇒ Object
40 41 42 |
# File 'lib/aireview/context_budget.rb', line 40 def self.pack_entries(entries, budget:, coverage:) Packer.new(entries, budget: budget, coverage: coverage).pack end |
.truncate_section(text, limit:, label:, coverage:) ⇒ Object
The beginning matters more than the end: requirements and acceptance criteria usually live there.
32 33 34 35 36 37 38 |
# File 'lib/aireview/context_budget.rb', line 32 def self.truncate_section(text, limit:, label:, coverage:) text = text.to_s return text if text.length <= limit coverage.truncated_sections << label "#{text[0, limit]}\n[#{label} truncated: #{limit} of #{text.length} chars shown]" end |