Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Cleanup the rake and the generator bundles.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmexe committed Mar 6, 2009
1 parent 328dfe4 commit c26278c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 70 deletions.
68 changes: 24 additions & 44 deletions bundles/rails-generator-bundle.el
Expand Up @@ -89,68 +89,48 @@
(defun rails/generator-bundle/generate (&optional task)
"Run a Generator task."
(interactive)
(when-bind (root (rails/root))
(let (options)
(unless task
(setq task
(rails/completing-read "What generate"
(rails/generator-bundle/list-of-tasks root)
nil
(car rails/generator-bundle/history)
'rails/generator-bundle/history)))
(unless (string-ext/empty-p task)
(setq options (read-string (format "Name and/or options for [%s]: " task)))
(unless (string-ext/empty-p options)
(rails/generator-bundle/run root
"generate"
task
options
rails/generator-bundle/options))))))
(rails/with-root nil
(if task
(let (options)
(unless (string-ext/empty-p task)
(setq options (read-string (format "Name and/or options for [%s]: " task)))
(unless (string-ext/empty-p options)
(rails/generator-bundle/run (rails/root)
"generate"
task
options
rails/generator-bundle/options))))
(rails/anything/run-with-pattern "gen "))))

(defun rails/generator-bundle/destroy (&optional task)
"Run a Destroy task."
(interactive)
(when-bind (root (rails/root))
(let (options)
(unless task
(setq task
(rails/completing-read "What destroy"
(rails/generator-bundle/list-of-tasks root)
nil
(car rails/generator-bundle/history)
'rails/generator-bundle/history)))
(unless (string-ext/empty-p task)
(setq options (read-string (format "Name of [%s]: " task)))
(unless (string-ext/empty-p options)
(rails/generator-bundle/run root "destroy" task options))))))
(rails/with-root nil
(if task
(let (options)
(unless (string-ext/empty-p task)
(setq options (read-string (format "Name of [%s]: " task)))
(unless (string-ext/empty-p options)
(rails/generator-bundle/run (rails/root) "destroy" task options))))
(rails/anything/run-with-pattern "des "))))

(defun rails/generator-bundle/reset-cache ()
(interactive)
(when-bind (root (rails/root))
(rails/generator-bundle/create-cache root)))

(defun rails/generator-bundle/gen ()
(interactive)
(when-bind (root (rails/root))
(rails/anything/run-with-pattern "gen ")))

(defun rails/generator-bundle/des ()
(interactive)
(when-bind (root (rails/root))
(rails/anything/run-with-pattern "des ")))

;;; ---------------------------------------------------------
;;; - Bundle
;;;

(rails/defbundle "Generator"
(:menu
(([reset] (cons "Reset Cache" 'rails/generator-bundle/reset-cache))
([destroy] (cons "Destroy" 'rails/generator-bundle/des))
([create] (cons "Generate" 'rails/generator-bundle/gen)))
([destroy] (cons "Destroy" 'rails/generator-bundle/destroy))
([create] (cons "Generate" 'rails/generator-bundle/generate)))
:keys
(("e" 'rails/generator-bundle/gen)
("E" 'rails/generator-bundle/des))
(("e" 'rails/generator-bundle/generate)
("E" 'rails/generator-bundle/destroy))
:triggers
(("gen" "Generate"
(candidates
Expand Down
41 changes: 15 additions & 26 deletions bundles/rails-rake-bundle.el
Expand Up @@ -142,43 +142,32 @@
(defun rails/rake-bundle/run (&optional task)
"Run a Rake task."
(interactive)
(when-bind (root (rails/root))
(let ((task (if task
task
(rails/completing-read "What task run"
(rails/rake-bundle/list-of-tasks root)
nil
(car rails/rake-bundle/history)
'rails/rake-bundle/history))))
(when (not (string-ext/empty-p task))
(rails/rake-bundle/task-run root task)))))
(rails/with-root nil
(if task
(when (not (string-ext/empty-p task))
(rails/rake-bundle/task-run root task))
(rails/rake-bundle/list-tasks))))

(defun rails/rake-bundle/run-with-args (&optional task)
"Run a Rake task with arguments ARGS."
(interactive)
(when-bind (root (rails/root))
(let ((task (if task
task
(rails/completing-read "What task run"
(rails/rake-bundle/list-of-tasks root)
nil
(car rails/rake-bundle/history)
'rails/rake-bundle/history)))
args)
(when (not (string-ext/empty-p task))
(setq args (read-string (format "Arguments fo %s: " task)))
(rails/rake-bundle/task-run root task args)))))
(rails/with-root nil
(if task
(when (not (string-ext/empty-p task))
(let ((args (read-string (format "Arguments fo %s: " task))))
(rails/rake-bundle/task-run root task args)))
(rails/rake-bundle/list-tasks))))

(defun rails/rake-bundle/reset-cache ()
"Reset tasks cache."
(interactive)
(when-bind (root (rails/root))
(rails/rake-bundle/create-tasks-cache root)))
(rails/with-root nil
(rails/rake-bundle/create-tasks-cache (rails/root))))

(defun rails/rake-bundle/list-tasks ()
"List of availabled Rake tasks."
(interactive)
(when-bind (root (rails/root))
(rails/with-root nil
(rails/anything/run-with-pattern "rake ")))

;;; ---------------------------------------------------------
Expand All @@ -190,7 +179,7 @@
(([reset] (cons "Reset Tasks Cache" 'rails/rake-bundle/reset-cache))
([task] (cons "Run Rake Task" 'rails/rake-bundle/list-tasks)))
:keys
(("r" 'rails/rake-bundle/anything))
(("r" 'rails/rake-bundle/list-tasks))
:triggers
(("rake" "Rake Task"
(candidates
Expand Down

0 comments on commit c26278c

Please sign in to comment.