Patches: Browse | Submit New | Admin

[#11648] Checking rake tasks cache to see if new rake tasks are added

Date:
2007-06-18 07:01
Priority:
3
Submitted By:
Rob Christie (rwc9u)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Checking rake tasks cache to see if new rake tasks are added

Detailed description
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

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
rails-rake.patch rails-rake patch for tasks-cache staleness checking Download

Changes:

Field Old Value Date By
File Added2125: rails-rake.patch2007-06-18 07:01rwc9u