0
@@ -272,6 +272,38 @@ editing of the url."
0
(eval (list rinari-browse-url-func url))))
0
+(defun rinari-parse-yaml ()
0
+ (end (save-excursion (re-search-forward "^$" nil t) (point)))
0
+ (while (and (< (point) end)
0
+ (re-search-forward "^ *\\(.*\\): \\(.*\\)$" nil t))
0
+ (setf alist (cons (cons (match-string 1) (match-string 2)) alist)))
0
+ "Browse the application's database."
0
+ (let* ((environment (or (getenv "RAILS_ENV") "development"))
0
+ (database-alist (save-excursion
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
+ (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
(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
(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
+(add-hook 'yaml-mode-hook
0
+ (lambda () (rinari-launch)))
0
(add-hook 'mumamo-after-change-major-mode-hook
0
(lambda () (rinari-launch)))
0
@@ -335,7 +370,7 @@ otherwise turn `rinari-minor-mode' off if it is on."
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
(define-minor-mode rinari-minor-mode
Comments
No one has commented yet.