Class: Reissue::Runbook

Inherits:
Object
  • Object
show all
Defined in:
lib/reissue/runbook.rb

Overview

Maintains a post-release runbook file listing steps to perform after releasing a version. The file holds only the latest release.

Constant Summary collapse

ITEM_PATTERN =
/^- (?:\[(?<checked>[ xX])\] )?(?<text>.+)$/
DEFAULT_TITLE =
"Runbook"
DEFAULT_PREAMBLE =
"Steps to perform after releasing the version below."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runbook_file) ⇒ Runbook

Returns a new instance of Runbook.



12
13
14
# File 'lib/reissue/runbook.rb', line 12

def initialize(runbook_file)
  @runbook_file = runbook_file
end

Instance Attribute Details

#runbook_fileObject (readonly)

Returns the value of attribute runbook_file.



16
17
18
# File 'lib/reissue/runbook.rb', line 16

def runbook_file
  @runbook_file
end

Instance Method Details

#finalize(version:, date:, trailer_items: []) ⇒ Object

Stamps the header with the release version and date, merging directly edited items with trailer items (deduplicated by text). Preserves any custom title and preamble already in the file.



35
36
37
38
39
40
41
42
43
# File 'lib/reissue/runbook.rb', line 35

def finalize(version:, date:, trailer_items: [])
  title, preamble = parsed_header
  merged = parsed_items
  texts = merged.map { |item| item[:text] }
  trailer_items.each do |text|
    merged << {text: text, checked: false} unless texts.include?(text)
  end
  File.write(runbook_file, template(heading(version, date), merged, title:, preamble:))
end

#generate(version: "Unreleased") ⇒ Object Also known as: clear

Writes a header-only template for the given version, preserving any custom title and preamble already in the file.



20
21
22
23
# File 'lib/reissue/runbook.rb', line 20

def generate(version: "Unreleased")
  title, preamble = parsed_header
  File.write(runbook_file, template(heading(version), title:, preamble:))
end

#itemsObject

Returns the text of each checklist item, without checkbox markers.



28
29
30
# File 'lib/reissue/runbook.rb', line 28

def items
  parsed_items.map { |item| item[:text] }
end