public
Description: Rinari Is Not A Rails IDE
Homepage: http://rinari.rubyforge.org
Clone URL: git://github.com/technomancy/rinari.git
Big Changes... (cleaner/smaller/hackable code and 
new/reliable/customizable movement functions)

- moved all support files into util/ directory
- replaced external tools toggle.el, find-file-in-project.el, and
  project-local-variables.el with jump.el see
  http://github.com/eschulte/jump.el/tree/master
- removed rinari-movement.el, and added rinari jump configuration to
  rinari.el (all rinari-specific code is now located in rianri.el)
- closer to working on windows (no dependency on unix find command)
eschulte (author)
Sat Aug 23 12:11:33 -0700 2008
commit  d5da5fa2c4f1ae15281d345e035f43db89863ecd
tree    f8f16374bdc96b5e4d4e467ffa14ac9b1cfb86ef
parent  b8c24576b8346154a17241e5554d8437ccf22cda
0
...
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
...
95
96
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
99
100
...
27
28
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
31
32
...
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
0
@@ -27,46 +27,6 @@ see http://github.com/eschulte/yasnippets-rails/tree/master
0
   - [ ] sql
0
   - [ ] script
0
 
0
-* PARTIAL rinari movement [0/1]
0
-
0
-From anywhere, get to the related model/controller/test/view
0
-
0
-where can you be?
0
-- view
0
-- controller
0
-- model
0
-- unit-test
0
-- functional-test
0
-- other
0
-
0
-pending...
0
-- [X] still need to work on movement from OTHER places
0
-- [X] look at a better keybinding setup
0
-- [X] rails2 style view names
0
-- [ ] code refactor:
0
-
0
-** code refactor
0
-
0
-actually I'm thinking that when I have time it would be worthwhile to
0
-remove toggle, and handle all of the movement through a new
0
-independent toggle-like tool say "toggle-hassle" which uses an alist
0
-like toggle, but instead of elements like
0
-
0
-("app/controllers/\\1.rb#\\2" . "test/functional/\\1_test.rb#test_\\2")
0
-
0
-it has elements like
0
-
0
-("app/controllers/\\1_controller.rb#\\2"
0
- (
0
- (:model . "app/models/\\1.rb#\\2")
0
- (:test . "app/test/functional/\\1_controller_test.rb#\\2")
0
- (:view . "app/views/\\1/\\2.rhtml")
0
- )
0
-)
0
-
0
-basically like toggle but more of a hassle to set up, and with
0
-enough functionality to subsume rinari-movement.el
0
-
0
 * MAYBE inf-ruby enhancement
0
 
0
 found an example of an error that the
0
@@ -95,6 +55,33 @@ and another
0
 
0
 ugh
0
 
0
+* DONE rinari movement [4/4]
0
+
0
+From anywhere, get to the related model/controller/test/view
0
+
0
+where can you be?
0
+- view
0
+- controller
0
+- model
0
+- unit-test
0
+- functional-test
0
+- other
0
+
0
+pending...
0
+- [X] still need to work on movement from OTHER places
0
+- [X] look at a better keybinding setup
0
+- [X] rails2 style view names
0
+- [X] code refactor:
0
+
0
+** code refactor
0
+
0
+actually I'm thinking that when I have time it would be worthwhile to
0
+remove toggle, and handle all of the movement through a new
0
+independent toggle-like tool say "toggle-hassle" which uses an alist
0
+like toggle, but instead of elements like
0
+
0
+Done see http://github.com/eschulte/jump.el/tree/master
0
+
0
 * DONE add yaml,css,javascript,ruby pointers to the documentation
0
 * CANCELLED adjust eshell/shell environment to highlight ruby errors
0
 not sure this is possible, at least not easily
...
175
176
177
178
179
180
181
...
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
 
342
343
344
...
346
347
348
349
350
351
 
 
 
 
 
 
 
352
353
354
...
425
426
427
428
429
430
431
 
 
 
432
433
434
...
175
176
177
 
178
179
180
...
319
320
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
323
324
325
...
327
328
329
 
 
 
330
331
332
333
334
335
336
337
338
339
...
410
411
412
 
 
 
 
413
414
415
416
417
418
0
@@ -175,7 +175,6 @@ code to your .emacs file:
0
 @lisp
0
   (add-to-list 'load-path "~/path/to/your/elisp/rinari")
0
   (require 'rinari)
0
- (global-set-key (kbd "C-x C-M-f") 'find-file-in-project) ;; optional
0
 @end lisp
0
 
0
 @node Rhtml Setup, Optional Setup, Basic Setup, Install
0
@@ -320,25 +319,7 @@ tags file relative to the root of your rails applications.
0
 @cindex navigation
0
 
0
 Rinari leverages the structure of Rails projects to allow immediate
0
-navigation between source files. The following four commands use
0
-information on the file and method you are current visiting to open the
0
-appropriate model, controller, view or test file and method.
0
-
0
-@defun rinari-find-model
0
-Go to the most logical model given the current location.
0
-@end defun
0
-
0
-@defun rinari-find-controller
0
-Go to the most logical controller given the current location.
0
-@end defun
0
-
0
-@defun rinari-find-view
0
-Go to the most logical view given the current location.
0
-@end defun
0
-
0
-@defun rinari-find-test
0
-Go to the most logical test given the current location.
0
-@end defun
0
+navigation between source files.
0
 
0
 So for example if you are in a buffer open to @emph{foo_controller.rb},
0
 a call to @code{rinari-find-model} will open the @emph{foo.rb} model
0
@@ -346,9 +327,13 @@ file. Say you are currently inside the @emph{bar} method in a buffer
0
 visiting @emph{foo_controller.rb}, then calling @code{rinari-find-test}
0
 will take you to the @emph{test_bar} method in
0
 @emph{test/functional/foo_controller_test.rb}, or calling
0
-@code{rinari-find-view} will open @emph{app/views/foos/bar.rhtml}, the
0
-bar method contains a redirect or render call in which case those will
0
-be followed to find the correct view to display.
0
+@code{rinari-find-view} will open @emph{app/views/foos/bar.rhtml}.
0
+
0
+All told there are 17 different rinari-find-* functions, which are all
0
+bound to similar hopefully intuitive keybindings allowing you to go
0
+anywhere from anywhere. To see the full range of rinari-find functions
0
+along with their bindings enter a rails project, activate rinari and
0
+call describe-bindings @code{\H-b}.
0
 
0
 @b{TAGS (jumping to method definitions)}
0
 
0
@@ -425,10 +410,9 @@ between errors and source code.
0
 @end defun
0
 
0
 @defun rinari-test
0
-Test the current ruby function. If current function is not a
0
-test, then try to jump to the related test using `toggle-buffer'.
0
-Dump output to a compilation buffer allowing jumping between
0
-errors and source code.
0
+Test the current ruby function. If current function is not a test, then
0
+try to jump to the related test using `rinari-find-test'. Dump output
0
+to a compilation buffer allowing jumping between errors and source code.
0
 @end defun
0
 
0
 @node Miscellaneous, Add Ons, Execution, Top
...
6
7
8
9
 
10
11
12
...
46
47
48
 
 
 
 
49
50
51
 
52
53
54
55
56
57
58
...
65
66
67
68
69
70
71
72
73
74
75
76
...
128
129
130
131
132
133
134
 
 
 
 
135
136
137
138
 
139
140
141
...
240
241
242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
244
245
...
247
248
249
 
 
 
 
 
 
250
251
252
253
254
255
256
257
258
259
 
 
 
 
 
260
261
262
263
264
265
266
267
 
 
 
 
 
 
268
269
270
...
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
298
 
299
300
301
...
6
7
8
 
9
10
11
12
...
46
47
48
49
50
51
52
53
54
55
56
57
 
 
 
58
59
60
...
67
68
69
 
 
 
 
 
 
70
71
72
...
124
125
126
 
 
 
 
127
128
129
130
131
132
133
 
134
135
136
137
...
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
...
429
430
431
432
433
434
435
436
437
438
 
 
 
 
 
 
 
 
 
439
440
441
442
443
444
445
 
 
 
 
 
 
446
447
448
449
450
451
452
453
454
...
456
457
458
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
460
461
 
 
462
463
464
 
 
465
466
467
468
0
@@ -6,7 +6,7 @@
0
 ;; URL: http://rinari.rubyforge.org
0
 ;; Version: 2.0
0
 ;; Created: 2006-11-10
0
-;; Keywords: ruby, rails
0
+;; Keywords: ruby, rails, project, convenience, web
0
 ;; EmacsWiki: Rinari
0
 
0
 ;; This file is NOT part of GNU Emacs.
0
@@ -46,13 +46,15 @@
0
 ;; See TODO file in this directory.
0
 
0
 ;;; Code:
0
+(let ((this-dir (file-name-directory (or load-file-name buffer-file-name))))
0
+ (add-to-list 'load-path this-dir)
0
+ (add-to-list 'load-path (expand-file-name "util" this-dir))
0
+ (add-to-list 'load-path (expand-file-name "util/jump" this-dir)))
0
 (require 'ruby-mode)
0
 (require 'inf-ruby)
0
 (require 'ruby-compilation)
0
+(require 'jump)
0
 (require 'cl)
0
-(require 'toggle)
0
-(require 'find-file-in-project)
0
-(require 'rinari-movement)
0
 
0
 (defcustom rinari-browse-url-func
0
   'browse-url
0
@@ -65,12 +67,6 @@
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
- (let ((ffip-project-root (rinari-root)))
0
- ad-do-it))
0
-
0
 (defadvice ruby-run-w/compilation (around rinari-run-w/compilation activate)
0
   "Set default directory to the root of the rails application
0
   before running ruby processes."
0
@@ -128,14 +124,14 @@ directory of the rails application."
0
 
0
 (defun rinari-test (&optional edit-cmd-args)
0
   "Test the current ruby function. If current function is not a
0
-test, then try to jump to the related test using `toggle-buffer'.
0
-Dump output to a compilation buffer allowing jumping between
0
-errors and source code. With optional prefix argument allows
0
-editing of the test command arguments."
0
+test, then try to jump to the related test using
0
+`rinari-find-test'. Dump output to a compilation buffer allowing
0
+jumping between errors and source code. With optional prefix
0
+argument allows editing of the test command arguments."
0
   (interactive "P")
0
   (or (string-match "test" (or (ruby-add-log-current-method)
0
        (file-name-nondirectory (buffer-file-name))))
0
- (toggle-buffer))
0
+ (rinari-find-test))
0
   (let* ((funname (ruby-add-log-current-method))
0
    (fn (and funname
0
      (string-match "#\\(.*\\)" funname)
0
@@ -240,6 +236,192 @@ With optional prefix argument just run `rgrep'."
0
    "*.rb *.rhtml *.yml *.erb" (rinari-root))))
0
 
0
 ;;--------------------------------------------------------------------
0
+;; rinari movement using jump.el
0
+
0
+(defun rinari-generate (type name)
0
+ (message (shell-command-to-string
0
+ (format "ruby %sscript/generate %s %s" (rinari-root) type
0
+ (read-from-minibuffer (format "create %s: " type) name)))))
0
+
0
+(defvar rinari-ruby-hash-regexp
0
+ "\\(:[^[:space:]]*?\\)[[:space:]]*\\(=>[[:space:]]*[\"\':]?\\([^[:space:]]*?\\)[\"\']?[[:space:]]*\\)?[,){}\n]"
0
+ "Regexp to match subsequent key => value pairs of a ruby hash.")
0
+
0
+(defun rinari-ruby-values-from-render (controller action)
0
+ "Adjusts CONTROLLER and ACTION acording to keyword arguments in
0
+the hash at `point', then return (CONTROLLER . ACTION)"
0
+ (let ((end (save-excursion
0
+ (re-search-forward "[^,{(]$" nil t)
0
+ (+ 1 (point)))))
0
+ (save-excursion
0
+ (while (and (< (point) end)
0
+ (re-search-forward rinari-ruby-hash-regexp end t))
0
+ (if (> (length (match-string 3)) 1)
0
+ (case (intern (match-string 1))
0
+ (:partial (setf action (concat "_" (match-string 3))))
0
+ (:action (setf action (match-string 3)))
0
+ (:controller (setf controller (match-string 3)))))))
0
+ (cons controller action)))
0
+
0
+(defun rinari-which-render (renders)
0
+ (let ((path (jump-completing-read
0
+ "Follow: "
0
+ (mapcar (lambda (lis)
0
+ (concat (car lis) "/" (cdr lis)))
0
+ renders))))
0
+ (string-match "\\(.*\\)/\\(.*\\)" path)
0
+ (cons (match-string 1 path) (match-string 2 path))))
0
+
0
+(defun rinari-follow-controller-and-action (controller action)
0
+ "Follow the current controller-and-action through all of the
0
+renders and redirects to find the final controller or view."
0
+ (save-excursion ;; if we can find the controller#action pair
0
+ (if (and (jump-to-path (format "app/controllers/%s_controller.rb#%s" controller action))
0
+ (equalp (jump-method) action))
0
+ (let ((start (point)) ;; demarcate the borders
0
+ (renders (list (cons controller action))) render view)
0
+ (ruby-forward-sexp)
0
+ ;; collect redirection options and pursue
0
+ (while (re-search-backward "re\\(?:direct_to\\|nder\\)" start t)
0
+ (add-to-list 'renders (rinari-ruby-values-from-render controller action)))
0
+ (let ((render (if (equalp 1 (length renders))
0
+ (car renders)
0
+ (rinari-which-render renders))))
0
+ (if (and (equalp (cdr render) action)
0
+ (equalp (car render) controller))
0
+ (list controller action) ;; directed to here so return
0
+ (rinari-follow-controller-and-action (or (car render)
0
+ controller)
0
+ (or (cdr render)
0
+ action)))))
0
+ ;; no controller entry so return
0
+ (list controller action))))
0
+
0
+(setf
0
+ rinari-jump-schema
0
+ '((model
0
+ "m"
0
+ (("app/controllers/\\1_controller.rb#\\2" . "app/models/\\1.rb#\\2")
0
+ ("app/views/\\1/.*" . "app/models/\\1.rb")
0
+ ("app/helpers/\\1_helper.rb" . "app/models/\\1.rb")
0
+ ("db/migrate/.*create_\\1.rb" . "app/models/\\1.rb")
0
+ ("test/functional/\\1_controller_test.rb" . "app/models/\\1.rb")
0
+ ("test/unit/\\1_test.rb#test_\\2" . "app/models/\\1.rb#\\2")
0
+ ("test/unit/\\1_test.rb" . "app/models/\\1.rb")
0
+ ("test/fixtures/\\1.yml" . "app/models/\\1.rb")
0
+ (t . "app/models/"))
0
+ (lambda (path)
0
+ (rinari-generate "model"
0
+ (and (string-match ".*/\\(.+?\\)\.rb" path)
0
+ (match-string 1 path)))))
0
+ (controller
0
+ "c"
0
+ (("app/models/\\1.rb" . "app/controllers/\\1_controller.rb")
0
+ ("app/views/\\1/\\2\\..*" . "app/controllers/\\1_controller.rb#\\2")
0
+ ("app/helpers/\\1_helper.rb" . "app/controllers/\\1_controller.rb")
0
+ ("db/migrate/.*create_\\1.rb" . "app/controllers/\\1_controller.rb")
0
+ ("test/functional/\\1_controller_test.rb" . "app/controllers/\\1_controller.rb")
0
+ ("test/unit/\\1_test.rb#test_\\2" . "app/controllers/\\1_controller.rb#\\2")
0
+ ("test/unit/\\1_test.rb" . "app/controllers/\\1_controller.rb")
0
+ ("test/fixtures/\\1.yml" . "app/controllers/\\1_controller.rb")
0
+ (t . "app/controllers/"))
0
+ (lambda (path)
0
+ (rinari-generate "model"
0
+ (and (string-match ".*/\\(.+?\\)_controller\.rb" path)
0
+ (match-string 1 path)))))
0
+ (view
0
+ "v"
0
+ (("app/models/\\1.rb" . "app/views/\\1/.*")
0
+ ((lambda () ;; find the controller/view
0
+ (rinari-follow-controller-and-action
0
+ (let ((file (file-name-nondirectory (buffer-file-name))))
0
+ (and (string-match "^\\(.*\\)_controller.rb" file)
0
+ (match-string 1 file)));; controller
0
+ (let ((method (ruby-add-log-current-method))) ;; action
0
+ (and (string-match "#\\(.*\\)" method) (match-string 1 method)))))
0
+ . "app/views/\\1/\\2\\..*")
0
+ ("app/helpers/\\1_helper.rb" . "app/views/\\1/.*")
0
+ ("db/migrate/.*create_\\1.rb" . "app/views/\\1/.*")
0
+ ("test/functional/\\1_controller_test.rb" . "app/views/\\1/.*")
0
+ ("test/unit/\\1_test.rb#test_\\2" . "app/views/\\1/_?\\2.*")
0
+ ("test/fixtures/\\1.yml" . "app/views/\\1/.*")
0
+ (t . "app/views/.*"))
0
+ nil)
0
+ (test
0
+ "t"
0
+ (("app/models/\\1.rb#\\2" . "test/unit/\\1_test.rb#test_\\2")
0
+ ("app/controllers/\\1.rb#\\2" . "test/functional/\\1_test.rb#test_\\2")
0
+ ("app/views/\\1/_?\\2\\..*" . "test/functional/\\1_controller_test.rb#test_\\2")
0
+ ("app/helpers/\\1_helper.rb" . "test/functional/\\1_controller_test.rb")
0
+ ("db/migrate/.*create_\\1.rb" . "test/unit/\\1_test.rb")
0
+ ("test/functional/\\1_controller_test.rb" . "test/unit/\\1_test.rb")
0
+ ("test/unit/\\1_test.rb" . "test/functional/\\1_controller_test.rb")
0
+ (t . "test/.*"))
0
+ nil)
0
+ (fixture
0
+ "x"
0
+ (("app/models/\\1.rb" . "test/fixtures/\\1.yml")
0
+ ("app/controllers/\\1_controller.rb" . "test/fixtures/\\1.yml")
0
+ ("app/views/\\1/.*" . "test/fixtures/\\1.yml")
0
+ ("app/helpers/\\1_helper.rb" . "test/fixtures/\\1.yml")
0
+ ("db/migrate/.*create_\\1.rb" . "test/fixtures/\\1.yml")
0
+ ("test/functional/\\1_controller_test.rb" . "test/fixtures/\\1.yml")
0
+ ("test/unit/\\1_test.rb" . "test/fixtures/\\1.yml")
0
+ (t . "test/fixtures/"))
0
+ nil)
0
+ (helper
0
+ "h"
0
+ (("app/models/\\1.rb" . "app/helpers/\\1_helper.rb")
0
+ ("app/controllers/\\1_controller.rb" . "app/helpers/\\1_helper.rb")
0
+ ("app/views/\\1/.*" . "app/helpers/\\1_helper.rb")
0
+ ("app/helpers/\\1_helper.rb" . "app/helpers/\\1_helper.rb")
0
+ ("db/migrate/.*create_\\1.rb" . "app/helpers/\\1_helper.rb")
0
+ ("test/functional/\\1_controller_test.rb" . "app/helpers/\\1_helper.rb")
0
+ ("test/unit/\\1_test.rb#test_\\2" . "app/helpers/\\1_helper.rb#\\2")
0
+ ("test/unit/\\1_test.rb" . "app/helpers/\\1_helper.rb")
0
+ (t . "app/helpers/"))
0
+ nil)
0
+ (migration
0
+ "i"
0
+ (("app/controllers/\\1_controller.rb" . "db/migrate/.*create_\\1.rb")
0
+ ("app/views/\\1/.*" . "db/migrate/.*create_\\1.rb")
0
+ ("app/helpers/\\1_helper.rb" . "db/migrate/.*create_\\1.rb")
0
+ ("app/models/\\1.rb" . "db/migrate/.*create_\\1.rb")
0
+ ("test/functional/\\1_controller_test.rb" . "db/migrate/.*create_\\1.rb")
0
+ ("test/unit/\\1_test.rb#test_\\2" . "db/migrate/.*create_\\1.rb#\\2")
0
+ ("test/unit/\\1_test.rb" . "db/migrate/.*create_\\1.rb")
0
+ (t . "db/migrate/"))
0
+ (lambda (path)
0
+ (rinari-generate "migration"
0
+ (and (string-match ".*create_\\(.+?\\)\.rb" path)
0
+ (match-string 1 path)))))
0
+ (environment "e" ((t . "config/environments/")) nil)
0
+ (configuration "n" ((t . "config/")) nil)
0
+ (script "s" ((t . "script/")) nil)
0
+ (lib "l" ((t . "lib/")) nil)
0
+ (log "o" ((t . "log/")) nil)
0
+ (worker "w" ((t . "lib/workers/")) nil)
0
+ (public "p" ((t . "public/")) nil)
0
+ (stylesheet "y" ((t . "public/stylesheets/.*")) nil)
0
+ (javascript "j" ((t . "public/javascripts/.*")) nil)
0
+ (plugin "l" ((t . "vendor/plugins/")) nil)
0
+ (file-in-project "f" ((t . ".*")) nil)))
0
+
0
+(mapcar
0
+ (lambda (type)
0
+ (let ((name (first type))
0
+ (specs (third type))
0
+ (make (fourth type)))
0
+ (eval `(defjump
0
+ (quote ,(read (format "rinari-find-%S" name)))
0
+ (quote ,specs)
0
+ 'rinari-root
0
+ ,(format "Go to the most logical %S given the current location" name)
0
+ ,(if make `(quote ,make))
0
+ 'ruby-add-log-current-method))))
0
+ rinari-jump-schema)
0
+
0
+;;--------------------------------------------------------------------
0
 ;; minor mode and keymaps
0
 
0
 (defvar rinari-minor-mode-map
0
@@ -247,24 +429,26 @@ With optional prefix argument just run `rgrep'."
0
     map)
0
   "Key map for Rinari minor mode.")
0
 
0
+(defun rinari-bind-key-to-func (key func)
0
+ (eval `(define-key rinari-minor-mode-map
0
+ ,(format "\C-c;%s" key) ,func))
0
+ (eval `(define-key rinari-minor-mode-map
0
+ ,(format "\C-c'%s" key) ,func)))
0
+
0
 (defvar rinari-minor-mode-keybindings
0
- '(("o" . 'toggle-buffer) ("s" . 'rinari-script)
0
- ("e" . 'rinari-insert-erb-skeleton) ("t" . 'rinari-test)
0
- ("r" . 'rinari-rake) ("c" . 'rinari-console)
0
- ("w" . 'rinari-web-server) ("g" . 'rinari-rgrep)
0
- ("b" . 'rinari-browse-url) ("q" . 'rinari-sql)
0
- ("fc" . 'rinari-find-controller) ("ft" . 'rinari-find-test)
0
- ("fv" . 'rinari-find-view) ("fm" . 'rinari-find-model)
0
- ("fi" . 'rinari-find-migration) ("fe" . 'rinari-find-environment)
0
- ("fj" . 'rinari-find-javascript) ("fs" . 'rinari-find-stylesheet))
0
+ '(("s" . 'rinari-script)
0
+ ("e" . 'rinari-insert-erb-skeleton) ("t" . 'rinari-test)
0
+ ("r" . 'rinari-rake) ("c" . 'rinari-console)
0
+ ("w" . 'rinari-web-server) ("g" . 'rinari-rgrep)
0
+ ("b" . 'rinari-browse-url) ("q" . 'rinari-sql))
0
   "alist mapping of keys to functions in `rinari-minor-mode'")
0
 
0
-(mapcar (lambda (el)
0
- (eval `(define-key rinari-minor-mode-map
0
- ,(format "\C-c;%s" (car el)) ,(cdr el)))
0
- (eval `(define-key rinari-minor-mode-map
0
- ,(format "\C-c'%s" (car el)) ,(cdr el))))
0
- rinari-minor-mode-keybindings)
0
+(mapcar (lambda (el) (rinari-bind-key-to-func (car el) (cdr el)))
0
+ (append (mapcar (lambda (el)
0
+ (cons (concat "f" (second el))
0
+ (read (format "'rinari-find-%S" (first el)))))
0
+ rinari-jump-schema)
0
+ rinari-minor-mode-keybindings))
0
 
0
 (defun rinari-launch ()
0
   "Run `rinari-minor-mode' if inside of a rails projecct,
0
@@ -272,30 +456,13 @@ 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
     (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
+ (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
0
- 'javascript-mode-hook 'dired-mode-hook)
0
+ '('find-file-hook 'mumamo-after-change-major-mode-hook 'dired-mode-hook)
0
   "Major Modes from which to launch Rinari.")
0
 
0
 (mapcar (lambda (hook)
...
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
...
35
36
37
 
38
39
40
 
41
42
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
47
48
0
@@ -35,32 +35,14 @@
0
        (kill-buffer (file-name-nondirectory (car start))))))
0
   (here-to-here '("test/unit/example_test.rb" . 153)
0
      'rinari-find-model
0
- '("app/models/example.rb" . 39))
0
+ '("app/models/example.rb" . 37))
0
   (here-to-here '("app/controllers/units_controller.rb" . 52)
0
      'rinari-find-test
0
- '("test/functional/units_controller_test.rb" . 152))
0
+ '("test/functional/units_controller_test.rb" . 150))
0
   (here-to-here '("app/controllers/units_controller.rb" . 61)
0
      'rinari-find-view
0
      '("app/views/units/fall.html.erb" . 1))))))
0
 
0
-(deftest rinari-create-model-test rinari-suite
0
- ;; testing the creation of models when they don't exist
0
- (let* ((default-directory (format "%s" (concat (file-name-directory
0
- (or load-file-name buffer-file-name))
0
- "rails-app/")))
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 ;; 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
- (delete-file new-model)
0
- ;; delete all of the migrations
0
- (mapcar (lambda (file)
0
- (delete-file (concat default-directory "/db/migrate/" file)))
0
- (directory-files "db/migrate/" nil "^[^.]"))))
0
-
0
 (deftest rinari-console-test rinari-suite
0
   ;; testing ability to launch console, server, and a test
0
   (save-excursion

Comments

    No one has commented yet.