Class: HunkReviewChanges::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/hunk_review_changes/export.rb

Overview

Builds export.md: the pieces that need action, as a paste-ready markdown block the launching agent reads to implement each requested change.

Instance Method Summary collapse

Constructor Details

#initialize(bundle, state) ⇒ Export

Returns a new instance of Export.



7
8
9
10
# File 'lib/hunk_review_changes/export.rb', line 7

def initialize(bundle, state)
  @bundle = bundle
  @state = state
end

Instance Method Details

#to_markdownObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hunk_review_changes/export.rb', line 12

def to_markdown
  lines = header
  actionable = @bundle.pieces.select { |piece| State.actionable?(@state[piece["id"]]) }

  if actionable.empty?
    lines << no_changes_note
    return "#{lines.join("\n").strip}\n"
  end

  lines << "The pieces below have comments to act on. Implement each `change`; " \
           "list each `flag` for the user to decide before touching it."
  lines << ""
  actionable.each { |piece| lines.concat(piece_lines(piece)) }
  "#{lines.join("\n").strip}\n"
end