Class: Groundskeeper::Changelog
- Inherits:
-
Object
- Object
- Groundskeeper::Changelog
- Defined in:
- lib/groundskeeper/changelog.rb
Overview
The ‘CHANGELOG.md` file in an application.
Constant Summary collapse
- FILENAME =
"CHANGELOG.md"
- TITLE_EXPRESSION =
"# Changelog"
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(document:, date:) ⇒ Changelog
constructor
A new instance of Changelog.
-
#update_file(version, changes) ⇒ Object
rubocop:disable Performance/RedundantMatch,Performance/RegexpMatch.
Constructor Details
#initialize(document:, date:) ⇒ Changelog
Returns a new instance of Changelog.
20 21 22 23 |
# File 'lib/groundskeeper/changelog.rb', line 20 def initialize(document:, date:) @document = document @date = date end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
8 9 10 |
# File 'lib/groundskeeper/changelog.rb', line 8 def date @date end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
8 9 10 |
# File 'lib/groundskeeper/changelog.rb', line 8 def document @document end |
Class Method Details
.build(filename: FILENAME) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/groundskeeper/changelog.rb', line 13 def self.build(filename: FILENAME) new( document: Groundskeeper::Document.new(filename), date: Date.today.iso8601 ) end |
Instance Method Details
#update_file(version, changes) ⇒ Object
rubocop:disable Performance/RedundantMatch,Performance/RegexpMatch
26 27 28 29 30 31 32 33 |
# File 'lib/groundskeeper/changelog.rb', line 26 def update_file(version, changes) unless document.match(/(#{TITLE_EXPRESSION})/) document.prepend_file("#{TITLE_EXPRESSION}\n\n") end document .append_to_file(TITLE_EXPRESSION, version_template(version, changes)) end |