The rake tasks are currently cached in tmp/.tasks-cache. However, if a new rake task is added to lib/tasks it is not
picked up in emacs-rails until you go in and delete the .tasks-cache file. The following patch checks to see if any
of the .rake files in the lib/tasks directory are newer than the .tasks-cache, and if so then it recreates the
.tasks-cache.
Index: rails-rake.el
===================================================================
--- rails-rake.el (revision 195)
+++ rails-rake.el (working copy)
@@ -45,10 +45,27 @@
"Return all available tasks and create tasks cache file."
(rails-project:in-root
(let* ((cache-file (rails-core:file "tmp/.tasks-cache")))
- (if (file-exists-p cache-file)
+ (if (and (file-exists-p cache-file)
+ (not (rails-rake:cache-stale)))
(read-from-file cache-file)
(rails-rake:create-tasks-cache cache-file)))))
+
+(defun rails-rake:cache-stale()
+ "Checks locations of files that might effect the cache, return t if cache is stale"
+ (rails-project:in-root
+ (let* ((cache-file (rails-core:file "tmp/.tasks-cache"))
+ (result nil))
+ (dolist (file-to-test
+ (find-recursive-files "\\.rake$" (rails-core:file "lib/tasks/"))
+ result)
+ (if (file-newer-than-file-p
+ (rails-core:file (concat "lib/tasks/" file-to-test)) cache-file)
+ (setq result 't))
+ ))))
+
+
+
(defun rails-rake:list-of-tasks-without-tests ()
"Return available tasks without test actions."
(when-bind
|