Class: Changelog
- Inherits:
-
Object
- Object
- Changelog
- Defined in:
- lib/changelog.rb
Overview
Central class that puts together the changelog.
Constant Summary collapse
nil
Instance Attribute Summary collapse
-
#recent_changes_heading ⇒ Object
writeonly
Heading for the most recent changes.
Instance Method Summary collapse
-
#generate(exclude_recent = false) ⇒ String
Generates a decorated changelog for the entire commit history.
-
#generate_recent ⇒ Array
Generates a simple, undecorated list of changelog entries since the most recent tag.
-
#initialize ⇒ Changelog
constructor
A new instance of Changelog.
Constructor Details
#initialize ⇒ Changelog
Returns a new instance of Changelog.
24 25 26 |
# File 'lib/changelog.rb', line 24 def initialize @recent_changes_heading = "Unpublished changes" end |
Instance Attribute Details
#recent_changes_heading=(value) ⇒ Object (writeonly)
Heading for the most recent changes.
22 23 24 |
# File 'lib/changelog.rb', line 22 def recent_changes_heading=(value) @recent_changes_heading = value end |
Instance Method Details
#generate(exclude_recent = false) ⇒ String
Generates a decorated changelog for the entire commit history.
39 40 41 42 43 44 45 46 47 |
# File 'lib/changelog.rb', line 39 def generate(exclude_recent = false) # Traverse tags @@tags = TagList.new(!exclude_recent) output = String.new @@tags.list.each_cons(2) do |current_tag, previous_tag| output << generate_for(current_tag, previous_tag) end output.length > 0 ? output : nil end |
#generate_recent ⇒ Array
Generates a simple, undecorated list of changelog entries since the most recent tag.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/changelog.rb', line 55 def generate_recent @@tags = TagList.new log = CommitChangelog.new(@@tags.list[0], @@tags.list[1]) # Explicitly add initial commit if there is no tag yet # This is necessary because HEAD..OTHER_COMMIT does not include # OTHER_COMMIT's message, which is the desired behavior if # OTHER_COMMIT is a tag for a previous version, but undesired # if OTHER_COMMIT is the initial commit of the repository. log.add_commit @@tags.list[1] if @@tags.list.length == 2 log.changelog end |