Created
June 30, 2009 14:18
-
-
Save mikehale/138174 to your computer and use it in GitHub Desktop.
Revisions
-
mikehale renamed this gist
Jun 30, 2009 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mikehale created this gist
Jun 30, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ class DatabaseYml < Thor FILE = 'config/database.yml' desc "mysql db_name", "create a database.yml for the named mysql database" method_options :force => :boolean def mysql(name) yml = %( env: &env adapter: mysql encoding: utf8 username: root password: host: localhost development: <<: *env database: #{name}_development test: <<: *env database: #{name}_test production: <<: *env database: #{name}_production ).lstrip! create_file(yml, options) end desc "sqlite", "create a database.yml for sqlite3" method_options :force => :boolean def sqlite yml = %( env: &env adapter: sqlite3 timeout: 5000 development: <<: *env database: db/development.sqlite3 test: <<: *env database: db/test.sqlite3 production: <<: *env database: db/production.sqlite3 ).lstrip! create_file(yml, options) end def create_file(yml, options) if (!File.exists?(FILE) || File.exists?(FILE) && options.force?) File.open(FILE, 'w+') do |f| f.print yml end end end end