Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rails-core.el (rails-core:model-file): search namespaced models.

rails-test.el (rails-test:line-regexp): applled patch by Alan Shields,
  don't hightlight whitespaces in test output.
rails-test.el: appled patch by Alan Shields,
  can't run rails-test-current-* without a file.
rails.el (rails-templates-list): added 'html.erb'.


git-svn-id: svn+ssh://rubyforge.org/var/svn/emacs-rails/trunk@217 cc5033d0-740f-0410-afc7-949910e492f2
  • Loading branch information...
commit c5ba131cf993026a690355cb5fe97ed4469caf63 1 parent 61c3e81
dimaexe authored
Showing with 77 additions and 22 deletions.
  1. +16 −4 ChangeLog
  2. +1 −1  History
  3. +23 −3 rails-core.el
  4. +37 −13 rails-test.el
  5. +0 −1  rails.el
View
20 ChangeLog
@@ -1,10 +1,21 @@
-2007-11-02 Dmitry Galinsky <dima.exe@gmail.com>
+2007-11-03 Dmitry Galinsky <dima.exe@gmail.com>
+
+ * rails-core.el (rails-core:model-file): search namespaced models.
+
+ * rails-test.el (rails-test:line-regexp): applled patch by Alan Shields,
+ don't hightlight whitespaces in test output.
+
+ * rails-test.el: appled patch by Alan Shields,
+ can't run rails-test-current-* without a file.
- * rails.el (rails-templates-list): added 'html.erb'
+2007-11-02 Dmitry Galinsky <dima.exe@gmail.com>
+
+ * rails.el (rails-templates-list): added 'html.erb'.
* rails-snippets-feature.el (rails-snippets-feature:rest): replace *_url to *_path
+
* inflections.el (singularize-string pluralize-string): downcase
- string befored searched
+ string befored searched.
2007-10-12 Dmitry Galinsky <dima.exe@gmail.com>
@@ -12,7 +23,8 @@
input string before find in irregular
2007-09-11 Peter Rezikov <crazypit13@gmail.com>
- * rails.el: basic support of Markaby templates.
+
+ * rails.el: basic support of Markaby templates.
2007-08-18 Peter Rezikov <crazypit13@gmail.com>
* rails-spec.el: base support for rspec. Function
View
2  History
@@ -1,4 +1,4 @@
-SVN
+0.5.99.6
* Removed file 'untabify-file.el' from package emacs-rails
* Updated highlight of compilation output
* Added ruby-mode support in hs-minor-mode (aka folding).
View
26 rails-core.el
@@ -99,15 +99,31 @@ will not append \".rb\" to result."
it does not exist, ask to create it using QUESTION as a prompt."
(find-or-ask-to-create question (rails-core:file file)))
+(defun rails-core:strip-namespace (class-name)
+ "Strip namespace of CLASS-NAME, eg Foo::Bar -> Bar."
+ (let ((name-list (split-string class-name "::")))
+ (car (last name-list))))
+
;; Funtions, that retrun Rails objects full pathes
(defun rails-core:model-file (model-name)
"Return the model file from the model name."
(when model-name
- (concat "app/models/" (rails-core:file-by-class model-name))))
+ (let* ((stripped-model-file
+ (rails-core:file-by-class
+ (rails-core:strip-namespace model-name)))
+ (model-file
+ (rails-core:file-by-class model-name)))
+ (cond
+ ((file-exists-p
+ (rails-core:file (concat "app/models/" model-file)))
+ (concat "app/models/" model-file))
+ ((file-exists-p
+ (rails-core:file (concat "app/models/" stripped-model-file)))
+ (concat "app/models/" stripped-model-file))))))
(defun rails-core:model-exist-p (model-name)
- "Return t if controller CONTROLLER-NAME exist."
+ "Return t if model MODEL-NAME exist."
(when model-name
(and (file-exists-p
(rails-core:file
@@ -135,7 +151,11 @@ it does not exist, ask to create it using QUESTION as a prompt."
(when model
(let* ((controller (pluralize-string model))
(controller (when controller (capitalize controller))))
- (when (rails-core:controller-exist-p controller)
+ (setq controller
+ (cond
+ ((rails-core:controller-exist-p controller) controller) ;; pluralized
+ ((rails-core:controller-exist-p model) model))) ;; singularized
+ (when controller
(rails-core:controller-file controller)))))
(defun rails-core:observer-file (observer-name)
View
50 rails-test.el
@@ -51,7 +51,7 @@
(defun rails-test:line-regexp (&optional append prepend)
(concat
append
- "^\\(?:\s+\\)\\[?\\([^ \f\n\r\t\v]*?\\):\\([0-9]+\\)\\(?::in\s*`\\(.*?\\)'\\)?"
+ "\\[?\\([^ \f\n\r\t\v]*?\\):\\([0-9]+\\)\\(?::in\s*`\\(.*?\\)'\\)?"
prepend))
(defun rails-test:error-regexp-alist ()
@@ -62,6 +62,7 @@
(rails-test:line-regexp nil "\\(?:\]:\\|\n$\\)") 1 2 nil 2))) ; ending of "]:" or next line is blank
(defun rails-test:print-result ()
+ "Determine if the output buffer needs to be shown"
(with-current-buffer (get-buffer rails-script:buffer-name)
(let ((msg (list))
(failures 0)
@@ -108,14 +109,30 @@
rails-test-trace))
(add-hook 'after-change-functions 'rails-test:print-progress nil t)
(add-hook 'rails-script:run-after-stop-hook 'rails-test:print-result nil t)
- (add-hook 'rails-script:show-buffer-hook
- #'(lambda()
- (let ((win (get-buffer-window (current-buffer))))
- (when (window-live-p win)
- (set-window-point win 0)
- (unless (buffer-visible-p (current-buffer))
- (compilation-set-window-height win)))))
- t t))
+ (add-hook 'rails-script:run-after-stop-hook 'rails-test:hide-rails-project-root t t)
+ (add-hook 'rails-script:show-buffer-hook 'rails-test:reset-point-and-height t t))
+
+(defun rails-test:hide-rails-project-root ()
+ "Show files that are relative to the project root as relative filenames
+As the buffer is read-only this is merely a change in appearance"
+ (rails-project:with-root (root)
+ (save-excursion
+ (beginning-of-buffer)
+ (let ((file-regex (concat (regexp-quote root) "[^:]+")))
+ (while (re-search-forward file-regex nil t)
+ (let* ((orig-filename (match-string 0))
+ (rel-filename (file-relative-name orig-filename root)))
+ (overlay-put (make-overlay (match-beginning 0) (match-end 0))
+ 'display rel-filename)))))))
+
+(defun rails-test:reset-point-and-height ()
+ "Resets the point and resizes the window for the output buffer.
+Used when it's determined that the output buffer needs to be shown."
+ (let ((win (get-buffer-window (current-buffer))))
+ (when (window-live-p win)
+ (set-window-point win 0)
+ (unless (buffer-visible-p (current-buffer))
+ (compilation-set-window-height win)))))
(defun rails-test:list-of-tasks ()
"Return a list contains test tasks."
@@ -142,7 +159,10 @@
(defun rails-test:run-single-file (file &optional param)
"Run test for single file FILE."
- (let ((param (if param (append (list file) (list param))
+ (when (not (or file param))
+ "Refuse to run ruby without an argument: it would never return")
+ (let ((param (if param
+ (list file param)
(list file))))
(rails-script:run "ruby" param 'rails-test:compilation-mode)))
@@ -161,9 +181,13 @@
;; controller
((and controller (not (rails-core:mailer-p controller)) func-test)
func-test)
- ;; mailer
- ((and controller (rails-core:mailer-p controller) unit-test)
- unit-test)))))
+ ;; mailer
+ ((and controller (rails-core:mailer-p controller) unit-test)
+ unit-test)
+ ;; otherwise...
+ (t (if (string-match "test.*\\.rb" (buffer-file-name))
+ (buffer-file-name)
+ (error "Cannot determine whiche test file to run.")))))))
(defun rails-test:run-current-method ()
"Run a test for the current method."
View
1  rails.el
@@ -44,7 +44,6 @@
(require 'etags)
(require 'find-recursive)
-(require 'untabify-file)
(require 'predictive-prog-mode)
(require 'inflections)
Please sign in to comment.
Something went wrong with that request. Please try again.