Class: Hookers::Changelog::Changelogger
- Inherits:
-
Object
- Object
- Hookers::Changelog::Changelogger
- Defined in:
- lib/hookers/changelog/changelogger.rb
Instance Method Summary collapse
- #generate(options = {}) ⇒ Object
-
#initialize(project = Project.discover) ⇒ Changelogger
constructor
A new instance of Changelogger.
Constructor Details
#initialize(project = Project.discover) ⇒ Changelogger
Returns a new instance of Changelogger.
8 9 10 |
# File 'lib/hookers/changelog/changelogger.rb', line 8 def initialize(project = Project.discover) @project = project end |
Instance Method Details
#generate(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hookers/changelog/changelogger.rb', line 12 def generate( = {}) from = [:from] || History.first to = [:to] || "HEAD" lines = History.between(from, to) parser = Parser.new(@project) commits = lines.map { |e| parser.parse(e) }.flatten output = StringIO.new types = Hash[commits.group_by(&:type).map { |type, commits| [type, commits.group_by(&:identifier)] }] types.each_pair do |type, commits| output.puts "\n*** #{type}S ***" commits.each_pair do |identifier, commits| output.puts "\n * #{identifier}: - #{commits.first.uri}" commits.each do |affected| output.puts " - #{affected.commit.} - #{affected.commit.uri}" end end end output.rewind output.read end |