Class: Omnibus::ChangeLog
- Inherits:
-
Object
- Object
- Omnibus::ChangeLog
- Defined in:
- lib/omnibus/changelog.rb
Constant Summary collapse
- CHANGELOG_TAG =
"ChangeLog-Entry".freeze
Instance Attribute Summary collapse
-
#end_ref ⇒ Object
readonly
Returns the value of attribute end_ref.
Instance Method Summary collapse
- #authors ⇒ Object
- #changelog_entries ⇒ Object
-
#initialize(start_ref = nil, end_ref = "HEAD", git_repo = GitRepository.new("./")) ⇒ ChangeLog
constructor
A new instance of ChangeLog.
- #start_ref ⇒ Object
Constructor Details
#initialize(start_ref = nil, end_ref = "HEAD", git_repo = GitRepository.new("./")) ⇒ ChangeLog
Returns a new instance of ChangeLog.
8 9 10 11 12 |
# File 'lib/omnibus/changelog.rb', line 8 def initialize(start_ref = nil, end_ref = "HEAD", git_repo = GitRepository.new("./")) @start_ref = start_ref @end_ref = end_ref @git_repo = git_repo end |
Instance Attribute Details
#end_ref ⇒ Object (readonly)
Returns the value of attribute end_ref.
7 8 9 |
# File 'lib/omnibus/changelog.rb', line 7 def end_ref @end_ref end |
Instance Method Details
#authors ⇒ Object
14 15 16 |
# File 'lib/omnibus/changelog.rb', line 14 def git_repo.(start_ref, end_ref) end |
#changelog_entries ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/omnibus/changelog.rb', line 18 def changelog_entries entries = [] current_entry = [] git_repo.(start_ref, end_ref).each do |l| if blank?(l) entries << current_entry current_entry = [] elsif tagged?(l) entries << current_entry current_entry = Array(l.sub(/^#{CHANGELOG_TAG}:[\s]*/, "")) elsif !current_entry.empty? current_entry << l end end entries << current_entry entries.reject(&:empty?).map(&:join) end |
#start_ref ⇒ Object
36 37 38 |
# File 'lib/omnibus/changelog.rb', line 36 def start_ref @start_ref ||= git_repo.latest_tag end |