Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c825e9a5
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,发现更多精彩内容 >>
提交
c825e9a5
编写于
3月 10, 2012
作者:
C
Carlos Antonio da Silva
提交者:
Santiago Pastorino
3月 14, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create generators http_only! setup and hide some common namespaces for now
[Carlos Antonio da Silva & Santiago Pastorino]
上级
124838b5
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
42 addition
and
4 deletion
+42
-4
railties/lib/rails/configuration.rb
railties/lib/rails/configuration.rb
+11
-3
railties/lib/rails/generators.rb
railties/lib/rails/generators.rb
+7
-1
railties/test/generators_test.rb
railties/test/generators_test.rb
+24
-0
未找到文件。
railties/lib/rails/configuration.rb
浏览文件 @
c825e9a5
...
@@ -44,14 +44,14 @@ module Configuration
...
@@ -44,14 +44,14 @@ module Configuration
# Cookies, Session and Flash, BestStandardsSupport, and MethodOverride. You
# Cookies, Session and Flash, BestStandardsSupport, and MethodOverride. You
# can always add any of them later manually if you want.
# can always add any of them later manually if you want.
class
MiddlewareStackProxy
class
MiddlewareStackProxy
attr_reader
:http_only
alias
:http_only?
:http_only
def
initialize
def
initialize
@operations
=
[]
@operations
=
[]
@http_only
=
false
@http_only
=
false
end
end
attr_reader
:http_only
alias
:http_only?
:http_only
def
http_only!
def
http_only!
@http_only
=
true
@http_only
=
true
end
end
...
@@ -90,6 +90,9 @@ class Generators #:nodoc:
...
@@ -90,6 +90,9 @@ class Generators #:nodoc:
attr_accessor
:aliases
,
:options
,
:templates
,
:fallbacks
,
:colorize_logging
attr_accessor
:aliases
,
:options
,
:templates
,
:fallbacks
,
:colorize_logging
attr_reader
:hidden_namespaces
attr_reader
:hidden_namespaces
attr_reader
:http_only
alias
:http_only?
:http_only
def
initialize
def
initialize
@aliases
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
{}
}
@aliases
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
{}
}
@options
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
{}
}
@options
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
{}
}
...
@@ -97,6 +100,7 @@ def initialize
...
@@ -97,6 +100,7 @@ def initialize
@templates
=
[]
@templates
=
[]
@colorize_logging
=
true
@colorize_logging
=
true
@hidden_namespaces
=
[]
@hidden_namespaces
=
[]
@http_only
=
false
end
end
def
initialize_copy
(
source
)
def
initialize_copy
(
source
)
...
@@ -110,6 +114,10 @@ def hide_namespace(namespace)
...
@@ -110,6 +114,10 @@ def hide_namespace(namespace)
@hidden_namespaces
<<
namespace
@hidden_namespaces
<<
namespace
end
end
def
http_only!
@http_only
=
true
end
def
method_missing
(
method
,
*
args
)
def
method_missing
(
method
,
*
args
)
method
=
method
.
to_s
.
sub
(
/=$/
,
''
).
to_sym
method
=
method
.
to_s
.
sub
(
/=$/
,
''
).
to_sym
...
...
railties/lib/rails/generators.rb
浏览文件 @
c825e9a5
...
@@ -68,6 +68,7 @@ def self.configure!(config) #:nodoc:
...
@@ -68,6 +68,7 @@ def self.configure!(config) #:nodoc:
templates_path
.
concat
config
.
templates
templates_path
.
concat
config
.
templates
templates_path
.
uniq!
templates_path
.
uniq!
hide_namespaces
(
*
config
.
hidden_namespaces
)
hide_namespaces
(
*
config
.
hidden_namespaces
)
http_only!
if
config
.
http_only?
end
end
def
self
.
templates_path
def
self
.
templates_path
...
@@ -104,6 +105,11 @@ def self.no_color!
...
@@ -104,6 +105,11 @@ def self.no_color!
Thor
::
Base
.
shell
=
Thor
::
Shell
::
Basic
Thor
::
Base
.
shell
=
Thor
::
Shell
::
Basic
end
end
# Configure generators for http only
def
self
.
http_only!
hide_namespaces
"assets"
,
"css"
,
"js"
,
"session_migration"
end
# Track all generators subclasses.
# Track all generators subclasses.
def
self
.
subclasses
def
self
.
subclasses
@subclasses
||=
[]
@subclasses
||=
[]
...
@@ -235,7 +241,7 @@ def self.help(command = 'generate')
...
@@ -235,7 +241,7 @@ def self.help(command = 'generate')
rails
.
delete
(
"plugin_new"
)
rails
.
delete
(
"plugin_new"
)
print_list
(
"rails"
,
rails
)
print_list
(
"rails"
,
rails
)
hidden_namespaces
.
each
{
|
n
|
groups
.
delete
(
n
.
to_s
)
}
hidden_namespaces
.
each
{
|
n
|
groups
.
delete
(
n
.
to_s
)
}
groups
.
sort
.
each
{
|
b
,
n
|
print_list
(
b
,
n
)
}
groups
.
sort
.
each
{
|
b
,
n
|
print_list
(
b
,
n
)
}
end
end
...
...
railties/test/generators_test.rb
浏览文件 @
c825e9a5
...
@@ -213,4 +213,28 @@ def test_hide_namespace
...
@@ -213,4 +213,28 @@ def test_hide_namespace
Rails
::
Generators
.
hide_namespace
(
"special:namespace"
)
Rails
::
Generators
.
hide_namespace
(
"special:namespace"
)
assert
Rails
::
Generators
.
hidden_namespaces
.
include?
(
"special:namespace"
)
assert
Rails
::
Generators
.
hidden_namespaces
.
include?
(
"special:namespace"
)
end
end
def
test_http_only_hides_generators
generators
=
%w(assets js css session_migration)
generators
.
each
do
|
generator
|
assert
!
Rails
::
Generators
.
hidden_namespaces
.
include?
(
generator
)
end
with_http_only!
do
generators
.
each
do
|
generator
|
assert
Rails
::
Generators
.
hidden_namespaces
.
include?
(
generator
),
"http only should hide
#{
generator
}
generator"
end
end
end
private
def
with_http_only!
Rails
::
Generators
.
http_only!
yield
ensure
Rails
::
Generators
.
instance_variable_set
(
:@http_only
,
false
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录