提交 79376e3c 编写于 作者: J José Valim

Update Gemfile to use latest bundler config.

上级 ab14e3f8
......@@ -9,6 +9,8 @@ module Rails::Generators
class AppGenerator < Base
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
attr_accessor :rails_template
add_shebang_option!
argument :app_path, :type => :string
......@@ -90,18 +92,6 @@ def create_boot_file
template "config/boot.rb"
end
def gem_for_database
# %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
case options[:database]
when "mysql" then "mysql"
when "oracle" then "ruby-oci8"
when "postgresql" then "pg"
when "sqlite3" then "sqlite3-ruby"
when "frontbase" then "ruby-frontbase"
when "ibm_db" then "ibm_db"
end
end
def create_activerecord_files
return if options[:skip_activerecord]
template "config/databases/#{options[:database]}.yml", "config/database.yml"
......@@ -185,7 +175,10 @@ def bundle_if_dev_or_edge
end
protected
attr_accessor :rails_template
def self.banner
"rails #{self.arguments.map(&:usage).join(' ')} [options]"
end
def set_default_accessors!
self.rails_template = case options[:template]
......@@ -230,8 +223,21 @@ def dev_or_edge?
options.dev? || options.edge?
end
def self.banner
"#{$0} #{self.arguments.map(&:usage).join(' ')} [options]"
def gem_for_database
# %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
case options[:database]
when "oracle" then "ruby-oci8"
when "postgresql" then "pg"
when "sqlite3" then "sqlite3-ruby"
when "frontbase" then "ruby-frontbase"
else options[:database]
end
end
def require_for_database
case options[:database]
when "sqlite3" then "sqlite3"
end
end
def mysql_socket
......
......@@ -18,17 +18,17 @@ gem "rails", "<%= Rails::VERSION::STRING %>"
# ActiveRecord requires a database adapter. By default,
# Rails has selected sqlite3.
<% end -%>
gem "<%= gem_for_database %>"
gem "<%= gem_for_database %>"<% if require_for_database %>, :require => "<%= require_for_database %>"<% end %>
<% end -%>
## Bundle the gems you use:
# gem "bj"
# gem "hpricot", "0.6"
# gem "sqlite3-ruby", :require_as => "sqlite3"
# gem "aws-s3", :require_as => "aws/s3"
# gem "sqlite3-ruby", :require => "sqlite3"
# gem "aws-s3", :require => "aws/s3"
## Bundle gems used only in certain environments:
# gem "rspec", :only => :test
# only :test do
# gem "rspec", :group => :test
# group :test do
# gem "webrat"
# end
......@@ -74,6 +74,13 @@ def test_application_names_are_not_singularized
def test_config_database_is_added_by_default
run_generator
assert_file "config/database.yml", /sqlite3/
assert_file "Gemfile", /^gem "sqlite3-ruby", :require => "sqlite3"$/
end
def test_config_another_database
run_generator([destination_root, "-d", "mysql"])
assert_file "config/database.yml", /mysql/
assert_file "Gemfile", /^gem "mysql"$/
end
def test_config_database_is_not_added_if_skip_activerecord_is_given
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册