class HostileGit::Hostility
Attributes
git[RW]
initial_time[RW]
timeout[RW]
Public Class Methods
new(timer = 10)
click to toggle source
# File lib/HostileGit.rb, line 11 def initialize(timer = 10) self.timeout = timer self.initial_time = Time.now.to_i self.git = Git.init end
Public Instance Methods
check_and_reset()
click to toggle source
# File lib/HostileGit.rb, line 25 def check_and_reset reset! unless commited? end
commited?()
click to toggle source
# File lib/HostileGit.rb, line 17 def commited? self.git.log.since("#{self.timeout} minutes ago").count > 0 end
initial_timeout()
click to toggle source
# File lib/HostileGit.rb, line 29 def initial_timeout (self.initial_time - Time.now.to_i) < (timeout * -3600) end
reset!()
click to toggle source
# File lib/HostileGit.rb, line 21 def reset! self.git.reset_hard("HEAD") end
start_being_hostile()
click to toggle source
# File lib/HostileGit.rb, line 33 def start_being_hostile listener = Listen.to(Dir.pwd) do |modified, added, removed| check_and_reset if initial_timeout end listener.start # not blocking sleep end