Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
9cf38be0
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,发现更多精彩内容 >>
提交
9cf38be0
编写于
12月 20, 2011
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get rid of --old-style-hash
上级
500ca98f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
6 addition
and
58 deletion
+6
-58
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+2
-10
railties/lib/rails/generators/named_base.rb
railties/lib/rails/generators/named_base.rb
+0
-3
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+1
-12
railties/test/generators/mailer_generator_test.rb
railties/test/generators/mailer_generator_test.rb
+2
-21
railties/test/generators/scaffold_controller_generator_test.rb
...ies/test/generators/scaffold_controller_generator_test.rb
+1
-12
未找到文件。
railties/lib/rails/generators/app_base.rb
浏览文件 @
9cf38be0
...
...
@@ -60,9 +60,6 @@ def self.add_shared_options_for(name)
class_option
:help
,
:type
=>
:boolean
,
:aliases
=>
"-h"
,
:group
=>
:rails
,
:desc
=>
"Show this help message and quit"
class_option
:old_style_hash
,
:type
=>
:boolean
,
:default
=>
false
,
:desc
=>
"Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
end
def
initialize
(
*
args
)
...
...
@@ -255,14 +252,9 @@ def git_keep(destination)
create_file
(
"
#{
destination
}
/.gitkeep"
)
unless
options
[
:skip_git
]
end
# Returns Ruby 1.9 style key-value pair if current code is running on
# Ruby 1.9.x. Returns the old-style (with hash rocket) otherwise.
# Returns Ruby 1.9 style key-value pair.
def
key_value
(
key
,
value
)
if
options
[
:old_style_hash
]
||
RUBY_VERSION
<
'1.9'
":
#{
key
}
=>
#{
value
}
"
else
"
#{
key
}
:
#{
value
}
"
end
"
#{
key
}
:
#{
value
}
"
end
end
end
...
...
railties/lib/rails/generators/named_base.rb
浏览文件 @
9cf38be0
...
...
@@ -9,9 +9,6 @@ class NamedBase < Base
class_option
:skip_namespace
,
:type
=>
:boolean
,
:default
=>
false
,
:desc
=>
"Skip namespace (affects only isolated applications)"
class_option
:old_style_hash
,
:type
=>
:boolean
,
:default
=>
false
,
:desc
=>
"Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
def
initialize
(
args
,
*
options
)
#:nodoc:
@inside_template
=
nil
# Unfreeze name in case it's given as a frozen string
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
9cf38be0
...
...
@@ -337,18 +337,7 @@ def test_no_active_record_or_test_unit_if_skips_given
def
test_new_hash_style
run_generator
[
destination_root
]
assert_file
"config/initializers/session_store.rb"
do
|
file
|
if
RUBY_VERSION
<
"1.9"
assert_match
(
/config.session_store :cookie_store, :key => '_.+_session'/
,
file
)
else
assert_match
(
/config.session_store :cookie_store, key: '_.+_session'/
,
file
)
end
end
end
def
test_force_old_style_hash
run_generator
[
destination_root
,
"--old-style-hash"
]
assert_file
"config/initializers/session_store.rb"
do
|
file
|
assert_match
(
/config.session_store :cookie_store, :key => '_.+_session'/
,
file
)
assert_match
(
/config.session_store :cookie_store, key: '_.+_session'/
,
file
)
end
end
...
...
railties/test/generators/mailer_generator_test.rb
浏览文件 @
9cf38be0
...
...
@@ -77,33 +77,14 @@ def test_actions_are_turned_into_methods
assert_file
"app/mailers/notifier.rb"
do
|
mailer
|
assert_instance_method
:foo
,
mailer
do
|
foo
|
if
RUBY_VERSION
<
"1.9"
assert_match
(
/mail :to => "to@example.org"/
,
foo
)
else
assert_match
(
/mail to: "to@example.org"/
,
foo
)
end
assert_match
(
/mail to: "to@example.org"/
,
foo
)
assert_match
(
/@greeting = "Hi"/
,
foo
)
end
assert_instance_method
:bar
,
mailer
do
|
bar
|
if
RUBY_VERSION
<
"1.9"
assert_match
(
/mail :to => "to@example.org"/
,
bar
)
else
assert_match
(
/mail to: "to@example.org"/
,
bar
)
end
assert_match
(
/mail to: "to@example.org"/
,
bar
)
assert_match
(
/@greeting = "Hi"/
,
bar
)
end
end
end
def
test_force_old_style_hash
run_generator
[
"notifier"
,
"foo"
,
"--old-style-hash"
]
assert_file
"app/mailers/notifier.rb"
do
|
mailer
|
assert_match
(
/default :from => "from@example.com"/
,
mailer
)
assert_instance_method
:foo
,
mailer
do
|
foo
|
assert_match
(
/mail :to => "to@example.org"/
,
foo
)
end
end
end
end
railties/test/generators/scaffold_controller_generator_test.rb
浏览文件 @
9cf38be0
...
...
@@ -126,18 +126,7 @@ def self.all(klass)
def
test_new_hash_style
run_generator
assert_file
"app/controllers/users_controller.rb"
do
|
content
|
if
RUBY_VERSION
<
"1.9"
assert_match
(
/\{ render :action => "new" \}/
,
content
)
else
assert_match
(
/\{ render action: "new" \}/
,
content
)
end
end
end
def
test_force_old_style_hash
run_generator
[
"User"
,
"--old-style-hash"
]
assert_file
"app/controllers/users_controller.rb"
do
|
content
|
assert_match
(
/\{ render :action => "new" \}/
,
content
)
assert_match
(
/\{ render action: "new" \}/
,
content
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录