Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 487 lines (439 sloc) 20.167 kb
bfb626a1 »
2008-05-13 Initial import of rinari 2
1 ;;; rinari.el --- Rinari Is Not A Rails IDE
2
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
3 ;; Copyright (C) 2008 Phil Hagelberg, Eric Schulte
bfb626a1 »
2008-05-13 Initial import of rinari 2
4
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
5 ;; Authors: Phil Hagelberg, Eric Schulte
bfb626a1 »
2008-05-13 Initial import of rinari 2
6 ;; URL: http://rinari.rubyforge.org
7 ;; Version: 2.0
8 ;; Created: 2006-11-10
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
9 ;; Keywords: ruby, rails, project, convenience, web
bfb626a1 »
2008-05-13 Initial import of rinari 2
10 ;; EmacsWiki: Rinari
11
12 ;; This file is NOT part of GNU Emacs.
13
14 ;;; License:
15
16 ;; This program is free software; you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation; either version 3, or (at your option)
19 ;; any later version.
20 ;;
21 ;; This program is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
25 ;;
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
28 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29 ;; Boston, MA 02110-1301, USA.
30
31 ;;; Commentary:
32
33 ;; Rinari Is Not A Ruby IDE.
34
35 ;; Well, ok it kind of is. Rinari is a set of Emacs Lisp modes that is
36 ;; aimed towards making Emacs into a top-notch Ruby and Rails
37 ;; development environment.
38
39 ;; Copy the directory containing this file into your Emacs lisp
40 ;; directory, assumed here to be ~/.emacs.d. Add these lines of code
41 ;; to your .emacs file:
42
43 ;; (add-to-list 'load-path "~/.emacs.d/rinari")
44 ;; (require 'rinari)
45
e6f3043c »
2008-07-02 minor doco tweaks
46 ;; See TODO file in this directory.
bfb626a1 »
2008-05-13 Initial import of rinari 2
47
48 ;;; Code:
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
49 (let ((this-dir (file-name-directory (or load-file-name buffer-file-name))))
50 (add-to-list 'load-path this-dir)
51 (add-to-list 'load-path (expand-file-name "util" this-dir))
52 (add-to-list 'load-path (expand-file-name "util/jump" this-dir)))
bfb626a1 »
2008-05-13 Initial import of rinari 2
53 (require 'ruby-mode)
54 (require 'inf-ruby)
9c51fe76 » eschulte
2008-06-24 cleaner, smaller, and more useful...
55 (require 'ruby-compilation)
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
56 (require 'jump)
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
57 (require 'cl)
ec565edb » Eric Schulte
2008-06-17 functions all start with 'rails', reverted to origional find-file-in-…
58
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
59 (defcustom rinari-browse-url-func
60 'browse-url
61 "`browse-url' function used by `rinari-browse-view'.")
bfb626a1 »
2008-05-13 Initial import of rinari 2
62
e71be827 » eschulte
2008-07-15 - added rinari-tags-file-name for using tags in a rails project
63 (defcustom rinari-tags-file-name
64 "TAGS"
65 "Path to your TAGS file inside of your rails project. See `tags-file-name'.")
66
b02f6c60 »
2008-08-18 Add `rinari-minor-mode-hook' for customization. Make some variables b…
67 (defvar rinari-minor-mode-hook nil
68 "*Hook for customising Rinari.")
69
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
70 (defadvice ruby-run-w/compilation (around rinari-run-w/compilation activate)
71 "Set default directory to the root of the rails application
72 before running ruby processes."
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
73 (let ((default-directory (or (rinari-root) default-directory)))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
74 ad-do-it
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
75 (rinari-launch)))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
76
77 (defadvice ruby-rake-w/compilation (around rinari-rake-w/compilation activate)
78 "Set default directory to the root of the rails application
79 before running rake processes."
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
80 (let ((default-directory (or (rinari-root) default-directory)))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
81 ad-do-it
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
82 (rinari-launch)))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
83
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
84 (defun rinari-parse-yaml ()
85 (let ((start (point))
86 (end (save-excursion (re-search-forward "^$" nil t) (point)))
87 alist)
88 (while (and (< (point) end)
89 (re-search-forward "^ *\\(.*\\): \\(.*\\)$" nil t))
90 (setf alist (cons (cons (match-string 1) (match-string 2)) alist)))
91 alist))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
92
93 (defun rinari-root (&optional dir)
94 (or dir (setq dir default-directory))
95 (if (file-exists-p (concat dir "config/environment.rb"))
96 dir
97 (unless (equal dir "/")
98 (rinari-root (expand-file-name (concat dir "../"))))))
99
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
100 ;;--------------------------------------------------------------------------------
101 ;; user functions
09ae6cbf » Eric Schulte
2008-06-16 rails-scripts.el is finished for now, progress of using redirects to …
102
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
103 (defun rinari-rake (&optional task edit-cmd-args)
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
104 "Tab completion selection of a rake task to execute with the
105 output dumped to a compilation buffer allowing jumping between
106 errors and source code. With optional prefix argument allows
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
107 editing of the rake command arguments."
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
108 (interactive "P")
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
109 (ruby-rake-w/compilation task edit-cmd-args))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
110
638d0c1e » eschulte
2008-07-22 added execution of rails scripts rinari-script
111 (defun rinari-script (&optional script)
112 "Tab completing selection of a script from the script/
113 directory of the rails application."
114 (interactive)
115 (let* ((root (rinari-root))
116 (script (or script
117 (completing-read "Script: " (directory-files (concat root "script") nil "^[^.]"))))
118 (ruby-compilation-error-regexp-alist ;; for jumping to newly created files
119 (if (equal script "generate")
120 '(("^ +\\(exists\\|create\\) +\\([^[:space:]]+\\.rb\\)" 2 3))
121 ruby-compilation-error-regexp-alist))
122 (script (concat "script/" script " ")))
123 (ruby-run-w/compilation (concat root script (read-from-minibuffer script)))))
124
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
125 (defun rinari-test (&optional edit-cmd-args)
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
126 "Test the current ruby function. If current function is not a
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
127 test, then try to jump to the related test using
128 `rinari-find-test'. Dump output to a compilation buffer allowing
129 jumping between errors and source code. With optional prefix
130 argument allows editing of the test command arguments."
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
131 (interactive "P")
132 (or (string-match "test" (or (ruby-add-log-current-method)
133 (file-name-nondirectory (buffer-file-name))))
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
134 (rinari-find-test))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
135 (let* ((funname (ruby-add-log-current-method))
136 (fn (and funname
137 (string-match "#\\(.*\\)" funname)
138 (match-string 1 funname)))
139 (path (buffer-file-name))
140 (default-command (if fn
141 (concat path " --name /" fn "/")
142 path))
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
143 (command (if edit-cmd-args
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
144 (read-string "Run w/Compilation: " default-command)
145 default-command)))
146 (if path (ruby-run-w/compilation command)
147 (message "no test available"))))
bfb626a1 »
2008-05-13 Initial import of rinari 2
148
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
149 (defun rinari-console (&optional edit-cmd-args)
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
150 "Run script/console in a compilation buffer, with command
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
151 history and links between errors and source code. With optional
152 prefix argument allows editing of the console command arguments."
bfb626a1 »
2008-05-13 Initial import of rinari 2
153 (interactive "P")
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
154 (let* ((script (concat (rinari-root) "script/console"))
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
155 (command (if edit-cmd-args
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
156 (read-string "Run Ruby: " (concat script " "))
157 script)))
158 (run-ruby command)
159 (save-excursion (pop-to-buffer "*ruby*")
160 (set (make-local-variable 'inferior-ruby-first-prompt-pattern) "^>> ")
161 (set (make-local-variable 'inferior-ruby-prompt-pattern) "^>> ")
d010c174 » eschulte
2008-07-22 added execution of rails scripts rinari-script
162 (rinari-launch))))
bfb626a1 »
2008-05-13 Initial import of rinari 2
163
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
164 (defun rinari-sql ()
165 "Browse the application's database. Looks up login information
166 from your conf/database.sql file."
167 (interactive)
168 (flet ((sql-name (env) (format "*%s-sql*" env)))
169 (let* ((environment (or (getenv "RAILS_ENV") "development"))
170 (sql-buffer (get-buffer (sql-name environment))))
171 (if sql-buffer
172 (pop-to-buffer sql-buffer)
173 (let* ((database-alist (save-excursion
174 (with-temp-buffer
175 (insert-file (concat (rinari-root)
176 "/config/database.yml"))
177 (goto-char (point-min))
178 (re-search-forward (concat "^" environment ":"))
179 (rinari-parse-yaml))))
180 (adapter (or (cdr (assoc "adapter" database-alist)) "sqlite"))
181 (sql-user (or (cdr (assoc "username" database-alist)) "root"))
182 (sql-password (or (cdr (assoc "password" database-alist)) ""))
183 (sql-database (or (cdr (assoc "database" database-alist))
184 (concat (file-name-nondirectory (rinari-root))
185 "_" environment)))
186 (server (or (cdr (assoc "host" database-alist)) "localhost"))
187 (port (cdr (assoc "port" database-alist)))
188 (sql-server (if port (concat server ":" port) server)))
189 (if (string-match "sqlite" adapter) (setf adapter "sqlite"))
190 (eval (list (intern (concat "sql-" adapter))))
191 (rename-buffer (sql-name environment)) (rinari-launch))))))
192
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
193 (defun rinari-web-server (&optional edit-cmd-args)
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
194 "Run script/server. Dump output to a compilation buffer
acb16a79 » eschulte
2008-07-27 updated documentation, rinari-web-server now takes a prefix argument
195 allowing jumping between errors and source code. With optional
196 prefix argument allows editing of the server command arguments."
197 (interactive "P")
198 (let* ((default-directory (rinari-root))
199 (script (concat (rinari-root) "script/server"))
200 (command (if edit-cmd-args
201 (read-string "Run Ruby: " (concat script " "))
202 script)))
203 (ruby-run-w/compilation command)))
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
204
205 (defun rinari-browse-url ()
206 "Browse the url of the current view, controller, test, or model
207 with `rinari-browse-url-func' which defaults to `browse-url'."
208 (interactive)
209 (unless (equal :view (rinari-whats-my-type))
210 (rinari-find-view))
41f635cb » Eric Schulte
2008-06-21 parsimony
211 (let* ((path (buffer-file-name))
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
212 (route (and (string-match "app/views/\\(.+\\)\.r[ebhtml]+" path)
213 (match-string 1 path)))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
214 (port (or () ;; guess port (or not)
41f635cb » Eric Schulte
2008-06-21 parsimony
215 "3000"))
68bf2c17 » eschulte
2008-06-27 cleaned up, ready for dissemination
216 (server (or () ;; guess server (or not)
41f635cb » Eric Schulte
2008-06-21 parsimony
217 "localhost"))
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
218 (base (concat server ":" port "/" route))
219 (url (read-from-minibuffer "url: " (concat base "/"))))
b12e8dbb » eschulte
2008-06-23 all function now prefix'd w/rinari
220 (eval (list rinari-browse-url-func url))))
41f635cb » Eric Schulte
2008-06-21 parsimony
221
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
222 (defun rinari-insert-erb-skeleton (no-equals)
223 "Insert an erb skeleton at point, with optional prefix argument
224 don't include an '='."
225 (interactive "P")
226 (insert "<%") (unless no-equals (insert "=")) (insert " %>")
227 (backward-char 3))
7db851b6 » eschulte
2008-06-30 added ruby-compilation minor mode, added rinari-sql for browsing rail…
228
ad549043 » eschulte
2008-07-02 added rinari-rgrep for searching the rails project
229 (defun rinari-rgrep (&optional arg)
230 "Search through the rails project for a string or `regexp'.
231 With optional prefix argument just run `rgrep'."
232 (interactive "P")
97592c28 » eschulte
2008-07-02 fixed small issue w/rinari-rgrep
233 (grep-compute-defaults)
ad549043 » eschulte
2008-07-02 added rinari-rgrep for searching the rails project
234 (if arg (call-interactively 'rgrep)
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
235 (funcall 'rgrep (read-from-minibuffer "search for: ")
0c3db2ff » eschulte
2008-07-14 expanded test coverage, added support for rails 2.*, added Nathan Wei…
236 "*.rb *.rhtml *.yml *.erb" (rinari-root))))
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
237
5d906bd8 » Eric Schulte
2008-06-17 rinari is now a minor mode
238 ;;--------------------------------------------------------------------
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
239 ;; rinari movement using jump.el
240
241 (defun rinari-generate (type name)
242 (message (shell-command-to-string
243 (format "ruby %sscript/generate %s %s" (rinari-root) type
244 (read-from-minibuffer (format "create %s: " type) name)))))
245
246 (defvar rinari-ruby-hash-regexp
247 "\\(:[^[:space:]]*?\\)[[:space:]]*\\(=>[[:space:]]*[\"\':]?\\([^[:space:]]*?\\)[\"\']?[[:space:]]*\\)?[,){}\n]"
248 "Regexp to match subsequent key => value pairs of a ruby hash.")
249
250 (defun rinari-ruby-values-from-render (controller action)
251 "Adjusts CONTROLLER and ACTION acording to keyword arguments in
252 the hash at `point', then return (CONTROLLER . ACTION)"
253 (let ((end (save-excursion
254 (re-search-forward "[^,{(]$" nil t)
255 (+ 1 (point)))))
256 (save-excursion
257 (while (and (< (point) end)
258 (re-search-forward rinari-ruby-hash-regexp end t))
259 (if (> (length (match-string 3)) 1)
260 (case (intern (match-string 1))
261 (:partial (setf action (concat "_" (match-string 3))))
262 (:action (setf action (match-string 3)))
263 (:controller (setf controller (match-string 3)))))))
264 (cons controller action)))
265
266 (defun rinari-which-render (renders)
267 (let ((path (jump-completing-read
268 "Follow: "
269 (mapcar (lambda (lis)
270 (concat (car lis) "/" (cdr lis)))
271 renders))))
272 (string-match "\\(.*\\)/\\(.*\\)" path)
273 (cons (match-string 1 path) (match-string 2 path))))
274
275 (defun rinari-follow-controller-and-action (controller action)
276 "Follow the current controller-and-action through all of the
277 renders and redirects to find the final controller or view."
278 (save-excursion ;; if we can find the controller#action pair
279 (if (and (jump-to-path (format "app/controllers/%s_controller.rb#%s" controller action))
280 (equalp (jump-method) action))
281 (let ((start (point)) ;; demarcate the borders
282 (renders (list (cons controller action))) render view)
283 (ruby-forward-sexp)
284 ;; collect redirection options and pursue
285 (while (re-search-backward "re\\(?:direct_to\\|nder\\)" start t)
286 (add-to-list 'renders (rinari-ruby-values-from-render controller action)))
287 (let ((render (if (equalp 1 (length renders))
288 (car renders)
289 (rinari-which-render renders))))
290 (if (and (equalp (cdr render) action)
291 (equalp (car render) controller))
292 (list controller action) ;; directed to here so return
293 (rinari-follow-controller-and-action (or (car render)
294 controller)
295 (or (cdr render)
296 action)))))
297 ;; no controller entry so return
298 (list controller action))))
299
300 (setf
301 rinari-jump-schema
302 '((model
303 "m"
304 (("app/controllers/\\1_controller.rb#\\2" . "app/models/\\1.rb#\\2")
305 ("app/views/\\1/.*" . "app/models/\\1.rb")
306 ("app/helpers/\\1_helper.rb" . "app/models/\\1.rb")
307 ("db/migrate/.*create_\\1.rb" . "app/models/\\1.rb")
308 ("test/functional/\\1_controller_test.rb" . "app/models/\\1.rb")
309 ("test/unit/\\1_test.rb#test_\\2" . "app/models/\\1.rb#\\2")
310 ("test/unit/\\1_test.rb" . "app/models/\\1.rb")
311 ("test/fixtures/\\1.yml" . "app/models/\\1.rb")
312 (t . "app/models/"))
313 (lambda (path)
314 (rinari-generate "model"
315 (and (string-match ".*/\\(.+?\\)\.rb" path)
316 (match-string 1 path)))))
317 (controller
318 "c"
319 (("app/models/\\1.rb" . "app/controllers/\\1_controller.rb")
320 ("app/views/\\1/\\2\\..*" . "app/controllers/\\1_controller.rb#\\2")
321 ("app/helpers/\\1_helper.rb" . "app/controllers/\\1_controller.rb")
322 ("db/migrate/.*create_\\1.rb" . "app/controllers/\\1_controller.rb")
323 ("test/functional/\\1_controller_test.rb" . "app/controllers/\\1_controller.rb")
324 ("test/unit/\\1_test.rb#test_\\2" . "app/controllers/\\1_controller.rb#\\2")
325 ("test/unit/\\1_test.rb" . "app/controllers/\\1_controller.rb")
326 ("test/fixtures/\\1.yml" . "app/controllers/\\1_controller.rb")
327 (t . "app/controllers/"))
328 (lambda (path)
329 (rinari-generate "model"
330 (and (string-match ".*/\\(.+?\\)_controller\.rb" path)
331 (match-string 1 path)))))
332 (view
333 "v"
334 (("app/models/\\1.rb" . "app/views/\\1/.*")
335 ((lambda () ;; find the controller/view
336 (rinari-follow-controller-and-action
337 (let ((file (file-name-nondirectory (buffer-file-name))))
338 (and (string-match "^\\(.*\\)_controller.rb" file)
339 (match-string 1 file)));; controller
340 (let ((method (ruby-add-log-current-method))) ;; action
341 (and (string-match "#\\(.*\\)" method) (match-string 1 method)))))
342 . "app/views/\\1/\\2\\..*")
343 ("app/helpers/\\1_helper.rb" . "app/views/\\1/.*")
344 ("db/migrate/.*create_\\1.rb" . "app/views/\\1/.*")
345 ("test/functional/\\1_controller_test.rb" . "app/views/\\1/.*")
346 ("test/unit/\\1_test.rb#test_\\2" . "app/views/\\1/_?\\2.*")
347 ("test/fixtures/\\1.yml" . "app/views/\\1/.*")
348 (t . "app/views/.*"))
349 nil)
350 (test
351 "t"
352 (("app/models/\\1.rb#\\2" . "test/unit/\\1_test.rb#test_\\2")
353 ("app/controllers/\\1.rb#\\2" . "test/functional/\\1_test.rb#test_\\2")
354 ("app/views/\\1/_?\\2\\..*" . "test/functional/\\1_controller_test.rb#test_\\2")
355 ("app/helpers/\\1_helper.rb" . "test/functional/\\1_controller_test.rb")
356 ("db/migrate/.*create_\\1.rb" . "test/unit/\\1_test.rb")
357 ("test/functional/\\1_controller_test.rb" . "test/unit/\\1_test.rb")
358 ("test/unit/\\1_test.rb" . "test/functional/\\1_controller_test.rb")
359 (t . "test/.*"))
360 nil)
361 (fixture
362 "x"
363 (("app/models/\\1.rb" . "test/fixtures/\\1.yml")
364 ("app/controllers/\\1_controller.rb" . "test/fixtures/\\1.yml")
365 ("app/views/\\1/.*" . "test/fixtures/\\1.yml")
366 ("app/helpers/\\1_helper.rb" . "test/fixtures/\\1.yml")
367 ("db/migrate/.*create_\\1.rb" . "test/fixtures/\\1.yml")
368 ("test/functional/\\1_controller_test.rb" . "test/fixtures/\\1.yml")
369 ("test/unit/\\1_test.rb" . "test/fixtures/\\1.yml")
370 (t . "test/fixtures/"))
371 nil)
372 (helper
373 "h"
374 (("app/models/\\1.rb" . "app/helpers/\\1_helper.rb")
375 ("app/controllers/\\1_controller.rb" . "app/helpers/\\1_helper.rb")
376 ("app/views/\\1/.*" . "app/helpers/\\1_helper.rb")
377 ("app/helpers/\\1_helper.rb" . "app/helpers/\\1_helper.rb")
378 ("db/migrate/.*create_\\1.rb" . "app/helpers/\\1_helper.rb")
379 ("test/functional/\\1_controller_test.rb" . "app/helpers/\\1_helper.rb")
380 ("test/unit/\\1_test.rb#test_\\2" . "app/helpers/\\1_helper.rb#\\2")
381 ("test/unit/\\1_test.rb" . "app/helpers/\\1_helper.rb")
382 (t . "app/helpers/"))
383 nil)
384 (migration
385 "i"
386 (("app/controllers/\\1_controller.rb" . "db/migrate/.*create_\\1.rb")
387 ("app/views/\\1/.*" . "db/migrate/.*create_\\1.rb")
388 ("app/helpers/\\1_helper.rb" . "db/migrate/.*create_\\1.rb")
389 ("app/models/\\1.rb" . "db/migrate/.*create_\\1.rb")
390 ("test/functional/\\1_controller_test.rb" . "db/migrate/.*create_\\1.rb")
391 ("test/unit/\\1_test.rb#test_\\2" . "db/migrate/.*create_\\1.rb#\\2")
392 ("test/unit/\\1_test.rb" . "db/migrate/.*create_\\1.rb")
393 (t . "db/migrate/"))
394 (lambda (path)
395 (rinari-generate "migration"
396 (and (string-match ".*create_\\(.+?\\)\.rb" path)
397 (match-string 1 path)))))
398 (environment "e" ((t . "config/environments/")) nil)
399 (configuration "n" ((t . "config/")) nil)
400 (script "s" ((t . "script/")) nil)
401 (lib "l" ((t . "lib/")) nil)
402 (log "o" ((t . "log/")) nil)
403 (worker "w" ((t . "lib/workers/")) nil)
404 (public "p" ((t . "public/")) nil)
405 (stylesheet "y" ((t . "public/stylesheets/.*")) nil)
406 (javascript "j" ((t . "public/javascripts/.*")) nil)
407 (plugin "l" ((t . "vendor/plugins/")) nil)
408 (file-in-project "f" ((t . ".*")) nil)))
409
410 (mapcar
411 (lambda (type)
412 (let ((name (first type))
413 (specs (third type))
414 (make (fourth type)))
415 (eval `(defjump
416 (quote ,(read (format "rinari-find-%S" name)))
417 (quote ,specs)
418 'rinari-root
419 ,(format "Go to the most logical %S given the current location" name)
420 ,(if make `(quote ,make))
421 'ruby-add-log-current-method))))
422 rinari-jump-schema)
423
424 ;;--------------------------------------------------------------------
5d906bd8 » Eric Schulte
2008-06-17 rinari is now a minor mode
425 ;; minor mode and keymaps
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
426
5d906bd8 » Eric Schulte
2008-06-17 rinari is now a minor mode
427 (defvar rinari-minor-mode-map
428 (let ((map (make-sparse-keymap)))
429 map)
430 "Key map for Rinari minor mode.")
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
431
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
432 (defun rinari-bind-key-to-func (key func)
433 (eval `(define-key rinari-minor-mode-map
434 ,(format "\C-c;%s" key) ,func))
435 (eval `(define-key rinari-minor-mode-map
436 ,(format "\C-c'%s" key) ,func)))
437
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
438 (defvar rinari-minor-mode-keybindings
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
439 '(("s" . 'rinari-script)
440 ("e" . 'rinari-insert-erb-skeleton) ("t" . 'rinari-test)
441 ("r" . 'rinari-rake) ("c" . 'rinari-console)
442 ("w" . 'rinari-web-server) ("g" . 'rinari-rgrep)
443 ("b" . 'rinari-browse-url) ("q" . 'rinari-sql))
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
444 "alist mapping of keys to functions in `rinari-minor-mode'")
445
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
446 (mapcar (lambda (el) (rinari-bind-key-to-func (car el) (cdr el)))
447 (append (mapcar (lambda (el)
448 (cons (concat "f" (second el))
449 (read (format "'rinari-find-%S" (first el)))))
450 rinari-jump-schema)
451 rinari-minor-mode-keybindings))
5d906bd8 » Eric Schulte
2008-06-17 rinari is now a minor mode
452
b446c479 » Eric Schulte
2008-06-18 cleaned up, ready for pull-request
453 (defun rinari-launch ()
b02f6c60 »
2008-08-18 Add `rinari-minor-mode-hook' for customization. Make some variables b…
454 "Run `rinari-minor-mode' if inside of a rails projecct,
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
455 otherwise turn `rinari-minor-mode' off if it is on."
9c51fe76 » eschulte
2008-06-24 cleaner, smaller, and more useful...
456 (interactive)
e71be827 » eschulte
2008-07-15 - added rinari-tags-file-name for using tags in a rails project
457 (let* ((root (rinari-root)) (r-tags-path (concat root rinari-tags-file-name)))
b02f6c60 »
2008-08-18 Add `rinari-minor-mode-hook' for customization. Make some variables b…
458 (when root
459 (set (make-local-variable 'tags-file-name)
460 (and (file-exists-p r-tags-path) r-tags-path))
461 (run-hooks 'rinari-minor-mode-hook)
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
462 (rinari-minor-mode t))))
5d906bd8 » Eric Schulte
2008-06-17 rinari is now a minor mode
463
99684c3e » eschulte
2008-07-21 now finds missing models with rinari-find-model
464 (defvar rinari-major-modes
d5da5fa2 » eschulte
2008-08-23 Big Changes... (cleaner/smaller/hackable code and new/reliable/custom…
465 '('find-file-hook 'mumamo-after-change-major-mode-hook 'dired-mode-hook)
99684c3e » eschulte
2008-07-21 now finds missing models with rinari-find-model
466 "Major Modes from which to launch Rinari.")
b446c479 » Eric Schulte
2008-06-18 cleaned up, ready for pull-request
467
99684c3e » eschulte
2008-07-21 now finds missing models with rinari-find-model
468 (mapcar (lambda (hook)
469 (eval `(add-hook ,hook
470 (lambda () (rinari-launch)))))
471 rinari-major-modes)
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
472
473 (defadvice cd (after rinari-on-cd activate)
474 "Active/Deactive rinari-minor-node when changing into and out
7db851b6 » eschulte
2008-06-30 added ruby-compilation minor mode, added rinari-sql for browsing rail…
475 of raills project directories."
f505236b » eschulte
2008-06-27 stabilized minor-mode toggling and buffer poping, and added rinari-ru…
476 (rinari-launch))
477
739e9aec » eschulte
2008-07-08 Last big commit for a while (should be stable)
478 ;;;###autoload
5d906bd8 » Eric Schulte
2008-06-17 rinari is now a minor mode
479 (define-minor-mode rinari-minor-mode
480 "Enable Rinari minor mode providing Emacs support for working
481 with the Ruby on Rails framework."
482 nil
483 " Rinari"
484 rinari-minor-mode-map)
bfb626a1 »
2008-05-13 Initial import of rinari 2
485
486 (provide 'rinari)
487 ;;; rinari.el ends here
Something went wrong with that request. Please try again.