Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
cc789ddc
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,发现更多精彩内容 >>
提交
cc789ddc
编写于
3月 04, 2010
作者:
C
Carl Lerche
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
No need for a module if it's only being included once into an empty class.
上级
0de3b9ec
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
95 deletion
+91
-95
railties/lib/rails/configuration.rb
railties/lib/rails/configuration.rb
+0
-94
railties/lib/rails/railtie/configuration.rb
railties/lib/rails/railtie/configuration.rb
+91
-1
未找到文件。
railties/lib/rails/configuration.rb
浏览文件 @
cc789ddc
...
...
@@ -4,100 +4,6 @@
module
Rails
module
Configuration
module
Shared
def
middleware
@@default_middleware_stack
||=
default_middleware
end
# Holds generators configuration:
#
# config.generators do |g|
# g.orm :datamapper, :migration => true
# g.template_engine :haml
# g.test_framework :rspec
# end
#
# If you want to disable color in console, do:
#
# config.generators.colorize_logging = false
#
def
generators
@@generators
||=
Rails
::
Configuration
::
Generators
.
new
if
block_given?
yield
@@generators
else
@@generators
end
end
def
after_initialize_blocks
@@after_initialize_blocks
||=
[]
end
def
after_initialize
(
&
blk
)
after_initialize_blocks
<<
blk
if
blk
end
def
to_prepare_blocks
@@to_prepare_blocks
||=
[]
end
def
to_prepare
(
&
blk
)
to_prepare_blocks
<<
blk
if
blk
end
def
respond_to?
(
name
)
super
||
name
.
to_s
=~
config_key_regexp
end
def
metal_loader
@metal_loader
||=
Rails
::
Application
::
MetalLoader
.
new
end
private
def
method_missing
(
name
,
*
args
,
&
blk
)
if
name
.
to_s
=~
config_key_regexp
return
$2
==
'='
?
options
[
$1
]
=
args
.
first
:
options
[
$1
]
end
super
end
def
config_key_regexp
bits
=
config_keys
.
map
{
|
n
|
Regexp
.
escape
(
n
.
to_s
)
}.
join
(
'|'
)
/^(
#{
bits
}
)(?:=)?$/
end
def
config_keys
(
Railtie
.
railtie_names
+
Engine
.
engine_names
).
map
{
|
n
|
n
.
to_s
}.
uniq
end
def
options
@@options
||=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
ActiveSupport
::
OrderedOptions
.
new
}
end
def
default_middleware
require
'action_dispatch'
ActionDispatch
::
MiddlewareStack
.
new
.
tap
do
|
middleware
|
middleware
.
use
(
'::ActionDispatch::Static'
,
lambda
{
Rails
.
public_path
},
:if
=>
lambda
{
serve_static_assets
})
middleware
.
use
(
'::Rack::Lock'
,
:if
=>
lambda
{
!
allow_concurrency
})
middleware
.
use
(
'::Rack::Runtime'
)
middleware
.
use
(
'::Rails::Rack::Logger'
)
middleware
.
use
(
'::ActionDispatch::ShowExceptions'
,
lambda
{
consider_all_requests_local
})
middleware
.
use
(
"::ActionDispatch::RemoteIp"
,
lambda
{
action_dispatch
.
ip_spoofing_check
},
lambda
{
action_dispatch
.
trusted_proxies
})
middleware
.
use
(
'::Rack::Sendfile'
,
lambda
{
action_dispatch
.
x_sendfile_header
})
middleware
.
use
(
'::ActionDispatch::Callbacks'
,
lambda
{
!
cache_classes
})
middleware
.
use
(
'::ActionDispatch::Cookies'
)
middleware
.
use
(
lambda
{
ActionController
::
SessionManagement
.
session_store_for
(
action_controller
.
session_store
)
},
lambda
{
action_controller
.
session
})
middleware
.
use
(
'::ActionDispatch::Flash'
,
:if
=>
lambda
{
action_controller
.
session_store
})
middleware
.
use
(
lambda
{
metal_loader
.
build_middleware
(
metals
)
},
:if
=>
lambda
{
metal_loader
.
metals
.
any?
})
middleware
.
use
(
'ActionDispatch::ParamsParser'
)
middleware
.
use
(
'::Rack::MethodOverride'
)
middleware
.
use
(
'::ActionDispatch::Head'
)
end
end
end
class
Generators
#:nodoc:
attr_accessor
:aliases
,
:options
,
:templates
,
:fallbacks
,
:colorize_logging
...
...
railties/lib/rails/railtie/configuration.rb
浏览文件 @
cc789ddc
...
...
@@ -3,7 +3,97 @@
module
Rails
class
Railtie
class
Configuration
include
Rails
::
Configuration
::
Shared
def
middleware
@@default_middleware_stack
||=
default_middleware
end
# Holds generators configuration:
#
# config.generators do |g|
# g.orm :datamapper, :migration => true
# g.template_engine :haml
# g.test_framework :rspec
# end
#
# If you want to disable color in console, do:
#
# config.generators.colorize_logging = false
#
def
generators
@@generators
||=
Rails
::
Configuration
::
Generators
.
new
if
block_given?
yield
@@generators
else
@@generators
end
end
def
after_initialize_blocks
@@after_initialize_blocks
||=
[]
end
def
after_initialize
(
&
blk
)
after_initialize_blocks
<<
blk
if
blk
end
def
to_prepare_blocks
@@to_prepare_blocks
||=
[]
end
def
to_prepare
(
&
blk
)
to_prepare_blocks
<<
blk
if
blk
end
def
respond_to?
(
name
)
super
||
name
.
to_s
=~
config_key_regexp
end
def
metal_loader
@metal_loader
||=
Rails
::
Application
::
MetalLoader
.
new
end
private
def
method_missing
(
name
,
*
args
,
&
blk
)
if
name
.
to_s
=~
config_key_regexp
return
$2
==
'='
?
options
[
$1
]
=
args
.
first
:
options
[
$1
]
end
super
end
def
config_key_regexp
bits
=
config_keys
.
map
{
|
n
|
Regexp
.
escape
(
n
.
to_s
)
}.
join
(
'|'
)
/^(
#{
bits
}
)(?:=)?$/
end
def
config_keys
(
Railtie
.
railtie_names
+
Engine
.
engine_names
).
map
{
|
n
|
n
.
to_s
}.
uniq
end
def
options
@@options
||=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
ActiveSupport
::
OrderedOptions
.
new
}
end
def
default_middleware
require
'action_dispatch'
ActionDispatch
::
MiddlewareStack
.
new
.
tap
do
|
middleware
|
middleware
.
use
(
'::ActionDispatch::Static'
,
lambda
{
Rails
.
public_path
},
:if
=>
lambda
{
serve_static_assets
})
middleware
.
use
(
'::Rack::Lock'
,
:if
=>
lambda
{
!
allow_concurrency
})
middleware
.
use
(
'::Rack::Runtime'
)
middleware
.
use
(
'::Rails::Rack::Logger'
)
middleware
.
use
(
'::ActionDispatch::ShowExceptions'
,
lambda
{
consider_all_requests_local
})
middleware
.
use
(
"::ActionDispatch::RemoteIp"
,
lambda
{
action_dispatch
.
ip_spoofing_check
},
lambda
{
action_dispatch
.
trusted_proxies
})
middleware
.
use
(
'::Rack::Sendfile'
,
lambda
{
action_dispatch
.
x_sendfile_header
})
middleware
.
use
(
'::ActionDispatch::Callbacks'
,
lambda
{
!
cache_classes
})
middleware
.
use
(
'::ActionDispatch::Cookies'
)
middleware
.
use
(
lambda
{
ActionController
::
SessionManagement
.
session_store_for
(
action_controller
.
session_store
)
},
lambda
{
action_controller
.
session
})
middleware
.
use
(
'::ActionDispatch::Flash'
,
:if
=>
lambda
{
action_controller
.
session_store
})
middleware
.
use
(
lambda
{
metal_loader
.
build_middleware
(
metals
)
},
:if
=>
lambda
{
metal_loader
.
metals
.
any?
})
middleware
.
use
(
'ActionDispatch::ParamsParser'
)
middleware
.
use
(
'::Rack::MethodOverride'
)
middleware
.
use
(
'::ActionDispatch::Head'
)
end
end
end
end
end
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录