forked from mojombo/god
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added file_mtime(path, max_age) - checks file mtime so you can restart
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|