Class: Commenter::Parser::OsdXlsxParser

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

Overview

Parser for ISO Online Standards Development (OSD) XLSX exports.

Supports two variants, detected from the header row:

- "resolved": single "Comments (N)" sheet with resolution data
(columns: Comment ID, User name, Clause nb, ..., Resolution status,
Motivation, Resolution Date, Stage code)
- "unresolved": multi-sheet format with "Comments (N)",
"Unresolved comments (N)", "Resolved comments (N)" sheets
(columns: User name, Clause nb, ..., Comment type, Comment/Motivation,
Comment on text, Proposal on Text, Proposed change, Replies,
Resolution status, Justification, Resolution Date, Date, Comment number)

Both variants share the same header structure in the first rows:

Row 0: [Date, Reference, nil, "", Title EN, nil, nil, Title FR, ...]
Row 1: ["2026-04-21", "ISO/DIS 5843-6(en)", ...]
Row 2: empty
Row 3: column headers
Row 4+: data

Constant Summary collapse

RESOLVED_COLUMN_KEYS =

Header names are mapped per variant onto common attribute keys so both variants share a single comment builder. Headers are mapped by real column position, tolerating gaps in the header row.

{
  "Comment ID" => :id,
  "User name" => :user_name,
  "Clause nb" => :clause,
  "Clause Title" => :clause_title,
  "Subtype" => :comment_type,
  "Comment" => :comment_text,
  "Proposal on Text" => :proposal_on_text,
  "Proposed change" => :proposed_change,
  "Feedbacks" => :feedbacks,
  "Created Date" => :created_date,
  "Resolution status" => :resolution_status,
  "Motivation" => :motivation,
  "Resolution Date" => :resolution_date,
  "Stage code" => :stage_code
}.freeze
UNRESOLVED_COLUMN_KEYS =
{
  "User name" => :user_name,
  "Clause nb" => :clause,
  "Clause Title" => :clause_title,
  "Comment type" => :comment_type,
  "Comment/Motivation" => :comment_text,
  "Proposal on Text" => :proposal_on_text,
  "Proposed change" => :proposed_change,
  "Replies" => :feedbacks,
  "Resolution status" => :resolution_status,
  "Justification" => :motivation,
  "Resolution Date" => :resolution_date,
  "Date" => :created_date,
  "Comment number" => :id
}.freeze

Instance Method Summary collapse

Instance Method Details

#parse(xlsx_path, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/commenter/parser/osd_xlsx_parser.rb', line 64

def parse(xlsx_path, options = {})
  xlsx = Roo::Spreadsheet.open(xlsx_path)

  sheet_name = select_sheet(xlsx, options)
  sheet = xlsx.sheet(sheet_name)
  header_row_num = find_header_row(sheet)
  variant = detect_variant(sheet.row(header_row_num))

  comments = parse_comments(sheet, header_row_num, variant, options)
  CommentSheet.new(version: "osd", **(xlsx, sheet_name), comments: comments)
end