Sha256: 10ce6d8292b041b7c4b1e129934b28a7d46ea3e96049fc34d5eb4d69ef1b6e49
Contents?: true
Size: 725 Bytes
Versions: 1
Compression:
Stored size: 725 Bytes
Contents
# frozen_string_literal: true require 'listen' module GitMQueue 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 listener.start end def stop listener.stop end 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 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gitmqueue-0.1.1 | lib/consumer.rb |