eschulte / rinari

Rinari Is Not A Rails IDE (it is an Emacs minor mode for Rails)
http://rinari.rubyforge.org
GNU General Public License v3.0
412 stars 68 forks source link

Improved parsing of database.yml #87

Closed erw7 closed 9 years ago

erw7 commented 9 years ago

Corresponding to the parsing of the reference with the anchor/aliases rails 4.2 to generate the next database.yml

default: &default
  adapter: postgresql
...

development:
  <<: *default
  database: depot_development

Fixed a bug that parsing is terminate by a comment line or empty line

development:
  database: depot_development
  # comment

  username: root

rinari-parse-yaml return (("database" . "depot_development")), but (("database" . "depot_development") ("username" . "root")) is correct.

Fixed a bug that include comment and trailing spaces on the value

development:
  database: depot_development # comment
  username: root     

rinari-parse-yaml return (("database" . "depot_development # comment") ("username" . "root     ")), but (("database" . "depot_development") ("username" . "root")) is correct.

purcell commented 9 years ago

Thanks! I decided that it might be better to just ask Ruby to handle this for us, so I committed 4862bb4 in place of this fix. Let me know if you have any problems with my fix. :)

erw7 commented 9 years ago

Thanks. Your code is more elegant than me code and work fine.

erw7 commented 9 years ago

rinari-sql fails with (wrong-type-argument sequencep 5432), if defined port in database.yml. We need number-to-string.

--- a/rinari.el
+++ b/rinari.el
@@ -425,7 +425,7 @@ Looks up login information from your conf/database.sql file."
           (when (string-match-p "sqlite" adapter)
             ;; Always expand sqlite DB filename relative to RAILS_ROOT
             (setq sql-database (expand-file-name sql-database (rinari-root))))
-          (set (make-local-variable 'sql-server) (if port (concat server ":" port) server))
+          (set (make-local-variable 'sql-server) (if port (concat server ":" (number-to-string port)) server))
           (funcall
            (intern (concat "sql-"
                            (cond
purcell commented 9 years ago

Done - thanks.