lib/consumer.rb in gitmqueue-0.1.1 vs lib/consumer.rb in gitmqueue-0.1.2

- old
+ new

@@ -14,10 +14,11 @@ @branch_file ||= File.join(@storage.path, 'refs', 'heads') end def consume(&block) @block = block + consume_commits listener.start end def stop listener.stop @@ -25,14 +26,18 @@ private def listener @listener ||= Listen.to(branch_file, only: /#{Regexp.escape(@branch)}/) do - commits = @storage.commits(@branch, @name) - commits.each do |commit| - @block.call commit.message - @storage.tag(@name, commit) - end + consume_commits + end + end + + def consume_commits + commits = @storage.commits(@branch, @name) + commits.each do |commit| + @block.call commit.message + @storage.tag(@name, commit) end end end end