Class: Commenter::Ballot

Inherits:
Object
  • Object
show all
Defined in:
lib/commenter/ballot.rb

Overview

Merges member-body comment sheets into a single ballot sheet — the collation step secretariats otherwise do by hand (ISO's own Comment Collation Tool fails on non-conforming files).

Policy: sheet metadata is first-non-nil across the given sheets (the output version comes from the first sheet); comments keep their input order. Identical duplicate IDs are deduplicated silently; the same ID with differing content raises.

Instance Method Summary collapse

Constructor Details

#initialize(sheets) ⇒ Ballot

Returns a new instance of Ballot.



13
14
15
# File 'lib/commenter/ballot.rb', line 13

def initialize(sheets)
  @sheets = sheets
end

Instance Method Details

#mergeObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/commenter/ballot.rb', line 17

def merge
  CommentSheet.new(
    version: first_sheet&.version || "2012-03",
    date: first_value(:date),
    document: first_value(:document),
    project: first_value(:project),
    stage: first_value(:stage),
    title_en: first_value(:title_en),
    title_fr: first_value(:title_fr),
    comments: deduplicate(@sheets.flat_map(&:comments))
  )
end