public
Description: Rinari Is Not A Rails IDE
Homepage: http://rinari.rubyforge.org
Clone URL: git://github.com/technomancy/rinari.git
added ruby-compilation minor mode, added rinari-sql for browsing rails 
database
eschulte (author)
Mon Jun 30 12:00:39 -0700 2008
commit  7db851b636e8152de9f3a1487ac4a2ab581c2fba
tree    b6671e5b02b746947ebd664f5040c639483cad97
parent  47ce62ce3fa238eea21bfb5d8f449c518e81b51d
...
272
273
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
276
277
...
295
296
297
298
 
299
300
301
...
327
328
329
 
 
 
330
331
332
...
335
336
337
338
 
339
340
341
...
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
...
327
328
329
 
330
331
332
333
...
359
360
361
362
363
364
365
366
367
...
370
371
372
 
373
374
375
376
0
@@ -272,6 +272,38 @@ editing of the url."
0
     base)))
0
     (eval (list rinari-browse-url-func url))))
0
 
0
+(defun rinari-parse-yaml ()
0
+ (let ((start (point))
0
+ (end (save-excursion (re-search-forward "^$" nil t) (point)))
0
+ alist)
0
+ (while (and (< (point) end)
0
+ (re-search-forward "^ *\\(.*\\): \\(.*\\)$" nil t))
0
+ (setf alist (cons (cons (match-string 1) (match-string 2)) alist)))
0
+ alist))
0
+
0
+(defun rinari-sql ()
0
+ "Browse the application's database."
0
+ (interactive)
0
+ (let* ((environment (or (getenv "RAILS_ENV") "development"))
0
+ (database-alist (save-excursion
0
+ (with-temp-buffer
0
+ (insert-file (concat (rinari-root)
0
+ "/config/database.yml"))
0
+ (goto-char (point-min))
0
+ (re-search-forward (concat "^" environment ":"))
0
+ (rinari-parse-yaml))))
0
+ (adapter (or (cdr (assoc "adapter" database-alist)) "sqlite"))
0
+ (sql-user (or (cdr (assoc "username" database-alist)) "root"))
0
+ (sql-password (or (cdr (assoc "password" database-alist)) ""))
0
+ (sql-database (or (cdr (assoc "database" database-alist))
0
+ (concat (file-name-nondirectory (rinari-root))
0
+ "_" environment)))
0
+ (server (or (cdr (assoc "host" database-alist)) "localhost"))
0
+ (port (cdr (assoc "port" database-alist)))
0
+ (sql-server (if port (concat server ":" port) server)))
0
+ (if (string-match "sqlite" adapter) (setf adapter "sqlite"))
0
+ (eval (list (intern (concat "sql-" adapter)))) (rinari-launch)))
0
+
0
 (defun rinari-run-what (&optional arg)
0
   "Allows the user to run a function selected from amongst all of
0
 the rinari functions displaying their names and keybindings."
0
@@ -295,7 +327,7 @@ the rinari functions displaying their names and keybindings."
0
   "Key map for Rinari minor mode.")
0
 
0
 (defvar rinari-minor-mode-keybindings
0
- '(("\t" . 'rinari-run-what) ("o" . 'toggle-buffer)
0
+ '(("\t" . 'rinari-run-what) ("o" . 'toggle-buffer) ("s" . 'rinari-sql)
0
     ("e" . 'rinari-insert-erb-skeleton) ("t" . 'rinari-test-function)
0
     ("r" . 'rinari-rake) ("c" . 'rinari-console) ("b" . 'rinari-browse-view)
0
     ("v" . 'rinari-find-view) ("a" . 'rinari-find-action) ("w" . 'rinari-server))
0
@@ -327,6 +359,9 @@ otherwise turn `rinari-minor-mode' off if it is on."
0
 (add-hook 'ruby-mode-hook
0
    (lambda () (rinari-launch)))
0
 
0
+(add-hook 'yaml-mode-hook
0
+ (lambda () (rinari-launch)))
0
+
0
 (add-hook 'mumamo-after-change-major-mode-hook
0
    (lambda () (rinari-launch)))
0
 
0
@@ -335,7 +370,7 @@ otherwise turn `rinari-minor-mode' off if it is on."
0
 
0
 (defadvice cd (after rinari-on-cd activate)
0
   "Active/Deactive rinari-minor-node when changing into and out
0
- of raills project directories"
0
+ of raills project directories."
0
   (rinari-launch))
0
 
0
 (define-minor-mode rinari-minor-mode
...
25
26
27
28
 
29
30
31
32
 
33
34
35
...
69
70
71
72
73
 
 
74
75
76
 
77
78
79
 
80
81
82
83
84
85
86
87
88
89
 
90
91
92
...
120
121
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
124
125
...
25
26
27
 
28
29
30
31
 
32
33
34
35
...
69
70
71
 
 
72
73
74
75
 
76
77
 
 
78
79
80
81
82
83
 
 
 
 
 
84
85
86
87
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
0
@@ -25,11 +25,11 @@
0
 ;; compilation buffer. Useful for executing tests, or rake tasks
0
 ;; where the ability to jump to errors in source code is desirable.
0
 ;;
0
-;; The functions you will probably want to use are...
0
+;; The functions you will probably want to use are
0
 ;;
0
 ;; ruby-run-w/compilation
0
 ;; ruby-rake-w/compilation
0
-;;
0
+;;
0
 
0
 ;;; Code:
0
 (require 'ansi-color)
0
@@ -69,24 +69,19 @@
0
       (if (get-buffer comp-buffer-name) (kill-buffer comp-buffer-name))
0
       (let* ((buffer (apply 'make-comint name (car cmdlist) nil (cdr cmdlist)))
0
    (proc (get-buffer-process buffer)))
0
- (save-excursion ;; set buffer local variables
0
- (set-buffer buffer)
0
+ (save-excursion
0
+ (set-buffer buffer) ;; set buffer local variables and process ornaments
0
    (set-process-sentinel proc 'ruby-compilation-sentinel)
0
    (set-process-filter proc 'ruby-compilation-insertion-filter)
0
- (set (make-variable-buffer-local 'compilation-error-regexp-alist)
0
+ (set (make-local-variable 'compilation-error-regexp-alist)
0
    ruby-compilation-error-regexp-alist)
0
- (define-key compilation-minor-mode-map (kbd "C-c C-c") 'comint-interrupt-subjob)
0
- (set (make-variable-buffer-local 'kill-buffer-hook)
0
+ (set (make-local-variable 'kill-buffer-hook)
0
    (lambda ()
0
      (let ((orphan-proc (get-buffer-process (buffer-name))))
0
      (if orphan-proc
0
      (kill-process orphan-proc)))))
0
    (compilation-minor-mode)
0
- ;; bind keys (maybe should be implemented as a ruby-compilation minor mode)
0
- (local-set-key "p" 'previous-error-no-select)
0
- (local-set-key "n" 'next-error-no-select)
0
- (local-set-key "\M-p" 'ruby-compilation-previous-error-group)
0
- (local-set-key "\M-n" 'ruby-compilation-next-error-group))))
0
+ (ruby-compilation-minor-mode))))
0
     comp-buffer-name))
0
 
0
 (defun ruby-compilation-insertion-filter (proc string)
0
@@ -120,5 +115,24 @@ compilation buffer."
0
     (forward-line 1))
0
   (compilation-next-error 1) (recenter))
0
 
0
+;; minor mode
0
+(defvar ruby-compilation-minor-mode-map
0
+ (let ((map (make-sparse-keymap)))
0
+ map)
0
+ "Key map for Ruby Compilation minor mode.")
0
+
0
+(define-key ruby-compilation-minor-mode-map "p" 'previous-error-no-select)
0
+(define-key ruby-compilation-minor-mode-map "n" 'next-error-no-select)
0
+(define-key ruby-compilation-minor-mode-map "\M-p" 'ruby-compilation-previous-error-group)
0
+(define-key ruby-compilation-minor-mode-map "\M-n" 'ruby-compilation-next-error-group)
0
+(define-key ruby-compilation-minor-mode-map (kbd "C-c C-c") 'comint-interrupt-subjob)
0
+
0
+(define-minor-mode ruby-compilation-minor-mode
0
+ "Enable Ruby Compilation minor mode providing some key-bindings
0
+ for navigating ruby compilation buffers."
0
+ nil
0
+ " Ruby:Comp"
0
+ ruby-compilation-minor-mode-map)
0
+
0
 (provide 'ruby-compilation)
0
 ;;; ruby-compilation.el ends here
0
\ No newline at end of file

Comments

    No one has commented yet.