public
Description: Rinari Is Not A Rails IDE
Homepage: http://rinari.rubyforge.org
Clone URL: git://github.com/technomancy/rinari.git
cleaner, smaller, and more useful...

refactoring:
- removed rails-script.el (pieces used in ruby-compilation.el)
- renamed from rails-* to rinari-*

additions:
- ruby-compilation.el provides support for running any ruby process
  dumping the output to a compilation buffer
- toggle.el now can toggle between specific methods as well as between
  specific files, see the 'rinari toggle style in rinari.el
eschulte (author)
Tue Jun 24 15:37:47 -0700 2008
commit  9c51fe7699fdea4b57318ec47acc635abe5e8d88
tree    81c4c5e3a294dcfad5900b710d309d0860ae2cc1
parent  b12e8dbbeeeb9e213da4316e00c1b511f44980af
0
...
1
2
3
4
 
5
6
7
...
9
10
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
16
...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
69
70
71
72
73
74
75
76
77
78
79
 
 
 
 
 
80
81
 
82
83
84
 
85
86
87
...
96
97
98
99
 
100
101
102
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
 
 
210
211
212
...
1
2
3
 
4
5
6
7
...
9
10
11
 
 
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
133
134
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
137
 
 
 
 
 
 
 
 
 
 
138
139
140
141
142
143
 
144
145
 
 
146
147
148
149
...
158
159
160
 
161
162
163
164
...
230
231
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
234
235
236
237
0
@@ -1,7 +1,7 @@
0
 # -*- mode: org -*-
0
 #
0
 #+TITLE: TODO
0
-#+SEQ_TODO: TODO MAYBE WAITING | PARTIAL DONE
0
+#+SEQ_TODO: TODO PARTIAL MAYBE WAITING | DONE CANCELLED
0
 #+DRAWERS: SNIP
0
 
0
 =TODO
0
@@ -9,8 +9,89 @@ List of pending/completed tasks for rinari
0
 
0
 for background see http://groups.google.com/group/emacs-on-rails
0
 
0
-* DONE launch web-browser to current view
0
- add a quick command to view the current page in a web-browser
0
+* TODO inf-ruby enhancement
0
+
0
+found an example of an error that the
0
+`inferior-ruby-error-regexp-alist' in inf-ruby.el doesn't match
0
+
0
+this was the error line
0
+
0
+:SNIP:
0
+SyntaxError: /home/eschulte/united/org/work/arf/arf/lib/cluster.rb:35: syntax error, unexpec
0
+:END:
0
+
0
+* TODO errors / tests
0
+something to speed up the cycle of
0
+
0
+- code
0
+- test
0
+- review errors
0
+
0
+this should probably cash out into two different functions...
0
+
0
+** PARTIAL rails-test-method
0
+
0
+*** DONE enhance toggle so that it can match up function names as well
0
+
0
+*** TODO defadvice toggle so it can run tests
0
+
0
+just need to figure out how to add a prefix argument when using
0
+defadvice ([[file:rinari.el::TODO%20need%20to%20figure%20out%20how%20to%20defadvice%20with%20a%20prefix%20a][defadvice in rinari.el]])
0
+
0
+
0
+*** CANCELLED use the same mechanism as find view
0
+maybe instead of using the current buffer-file change
0
+[[file:rinari.el::defun%20rails%20name%20components%20name][rails-name-components-name]] so it returns the last component as well,
0
+then change the controller usage of this function to drop the last
0
+list element. That way this can be used to get model names when
0
+calling which-function from models/model.rb files.
0
+
0
+Also, if you don't have a test written for this particular method this
0
+could insert the def...end for the test into the appropriate file, and
0
+drop the point there. Nothing wrong with a little bit of soft
0
+paternalism.
0
+
0
+* TODO make rails-find-view follow forms and link_to[_remote]
0
+
0
+working on this currently...
0
+
0
+* TODO make `rails-find-action' work with rails2-style view filenames
0
+
0
+* TODO define macro for ido completion
0
+since we often want to check the availability of ido for completing
0
+reads it would probably be worth writing a macro to do this.
0
+
0
+also, it may be worthwhile breaking utility functions out into a
0
+separate file...
0
+* MAYBE add a function for running mysql
0
+this would use the information in /conf/databases.yaml to log into the
0
+application's database using sql-* functions from sql.el as
0
+appropriate
0
+
0
+* PARTIAL make `rails-find-action' which will follow forms (maybe w/prefix?)
0
+
0
+works for the following cases
0
+- default (goes to the view with the name of the action)
0
+- follows redirect_to another controller and action
0
+- follows renders
0
+- follows redirects to partials
0
+- render_partial
0
+- multiple renders (for example from separate clauses in an if
0
+ statement)
0
+
0
+can follow multiple redirects
0
+
0
+** DONE enhancement
0
+sometimes an action will have multiple redirect statements, in which
0
+case this function should ask the user (with completion) which one to
0
+follow
0
+
0
+** TODO better error if run outside of controller
0
+** TODO cleanup
0
+
0
+this is current the largest set of functions in rinari.el (it should
0
+be cleaner / less code)
0
+
0
 * PARTIAL Make rinari a minor mode that doesn't activate for regular ruby-mode.
0
   :PROPERTIES:
0
   :assignee: eschulte
0
@@ -52,36 +133,17 @@ something similar to \C-c\C-c in org-mode
0
 something to indicate functions and keybindings, like \C-hm for major
0
 modes
0
 
0
-* TODO errors / tests
0
-something to speed up the cycle of
0
-
0
-- code
0
-- test
0
-- review errors
0
-
0
-this should probably cash out into two different functions...
0
-
0
-** rails-test-method
0
-
0
-use `which-function' and the current buffer-file to find the current
0
-function, then lookup and run the test related to that function
0
-dumping the output into a compile buffer
0
+* DONE remove rails-script add ruby-compilation
0
 
0
-maybe instead of using the current buffer-file change
0
-[[file:rinari.el::defun%20rails%20name%20components%20name][rails-name-components-name]] so it returns the last component as well,
0
-then change the controller usage of this function to drop the last
0
-list element. That way this can be used to get model names when
0
-calling which-function from models/model.rb files.
0
-
0
-Also, if you don't have a test written for this particular method this
0
-could insert the def...end for the test into the appropriate file, and
0
-drop the point there. Nothing wrong with a little bit of soft
0
-paternalism.
0
+it turns out most of the bulk of rails-script.el was supporting
0
+running ruby processes with output going to compilation buffers. So
0
+rails-script.el is now removed (with two short functions in rinari.el
0
+[[file:rinari.el::defun%20rinari%20console%20optional%20arg][rinari-console]] and [[file:rinari.el::defun%20rinari%20server][rinari-server]]), also ruby-compilation has been
0
+added.
0
 
0
-** rails-recent error
0
+** PARTIAL move through compilation buffers
0
 
0
-Going to re-define some keys in the *server* and *test* compilation
0
-buffers to make it easier to navigate.
0
+redefine some keys buffers to make it easier to navigate.
0
 
0
 n will go to the next line
0
 p will go to the previous line
0
@@ -96,7 +158,7 @@ so if you just saw an error on a web page, you can see that error in
0
 three key commands
0
 
0
 1) X-b *server*
0
-2) M-p
0
+p2) M-p
0
 3) enter
0
 
0
 *** old
0
@@ -168,45 +230,8 @@ http://www.emacswiki.org/cgi-bin/wiki/CompilationMode
0
 Yeah, the second one sounds a lot harder.
0
 :END:
0
 
0
-* TODO make rails-find-view follow forms and link_to[_remote]
0
-
0
-working on this currently...
0
-
0
-* TODO quick wrapper for find file to include *server*, *console*, etc...
0
-include all of the rails process buffers if they exist
0
-
0
-* TODO define macro for ido completion
0
-since we often want to check the availability of ido for completing
0
-reads it would probably be worth writing a macro to do this.
0
-
0
-also, it may be worthwhile breaking utility functions out into a
0
-separate file...
0
-
0
-* PARTIAL make `rails-find-action' which will follow forms (maybe w/prefix?)
0
-
0
-works for the following cases
0
-- default (goes to the view with the name of the action)
0
-- follows redirect_to another controller and action
0
-- follows renders
0
-- follows redirects to partials
0
-- render_partial
0
-- multiple renders (for example from separate clauses in an if
0
- statement)
0
-
0
-can follow multiple redirects
0
-
0
-** DONE enhancement
0
-sometimes an action will have multiple redirect statements, in which
0
-case this function should ask the user (with completion) which one to
0
-follow
0
-
0
-** TODO better error if run outside of controller
0
-
0
-* WAITING make `rails-find-action' work with rails2-style view filenames
0
-* MAYBE add a function for running mysql
0
-this would use the information in /conf/databases.yaml to log into the
0
-application's database using sql-* functions from sql.el as
0
-appropriate
0
+* DONE launch web-browser to current view
0
+ add a quick command to view the current page in a web-browser
0
 
0
 * DONE unified runner for rails scripts
0
 
...
143
144
145
 
 
 
 
 
 
146
147
148
...
143
144
145
146
147
148
149
150
151
152
153
154
0
@@ -143,6 +143,12 @@
0
 (defvar inferior-ruby-mode-map nil
0
   "*Mode map for inferior-ruby-mode")
0
 
0
+;; TODO:
0
+;; doesn't match this example
0
+;;
0
+;; SyntaxError: /home/eschulte/united/org/work/arf/arf/lib/cluster.rb:35: syntax error, unexpected '~', expecting kEND
0
+;; similarity = comparison_cache[m][n] ||= clusters[m] ~ clusters[n]
0
+;;
0
 (defconst inferior-ruby-error-regexp-alist
0
        '(("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2)
0
    ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
...
57
58
59
 
60
61
62
63
64
65
66
67
...
81
82
83
84
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
87
88
89
90
91
92
93
94
95
96
97
 
98
99
100
101
102
103
104
 
105
106
107
...
247
248
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
251
252
...
262
263
264
 
265
266
267
268
269
 
 
 
 
 
 
 
 
 
 
 
 
 
270
271
272
...
57
58
59
60
61
62
63
64
 
65
66
67
...
81
82
83
 
 
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 
 
 
 
 
 
 
 
 
 
 
99
100
101
102
103
104
105
 
106
107
108
109
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
...
280
281
282
283
284
285
286
287
 
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
0
@@ -57,11 +57,11 @@
0
 (require 'which-func)
0
 (require 'ruby-mode)
0
 (require 'inf-ruby)
0
+(require 'ruby-compilation)
0
 (require 'toggle)
0
 
0
 (require 'find-file-in-project)
0
 (require 'pcmpl-rake)
0
-(require 'rinari-script)
0
 
0
 ;;;###autoload
0
 (defun rinari-rake (&optional arg)
0
@@ -81,27 +81,29 @@
0
     (unless (equal dir "/")
0
       (rinari-root (expand-file-name (concat dir "../"))))))
0
 
0
-(defun rinari-test ()
0
- "test the current method"
0
+(defun rinari-console (&optional arg)
0
+ "Run script/console. Use a prefix argument to edit command line options."
0
+ (interactive "P")
0
+ (let* ((script (concat (rinari-root) "script/console"))
0
+ (command (if arg
0
+ (read-string "Run Ruby: " (concat script " "))
0
+ script)))
0
+ (run-ruby command)
0
+ (save-excursion (pop-to-buffer "*ruby*")
0
+ (set (make-local-variable 'inferior-ruby-first-prompt-pattern) "^>> ")
0
+ (set (make-local-variable 'inferior-ruby-prompt-pattern) "^>> "))))
0
+
0
+(defun rinari-server ()
0
+ "Run script/server."
0
   (interactive)
0
- (let* ((funname (which-function))
0
- (method (and (string-match "#\\(.*\\)" funname) (match-string 1 funname)))
0
- ;; rinari-name-components strips _controller from the end
0
- (class (rinari-make-dirname (rinari-name-components funname))))
0
- (cond
0
- ((string-match "controller" class)
0
- (message "controller")
0
- (find-file (format "%s/test/functional/%s_test.rb" (rinari-root) class))
0
- (goto-char (point-min))
0
- (search-forward (format "def %s" method))
0
- ))))
0
+ (ruby-run-w/compilation (concat (rinari-root) "/script/server")))
0
 
0
 (defun rinari-find-view ()
0
   "View toggling for rails"
0
   (interactive)
0
   (let* ((funname (which-function))
0
    (function (and (string-match "#\\(.*\\)" funname) (match-string 1 funname)))
0
- (controller (rinari-make-dirname (rails-name-components funname)))
0
+ (controller (rinari-make-dirname (rinari-name-components funname)))
0
    (path (rinari-path-to-view controller function))
0
     (appdir (concat (rinari-root) "/app/")))
0
     (find-file (concat appdir "views/" path ".rhtml"))))
0
@@ -247,6 +249,22 @@ editing of the url."
0
   (let ((ffip-project-root (rinari-root)))
0
     ad-do-it))
0
 
0
+;; ;; TODO: need to figure out how to defadvice with a prefix a
0
+;; ;; function which doesn't normally have a prefix
0
+;; (defadvice toggle-buffer (around toggle-buffer-and-run-test first activate)
0
+;; "Wrap `toggle-buffer' so that if it is called with a prefix
0
+;; argument, and the toggle ends on a testing method, then we run
0
+;; the related test, dumping the results into a compilation
0
+;; buffer"
0
+;; (interactive "P")
0
+;; ad-do-it
0
+;; (if (ad-get-arg 0)
0
+;; (let* ((line (thing-at-point 'line))
0
+;; (test (and (string-match "def \\(.+\\)" line)
0
+;; (match-string 1 line))))
0
+;; (if (string-match "test" test)
0
+;; (ruby-run-w/compilation (concat (buffer-file-name) " -n " test))))))
0
+
0
 ;;--------------------------------------------------------------------
0
 ;;
0
 ;; minor mode and keymaps
0
@@ -262,11 +280,24 @@ editing of the url."
0
 (define-key rinari-minor-mode-map "\C-c'v" 'rinari-find-view)
0
 (define-key rinari-minor-mode-map "\C-c'a" 'rinari-find-action)
0
 (define-key rinari-minor-mode-map "\C-c'b" 'rinari-browse-view)
0
+(define-key rinari-minor-mode-map "\C-c'e" 'rinari-insert-erb-skeleton)
0
 (define-key rinari-minor-mode-map "\C-c't" 'toggle-buffer)
0
 
0
 (defun rinari-launch ()
0
   "Run `rinari-minor-mode' if inside of a rails projcect"
0
- (interactive) (if (rinari-root) (rinari-minor-mode t)))
0
+ (interactive)
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
+ (if (rinari-root) (rinari-minor-mode t)))
0
 
0
 (add-hook 'ruby-mode-hook
0
    (lambda () (rinari-launch)))
...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
 
 
 
 
 
 
 
 
 
 
 
 
79
80
81
...
99
100
101
102
 
103
104
 
105
106
107
...
123
124
125
126
127
128
 
 
 
129
130
131
132
133
134
135
 
 
 
 
 
 
 
 
136
137
 
 
 
 
 
 
 
 
138
139
140
...
63
64
65
 
 
 
 
 
 
 
 
 
 
 
 
 
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
99
100
101
 
102
103
 
104
105
106
107
...
123
124
125
 
 
 
126
127
128
129
130
131
132
133
134
 
135
136
137
138
139
140
141
142
143
 
144
145
146
147
148
149
150
151
152
153
154
0
@@ -63,19 +63,19 @@
0
 (require 'cl)
0
 
0
 (defcustom toggle-mapping-styles
0
- '((zentest . (("app/controllers/\\1.rb" . "test/controllers/\\1_test.rb")
0
- ("app/views/\\1.rb" . "test/views/\\1_test.rb")
0
- ("app/models/\\1.rb" . "test/unit/\\1_test.rb")
0
- ("lib/\\1.rb" . "test/unit/test_\\1.rb")))
0
- (rspec . (("app/models/\\1.rb" . "spec/models.\\1_spec.rb")
0
- ("app/controllers/\\1.rb" . "spec/controllers/\\1_spec.rb")
0
- ("app/views/\\1.rb" . "spec/views/\\1_spec.rb")
0
- ("app/helpers/\\1.rb" . "spec/helpers/\\1_spec.rb")))
0
- (rails . (("app/controllers/\\1.rb" . "test/functional/\\1_test.rb")
0
- ("app/models/\\1.rb" . "test/unit/\\1_test.rb")
0
- ("lib/\\1.rb" . "test/unit/test_\\1.rb")))
0
- (ruby . (("lib/\\1.rb" . "test/test_\\1.rb")
0
- ("\\1.rb" . "test_\\1.rb"))))
0
+ '((zentest . (("app/controllers/\\1.rb" . "test/controllers/\\1_test.rb")
0
+ ("app/views/\\1.rb" . "test/views/\\1_test.rb")
0
+ ("app/models/\\1.rb" . "test/unit/\\1_test.rb")
0
+ ("lib/\\1.rb" . "test/unit/test_\\1.rb")))
0
+ (rspec . (("app/models/\\1.rb" . "spec/models.\\1_spec.rb")
0
+ ("app/controllers/\\1.rb" . "spec/controllers/\\1_spec.rb")
0
+ ("app/views/\\1.rb" . "spec/views/\\1_spec.rb")
0
+ ("app/helpers/\\1.rb" . "spec/helpers/\\1_spec.rb")))
0
+ (rails . (("app/controllers/\\1.rb" . "test/functional/\\1_test.rb")
0
+ ("app/models/\\1.rb" . "test/unit/\\1_test.rb")
0
+ ("lib/\\1.rb" . "test/unit/test_\\1.rb")))
0
+ (ruby . (("lib/\\1.rb" . "test/test_\\1.rb")
0
+ ("\\1.rb" . "test_\\1.rb"))))
0
   "A list of (name . toggle-mapping) rules used by toggle-filename."
0
   :group 'toggle
0
   :type '(repeat (cons string string)))
0
@@ -99,9 +99,9 @@
0
                (mapcar (lambda (pair)
0
                          (cons
0
                           (replace-regexp-in-string
0
- "\\\\1" "\\\\(.*\\\\)"
0
+ "\\\\[[:digit:]]" "\\\\(.*\\\\)"
0
                            (replace-regexp-in-string ; special case for "\\1.ext"
0
- "^\\\\1" "\\\\([^/]*\\\\)" (car pair)))
0
+ "^\\\\[[:digit:]]" "\\\\([^/]*\\\\)" (car pair)))
0
                           (cdr pair)))
0
                        (mapcan 'list
0
                                pairs
0
@@ -123,18 +123,32 @@ expression RE matches PATH, then replace-match is invoked with
0
 TRANS. After the first successful match, this returns. If no rule
0
 matches, it returns nil"
0
   (cond ((null rules) nil)
0
- ((string-match (caar rules) path)
0
- (replace-match (cdar rules) nil nil path))
0
- (t (toggle-filename path (rest rules)))))
0
+ ((string-match (caar rules) path)
0
+ (replace-match (cdar rules) nil nil path))
0
+ (t (toggle-filename path (rest rules)))))
0
 
0
 (defun toggle-buffer ()
0
   "Opens a related file to the current buffer using matching rules.
0
 Matches the current buffer against rules in toggle-mappings. If a
0
 match is found, switches to that buffer."
0
   (interactive)
0
- (let ((new-name (toggle-filename (buffer-file-name) toggle-mappings)))
0
+ (let* ((function (which-function))
0
+ (func-add (if function
0
+ (concat "#" (and (string-match "#\\(.+\\)" (which-function))
0
+ (match-string 1 (which-function))))
0
+ ""))
0
+ (new-name (or (toggle-filename (concat (buffer-file-name) func-add)
0
+ toggle-mappings)
0
+ (toggle-filename (buffer-file-name) toggle-mappings))))
0
     (if new-name
0
- (find-file new-name)
0
+ (if (string-match "\\(.+\\)#\\(.+\\)" new-name)
0
+ (let ((path (match-string 1 new-name))
0
+ (method (match-string 2 new-name)))
0
+ (find-file path)
0
+ (goto-char (point-min))
0
+ (unless (search-forward (concat "def " method) nil t)
0
+ (message "%s not defined in %s" method (file-name-nondirectory path))))
0
+ (find-file new-name))
0
       (message (concat "Match not found for " (buffer-file-name))))))
0
 
0
 (provide 'toggle)

Comments

    No one has commented yet.