public
Description: Rinari Is Not A Rails IDE
Homepage: http://rinari.rubyforge.org
Clone URL: git://github.com/technomancy/rinari.git
Add `rinari-minor-mode-hook' for customization. Make some variables 
buffer-local.
technomancy (author)
Mon Aug 18 08:54:37 -0700 2008
commit  b02f6c60c15444693c29354afe4bbc4748d51b7e
tree    1bf61ad7774fad30e84a7aabff2c13a9ca402524
parent  55f3b9fc737fb4d5380df3a656e5a366b017c84b
...
47
48
49
50
 
...
47
48
49
 
50
0
@@ -47,4 +47,4 @@ namespace "doc" do
0
 
0
 end
0
 
0
-task :default => :test
0
+task :default => :'test:emacs'
...
62
63
64
 
 
 
65
66
67
...
264
265
266
267
 
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
290
291
...
62
63
64
65
66
67
68
69
70
...
267
268
269
 
270
271
272
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
0
@@ -62,6 +62,9 @@
0
   "TAGS"
0
   "Path to your TAGS file inside of your rails project. See `tags-file-name'.")
0
 
0
+(defvar rinari-minor-mode-hook nil
0
+ "*Hook for customising Rinari.")
0
+
0
 (defadvice find-file-in-project (around find-file-in-rinari-project activate)
0
   "Wrap `find-file-in-project' to use `rinari-root' as the base of
0
   the project."
0
@@ -264,28 +267,31 @@ With optional prefix argument just run `rgrep'."
0
   rinari-minor-mode-keybindings)
0
 
0
 (defun rinari-launch ()
0
- "Run `rinari-minor-mode' if inside of a rails projcect,
0
+ "Run `rinari-minor-mode' if inside of a rails projecct,
0
 otherwise turn `rinari-minor-mode' off if it is on."
0
   (interactive)
0
   (let* ((root (rinari-root)) (r-tags-path (concat root rinari-tags-file-name)))
0
- (if root
0
- (progn
0
- ;; customize toggle.el for rinari
0
- (add-to-list
0
- 'toggle-mapping-styles
0
- '(rinari . (("app/controllers/\\1.rb#\\2" . "test/functional/\\1_test.rb#test_\\2")
0
- ("app/controllers/\\1.rb" . "test/functional/\\1_test.rb")
0
- ("app/models/\\1.rb#\\2" . "test/unit/\\1_test.rb#test_\\2")
0
- ("app/models/\\1.rb" . "test/unit/\\1_test.rb")
0
- ("lib/\\1.rb#\\2" . "test/unit/test_\\1.rb#test_\\2")
0
- ("lib/\\1.rb" . "test/unit/test_\\1.rb"))))
0
- (setq toggle-mapping-style 'rinari)
0
- (setq toggle-mappings (toggle-style toggle-mapping-style))
0
- (setq toggle-which-function-command 'ruby-add-log-current-method)
0
- (setq toggle-method-format "def %s")
0
- (if (file-exists-p r-tags-path) (setq tags-file-name r-tags-path))
0
- (unless rinari-minor-mode (rinari-minor-mode t)))
0
- (if rinari-minor-mode (rinari-minor-mode)))))
0
+ (when root
0
+ ;; customize toggle.el for rinari
0
+ (add-to-list
0
+ 'toggle-mapping-styles
0
+ '(rinari . (("app/controllers/\\1.rb#\\2" . "test/functional/\\1_test.rb#test_\\2")
0
+ ("app/controllers/\\1.rb" . "test/functional/\\1_test.rb")
0
+ ("app/models/\\1.rb#\\2" . "test/unit/\\1_test.rb#test_\\2")
0
+ ("app/models/\\1.rb" . "test/unit/\\1_test.rb")
0
+ ("lib/\\1.rb#\\2" . "test/unit/test_\\1.rb#test_\\2")
0
+ ("lib/\\1.rb" . "test/unit/test_\\1.rb"))))
0
+ (set (make-local-variable 'toggle-mapping-style) 'rinari)
0
+ (set (make-local-variable 'toggle-which-function-command)
0
+ 'ruby-add-log-current-method)
0
+ (set (make-local-variable 'toggle-mappings)
0
+ (toggle-style toggle-mapping-style))
0
+ (set (make-local-variable 'toggle-method-format) "def %s")
0
+ (set (make-local-variable 'tags-file-name)
0
+ (and (file-exists-p r-tags-path) r-tags-path))
0
+ (run-hooks 'rinari-minor-mode-hook)
0
+ ;; TODO: Why is there mode-toggling logic here? define-minor-mode handles that for us.
0
+ (unless rinari-minor-mode (rinari-minor-mode t)))))
0
 
0
 (defvar rinari-major-modes
0
   '('ruby-mode-hook 'yaml-mode-hook 'mumamo-after-change-major-mode-hook 'css-mode-hook
...
51
52
53
54
 
55
56
57
...
97
98
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
101
...
51
52
53
 
54
55
56
57
...
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
0
@@ -51,7 +51,7 @@
0
    (new-controller (concat default-directory "app/controllers/newone_controller.rb"))
0
    (new-model (concat default-directory "app/models/newone.rb")))
0
     (find-file new-controller)
0
- (rinari-find-model) ;; answer yes to the prompt
0
+ (rinari-find-model) ;; answer yes to the prompt ;; TODO: find a way to mock out the prompt
0
     (kill-buffer (file-name-nondirectory new-model))
0
     (kill-buffer (file-name-nondirectory new-controller))
0
     (assert-that (file-exists-p new-model))
0
@@ -97,5 +97,20 @@
0
       (kill-buffer "units_controller_test.rb")
0
       (kill-buffer "units_controller.rb"))))
0
 
0
+;; TODO: for some reason this doesn't work inside the test body
0
+(add-hook 'rinari-minor-mode-hook '(lambda () (setq hooks-ran t)))
0
+
0
+(deftest rinari-hooks rinari-suite
0
+ (save-excursion
0
+ (unwind-protect ;; like ruby's ensure
0
+ (progn
0
+ (let ((default-directory (format "%s" (concat (file-name-directory
0
+ (or load-file-name buffer-file-name))
0
+ "rails-app/"))))
0
+ (find-file "app/controllers/units_controller.rb")
0
+ (assert-that hooks-ran)))
0
+ (kill-buffer "units_controller.rb")
0
+ (setq hooks-ran nil))))
0
+
0
 ;; (elunit-run-suite (elunit-get-suite 'rinari-movement-suite))
0
 (elunit "rinari-suite")

Comments

    No one has commented yet.