module Masshtab class DatabaseGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) class_option :mysql_with_sqlite, type: :boolean, default: false, desc: 'configure to sqlite on darwin and to mysql on others' class_option :application_name, type: :string, default: Rails.application.class.parent_name.underscore, desc: 'Rails application name' def mysql2_gem gem 'sqlite3' if options[:mysql_with_sqlite] gem 'mysql2' end def database_yml if options[:mysql_with_sqlite] template 'mysql_with_sqlite.yml', Rails.root.join('config', 'database.yml') else template 'mysql.yml', Rails.root.join('config', 'database.yml') end end end end