Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
79376e3c
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
79376e3c
编写于
2月 04, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update Gemfile to use latest bundler config.
上级
ab14e3f8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
20 deletion
+33
-20
railties/lib/generators/rails/app/app_generator.rb
railties/lib/generators/rails/app/app_generator.rb
+21
-15
railties/lib/generators/rails/app/templates/Gemfile
railties/lib/generators/rails/app/templates/Gemfile
+5
-5
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+7
-0
未找到文件。
railties/lib/generators/rails/app/app_generator.rb
浏览文件 @
79376e3c
...
...
@@ -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
...
...
railties/lib/generators/rails/app/templates/Gemfile
浏览文件 @
79376e3c
...
...
@@ -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
railties/test/generators/app_generator_test.rb
浏览文件 @
79376e3c
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录