Skip to content

Commit

Permalink
added file_mtime(path, max_age) - checks file mtime so you can restart
Browse files Browse the repository at this point in the history
if a file hasn't been modified for a certain length of time
  • Loading branch information
Jonathan Wilkins committed Oct 4, 2008
1 parent 5acd419 commit 856d321
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/god/conditions/file_mtime.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module God
module Conditions

class FileMtime < PollCondition
attr_accessor :path, :max_age

def initialize
super
self.path = nil
self.max_age = nil
end

def valid?
valid = true
valid &= complain("Attribute 'path' must be specified", self) if self.path.nil?
valid &= complain("Attribute 'max_age' must be specified", self) if self.max_age.nil?
valid
end

def test
(Time.now - File.mtime(self.path)) > self.max_age
end
end

end
end


0 comments on commit 856d321

Please sign in to comment.