Class: Freshness
- Inherits:
-
AbstractCheck
- Object
- AbstractCheck
- Freshness
- Defined in:
- lib/standard_checks.rb
Overview
Ensures that a file is not too old.
Constant Summary collapse
- SECONDS_IN_HOUR =
60 * 60
- HOUR_HASH =
{'default' => 24, /^hour/i => 1, /^day/i => 24, /^week/i => 7*24, /^month/i => 30*24, /^year/i => 365*24}
Instance Attribute Summary
Attributes inherited from AbstractCheck
Instance Method Summary collapse
Methods inherited from AbstractCheck
#add_error, check_name, children, get_check_name, inherited, #initialize, #run_check, #unit_parse
Constructor Details
This class inherits a constructor from AbstractCheck
Instance Method Details
#check(path_obj, options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/standard_checks.rb', line 13 def check(path_obj,) hours = unit_parse(,HOUR_HASH) old_time = Time.now - (hours * SECONDS_IN_HOUR) tomorrow = Time.now + (24 * SECONDS_IN_HOUR) unless path_obj.any_sub_node?{|f| f.mtime < tomorrow && f.mtime > old_time} #unless path_obj.any_sub_node?{|f| f.mtime > old_time} add_error('file is too old') end end |