Class: Header

Inherits:
Object
  • Object
show all
Defined in:
lib/ratatui_ruby/devtools/tasks/bump/header.rb

Overview

Manages the header section of a changelog.

Changelogs start with a header: title, description, format reference. During updates, this section stays unchanged. Extracting it ensures safe rewrites.

This class parses the header from changelog markdown. It preserves it during modifications.

Constant Summary collapse

PATTERN =

Regex to match everything before the Unreleased section.

/^(.*?)(?=## \[Unreleased\])/m

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Header

Creates a new Header.

content

The raw header text.



30
31
32
# File 'lib/ratatui_ruby/devtools/tasks/bump/header.rb', line 30

def initialize(content)
  @content = content.dup
end

Class Method Details

.parse(content) ⇒ Object

Parses the header from changelog content.

content

The full changelog text.



22
23
24
25
# File 'lib/ratatui_ruby/devtools/tasks/bump/header.rb', line 22

def self.parse(content)
  match = content.match(PATTERN)
  new(match[1]) if match
end

Instance Method Details

#lengthObject

Returns the byte length of the header.



35
36
37
# File 'lib/ratatui_ruby/devtools/tasks/bump/header.rb', line 35

def length
  @content.length
end

#to_sObject

Returns the header as a string.



40
41
42
# File 'lib/ratatui_ruby/devtools/tasks/bump/header.rb', line 40

def to_s
  @content
end