diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/file_update_checker.rb | 14 |
2 files changed, 15 insertions, 5 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index d2e07d6762..df144dd00b 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,10 +1,10 @@ ## Rails 4.0.0 (unreleased) ## -* Time#change now works with time values with offsets other than UTC or the local time zone. *Andrew White* +* `Time#change` now works with time values with offsets other than UTC or the local time zone. *Andrew White* -* AS::Callbacks: deprecate usage of filter object with `#before` and `#after` methods as `around` callback. *Bogdan Gusiev* +* `ActiveSupport::Callbacks`: deprecate usage of filter object with `#before` and `#after` methods as `around` callback. *Bogdan Gusiev* -* Add `Time#prev_quarter' and 'Time#next_quarter' short-hands for months_ago(3) and months_since(3). *SungHee Kang* +* Add `Time#prev_quarter` and `Time#next_quarter` short-hands for `months_ago(3)` and `months_since(3)`. *SungHee Kang* * Remove obsolete and unused `require_association` method from dependencies. *fxn* diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb index 9decbaef32..1cc852a3e6 100644 --- a/activesupport/lib/active_support/file_update_checker.rb +++ b/activesupport/lib/active_support/file_update_checker.rb @@ -101,9 +101,19 @@ module ActiveSupport end def updated_at(paths) + @updated_at || max_mtime(paths) || Time.at(0) + end + + # This method returns the maximum mtime of the files in +paths+, or +nil+ + # if the array is empty. + # + # Files with a mtime in the future are ignored. Such abnormal situation + # can happen for example if the user changes the clock by hand. It is + # healthy to consider this edge case because with mtimes in the future + # reloading is not triggered. + def max_mtime(paths) time_now = Time.now - @updated_at || paths.map { |path| File.mtime(path) }. - reject { |time| time > time_now }.max || Time.at(0) + paths.map {|path| File.mtime(path)}.reject {|mtime| time_now < mtime}.max end def compile_glob(hash) |