class AutoCommit::Gatherer
Constants
- Delay
Public Class Methods
new(dir, committer)
click to toggle source
# File lib/autocommit/gatherer.rb, line 10 def initialize dir, committer @dir = dir @committer = committer @mutex = Mutex.new @list = [] Detector.new dir do |event| name = event.absolute_name puts "#{name} (#{event.flags})" unless /\.git/ =~ name trigger_commit event.absolute_name end end
Public Instance Methods
commit()
click to toggle source
# File lib/autocommit/gatherer.rb, line 42 def commit @mutex.synchronize { @list.clear # Prevent the next commit (>=0.25 seconds later, but still) # from interfering with this one: # commit from within the synchronized block @committer.commit } end
delayed_commit()
click to toggle source
# File lib/autocommit/gatherer.rb, line 37 def delayed_commit sleep Delay commit end
start_thread()
click to toggle source
# File lib/autocommit/gatherer.rb, line 31 def start_thread Thread.new { delayed_commit } end
trigger_commit(full_name)
click to toggle source
# File lib/autocommit/gatherer.rb, line 22 def trigger_commit full_name in_git_repo = full_name.start_with? File.join(@dir, ".git") return if in_git_repo @mutex.synchronize { start_thread if @list.empty? @list << Time.now } end