Created
December 2, 2009 09:31
-
-
Save authorNari/247085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; for spork | |
;; http://github.com/timcharper/spork | |
;; requirement gems: spork, spork-testunit | |
(defvar rinari-spork-executable "spork1.8" | |
"spork bin") | |
(defvar rinari-spork-test-executable "testdrb1.8" | |
"spork test bin") | |
(defun rinari-spork-root (&optional dir home) | |
(or dir (setq dir default-directory)) | |
(if (file-exists-p (expand-file-name | |
"test_helper.rb" (expand-file-name "test" dir))) | |
dir | |
(let ((new-dir (expand-file-name (file-name-as-directory "..") dir))) | |
;; regexp to match windows roots, tramp roots, or regular posix roots | |
(unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^\/]+:\\|^/$\\)" dir) | |
(rinari-root new-dir))))) | |
(defun rinari-spork (&optional edit-cmd-args) | |
"Run spork." | |
(interactive "P") | |
(let* ( | |
(default-directory (rinari-spork-root)) | |
) | |
(pop-to-buffer (ruby-compilation-do | |
rinari-spork-executable (cons rinari-spork-executable nil))) | |
) (rinari-launch)) | |
(defun rinari-spork-test (&optional edit-cmd-args) | |
"spork test." | |
(interactive "P") | |
(or (string-match "test" (or (ruby-add-log-current-method) | |
(file-name-nondirectory (buffer-file-name)))) | |
(rinari-find-test)) | |
(let* ((funname (ruby-add-log-current-method)) | |
(fn (and funname | |
(string-match "#\\(.*\\)" funname) | |
(match-string 1 funname))) | |
(path (buffer-file-name)) | |
(default-command (if fn | |
(concat path " --name /" fn "/") | |
path)) | |
(command (if edit-cmd-args | |
(read-string "Run w/Compilation: " default-command) | |
default-command)) | |
(name (file-name-nondirectory (car (split-string command)))) | |
(cmdlist (cons rinari-spork-test-executable | |
(split-string (expand-file-name command))))) | |
(if path (pop-to-buffer | |
(ruby-compilation-do (concat rinari-spork-test-executable ":" name) cmdlist)) | |
(message "no test available")))) | |
(provide 'rinari-extend-spork) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment