Class: History
- Inherits:
-
Object
- Object
- History
- Defined in:
- lib/ratatui_ruby/devtools/tasks/bump/history.rb
Overview
Manages the versioned history section of a changelog.
Changelogs contain past version entries below the Unreleased section. During a release, new version entries prepend to this history. Manipulating it manually risks corruption.
This class extracts history from the changelog. It prepends new version entries. It serializes back to markdown.
Use it during release preparation.
Class Method Summary collapse
-
.parse(content, header_length, unreleased_length, links_text) ⇒ Object
Parses the history section from changelog content.
Instance Method Summary collapse
-
#add(section) ⇒ Object
Adds a new versioned section to the beginning of history.
-
#initialize(content) ⇒ History
constructor
Creates a new History.
-
#to_s ⇒ Object
Returns the history as a string.
Constructor Details
#initialize(content) ⇒ History
Creates a new History.
- content
-
The raw history text.
34 35 36 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/history.rb', line 34 def initialize(content) @content = content.dup end |
Class Method Details
.parse(content, header_length, unreleased_length, links_text) ⇒ Object
Parses the history section from changelog content.
- content
-
The full changelog text.
- header_length
-
Length of the header section.
- unreleased_length
-
Length of the Unreleased section.
- links_text
-
The links section text (used as end marker).
25 26 27 28 29 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/history.rb', line 25 def self.parse(content, header_length, unreleased_length, links_text) start = header_length + unreleased_length text = "#{content[start...(content.index(links_text))].strip}\n" new(text) end |
Instance Method Details
#add(section) ⇒ Object
Adds a new versioned section to the beginning of history.
- section
-
The version section text to prepend.
41 42 43 44 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/history.rb', line 41 def add(section) @content = "#{"#{section}\n\n#{@content}".strip}\n" nil end |
#to_s ⇒ Object
Returns the history as a string.
47 48 49 |
# File 'lib/ratatui_ruby/devtools/tasks/bump/history.rb', line 47 def to_s @content end |