Class: CreateGithubRelease::Changelog
- Inherits:
-
Object
- Object
- CreateGithubRelease::Changelog
- Defined in:
- lib/create_github_release/changelog.rb
Overview
Generate a changelog for a new release
Given an existing changelog and a description of a new release, generate a new changelog that includes the new release.
Instance Attribute Summary collapse
-
#existing_changelog ⇒ String
readonly
The changelog before the new release is added.
-
#next_release_description ⇒ String
readonly
The description of the new release to add to the changelog.
Instance Method Summary collapse
-
#body ⇒ String
The body of the existing changelog.
-
#front_matter ⇒ String
The front matter of the changelog.
-
#initialize(existing_changelog, next_release_description) ⇒ Changelog
constructor
Create a new changelog object.
-
#to_s ⇒ String
The changelog with the new release.
Constructor Details
#initialize(existing_changelog, next_release_description) ⇒ Changelog
Create a new changelog object
55 56 57 58 59 60 |
# File 'lib/create_github_release/changelog.rb', line 55 def initialize(existing_changelog, next_release_description) @existing_changelog = existing_changelog @next_release_description = next_release_description @lines = existing_changelog.lines.map(&:chomp) end |
Instance Attribute Details
#existing_changelog ⇒ String (readonly)
The changelog before the new release is added
181 182 183 |
# File 'lib/create_github_release/changelog.rb', line 181 def existing_changelog @existing_changelog end |
#next_release_description ⇒ String (readonly)
The description of the new release to add to the changelog
190 191 192 |
# File 'lib/create_github_release/changelog.rb', line 190 def next_release_description @next_release_description end |
Instance Method Details
#body ⇒ String
The body of the existing changelog
168 169 170 171 172 |
# File 'lib/create_github_release/changelog.rb', line 168 def body return '' if body_start == body_end lines[body_start..body_end - 1].join("\n") end |
#front_matter ⇒ String
The front matter of the changelog
This is the part of the changelog up until the body. The body contains the list of releases and is the first line starting with '## '.
108 109 110 111 112 |
# File 'lib/create_github_release/changelog.rb', line 108 def front_matter return '' if front_matter_start == front_matter_end lines[front_matter_start..front_matter_end - 1].join("\n") end |
#to_s ⇒ String
The changelog with the new release
279 280 281 |
# File 'lib/create_github_release/changelog.rb', line 279 def to_s formatted_front_matter + next_release_description + formatted_body end |