Class: ChangesSince::ChangelogPrinter
- Inherits:
-
Object
- Object
- ChangesSince::ChangelogPrinter
- Defined in:
- lib/changes_since/changelog_printer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#teams ⇒ Object
readonly
Returns the value of attribute teams.
Instance Method Summary collapse
-
#initialize(commits, teams, options) ⇒ ChangelogPrinter
constructor
A new instance of ChangelogPrinter.
- #print! ⇒ Object
- #print_commits!(output_commits) ⇒ Object
- #print_message(commit, type, options) ⇒ Object
- #print_team_commits! ⇒ Object
Constructor Details
#initialize(commits, teams, options) ⇒ ChangelogPrinter
Returns a new instance of ChangelogPrinter.
4 5 6 7 8 |
# File 'lib/changes_since/changelog_printer.rb', line 4 def initialize(commits, teams, ) @commits = commits @teams = teams = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/changes_since/changelog_printer.rb', line 2 def end |
#teams ⇒ Object (readonly)
Returns the value of attribute teams.
2 3 4 |
# File 'lib/changes_since/changelog_printer.rb', line 2 def teams @teams end |
Instance Method Details
#print! ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/changes_since/changelog_printer.rb', line 10 def print! if teams print_team_commits! else print_commits!(@commits) end return end |
#print_commits!(output_commits) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/changes_since/changelog_printer.rb', line 38 def print_commits!(output_commits) output_commits.sort! { |a, b| a..name <=> b..name } { public: 'Public', bug: 'Bugs', internal: 'Internal' }.each do |type, title| tagged_commits = output_commits.select { |commit| commit..include?("##{type}") } next if tagged_commits.empty? puts "\n#{title}:\n\n" tagged_commits.each { |commit| (commit, type, ) } output_commits -= tagged_commits end puts "\nUnclassified:\n\n" output_commits.each { |commit| (commit, nil, ) } end |
#print_message(commit, type, options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/changes_since/changelog_printer.rb', line 57 def (commit, type, ) = commit..split("\n\n") if .first =~ /Merge pull request/ title = .last else title = .first end title.gsub!("##{type}", "") if type = commit..name puts "* #{title} (#{branch_author}) #{options[:sha] ? commit.sha[0..9] : ''}" end |
#print_team_commits! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/changes_since/changelog_printer.rb', line 19 def print_team_commits! teams.each do |team, members| = /#{members.join("|")}/i team_commits = @commits.select do |commit| [commit..name, commit..email].any? do |str| str =~ end end next if team_commits.empty? @commits -= team_commits puts "\n*#{team}*\n" print_commits!(team_commits) end return if @commits.empty? puts "\n*Other*\n\n" @commits.each { |commit| (commit, nil, ) } end |