Permalink
Browse files

Added a new file touched condition

  • Loading branch information...
1 parent 59cd9ed commit 42b28678eec1d2ca168675f6f3201c01fed6269f @cyrilpic committed Feb 7, 2012
Showing with 24 additions and 0 deletions.
  1. +1 −0 lib/god.rb
  2. +23 −0 lib/god/conditions/file_touched.rb
View
@@ -47,6 +47,7 @@
require 'god/conditions/disk_usage'
require 'god/conditions/complex'
require 'god/conditions/file_mtime'
+require 'god/conditions/file_touched'
require 'god/conditions/socket_responding'
require 'god/socket'
@@ -0,0 +1,23 @@
+module God
+ module Conditions
+ class FileTouched < PollCondition
+ attr_accessor :path
+
+ 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
+ end
+
+ def test
+ (Time.now - File.mtime(self.path)) <= self.interval
+ end
+ end
+ end
+end

0 comments on commit 42b2867

Please sign in to comment.