Sha256: ed467940c0fa3dc4d7ca4f7f88a293c7b1b807e0ae01d7a7182a1a8a8cd0fe29
Contents?: true
Size: 790 Bytes
Versions: 2
Compression:
Stored size: 790 Bytes
Contents
# frozen_string_literal: true require 'listen' module GitMQ class Consumer def initialize(storage:, name:, branch:) @storage = storage @branch = branch @name = name end def branch_file @branch_file ||= File.join(@storage.path, 'refs', 'heads') end def consume(&block) @block = block consume_commits listener.start end def stop listener.stop end private def listener @listener ||= Listen.to(branch_file, only: /#{Regexp.escape(@branch)}/) do 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitmq-0.1.3 | lib/consumer.rb |
gitmq-0.1.2 | lib/consumer.rb |