Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
02908e11
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,发现更多精彩内容 >>
提交
02908e11
编写于
1月 25, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
As first step setup the load path and lazy compare middlewares.
上级
1177a40e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
26 deletion
+46
-26
actionpack/lib/action_dispatch/middleware/stack.rb
actionpack/lib/action_dispatch/middleware/stack.rb
+13
-1
actionpack/test/dispatch/middleware_stack_test.rb
actionpack/test/dispatch/middleware_stack_test.rb
+6
-0
activerecord/lib/active_record/railtie.rb
activerecord/lib/active_record/railtie.rb
+3
-3
railties/lib/rails/application/bootstrap.rb
railties/lib/rails/application/bootstrap.rb
+4
-0
railties/lib/rails/engine.rb
railties/lib/rails/engine.rb
+2
-2
railties/test/plugins/vendored_test.rb
railties/test/plugins/vendored_test.rb
+18
-20
未找到文件。
actionpack/lib/action_dispatch/middleware/stack.rb
浏览文件 @
02908e11
...
@@ -55,7 +55,11 @@ def ==(middleware)
...
@@ -55,7 +55,11 @@ def ==(middleware)
when
Class
when
Class
klass
==
middleware
klass
==
middleware
else
else
klass
==
ActiveSupport
::
Inflector
.
constantize
(
middleware
.
to_s
)
if
lazy_compare?
(
@klass
)
&&
lazy_compare?
(
middleware
)
normalize
(
@klass
)
==
normalize
(
middleware
)
else
klass
==
ActiveSupport
::
Inflector
.
constantize
(
middleware
.
to_s
)
end
end
end
end
end
...
@@ -72,6 +76,14 @@ def build(app)
...
@@ -72,6 +76,14 @@ def build(app)
end
end
private
private
def
lazy_compare?
(
object
)
object
.
is_a?
(
String
)
||
object
.
is_a?
(
Symbol
)
end
def
normalize
(
object
)
object
.
to_s
.
strip
.
sub
(
/^::/
,
''
)
end
def
build_args
def
build_args
Array
(
args
).
map
{
|
arg
|
arg
.
respond_to?
(
:call
)
?
arg
.
call
:
arg
}
Array
(
args
).
map
{
|
arg
|
arg
.
respond_to?
(
:call
)
?
arg
.
call
:
arg
}
end
end
...
...
actionpack/test/dispatch/middleware_stack_test.rb
浏览文件 @
02908e11
...
@@ -87,4 +87,10 @@ def setup
...
@@ -87,4 +87,10 @@ def setup
end
end
assert_equal
[
:foo
],
@stack
.
last
.
send
(
:build_args
)
assert_equal
[
:foo
],
@stack
.
last
.
send
(
:build_args
)
end
end
test
"lazy compares so unloaded constants can be loaded"
do
@stack
.
use
"UnknownMiddleware"
@stack
.
use
:"MiddlewareStackTest::BazMiddleware"
assert
@stack
.
include?
(
"::MiddlewareStackTest::BazMiddleware"
)
end
end
end
activerecord/lib/active_record/railtie.rb
浏览文件 @
02908e11
...
@@ -49,9 +49,9 @@ class Railtie < Rails::Railtie
...
@@ -49,9 +49,9 @@ class Railtie < Rails::Railtie
# Setup database middleware after initializers have run
# Setup database middleware after initializers have run
initializer
"active_record.initialize_database_middleware"
do
|
app
|
initializer
"active_record.initialize_database_middleware"
do
|
app
|
middleware
=
app
.
config
.
middleware
middleware
=
app
.
config
.
middleware
if
middleware
.
include?
(
ActiveRecord
::
SessionStore
)
if
middleware
.
include?
(
"ActiveRecord::SessionStore"
)
middleware
.
insert_before
ActiveRecord
::
SessionStore
,
ActiveRecord
::
ConnectionAdapters
::
ConnectionManagement
middleware
.
insert_before
"ActiveRecord::SessionStore"
,
ActiveRecord
::
ConnectionAdapters
::
ConnectionManagement
middleware
.
insert_before
ActiveRecord
::
SessionStore
,
ActiveRecord
::
QueryCache
middleware
.
insert_before
"ActiveRecord::SessionStore"
,
ActiveRecord
::
QueryCache
else
else
middleware
.
use
ActiveRecord
::
ConnectionAdapters
::
ConnectionManagement
middleware
.
use
ActiveRecord
::
ConnectionAdapters
::
ConnectionManagement
middleware
.
use
ActiveRecord
::
QueryCache
middleware
.
use
ActiveRecord
::
QueryCache
...
...
railties/lib/rails/application/bootstrap.rb
浏览文件 @
02908e11
...
@@ -76,6 +76,10 @@ module Bootstrap
...
@@ -76,6 +76,10 @@ module Bootstrap
initializer
:initialize_dependency_mechanism
do
|
app
|
initializer
:initialize_dependency_mechanism
do
|
app
|
ActiveSupport
::
Dependencies
.
mechanism
=
app
.
config
.
cache_classes
?
:require
:
:load
ActiveSupport
::
Dependencies
.
mechanism
=
app
.
config
.
cache_classes
?
:require
:
:load
end
end
initializer
:bootstrap_load_path
do
# This is just an initializer used as hook so all load paths are loaded together
end
end
end
end
end
end
end
\ No newline at end of file
railties/lib/rails/engine.rb
浏览文件 @
02908e11
...
@@ -47,7 +47,7 @@ def load_tasks
...
@@ -47,7 +47,7 @@ def load_tasks
end
end
# Add configured load paths to ruby load paths and remove duplicates.
# Add configured load paths to ruby load paths and remove duplicates.
initializer
:set_load_path
do
initializer
:set_load_path
,
:before
=>
:bootstrap_load_path
do
config
.
load_paths
.
reverse_each
do
|
path
|
config
.
load_paths
.
reverse_each
do
|
path
|
$LOAD_PATH
.
unshift
(
path
)
if
File
.
directory?
(
path
)
$LOAD_PATH
.
unshift
(
path
)
if
File
.
directory?
(
path
)
end
end
...
@@ -56,7 +56,7 @@ def load_tasks
...
@@ -56,7 +56,7 @@ def load_tasks
# Set the paths from which Rails will automatically load source files,
# Set the paths from which Rails will automatically load source files,
# and the load_once paths.
# and the load_once paths.
initializer
:set_autoload_paths
do
|
app
|
initializer
:set_autoload_paths
,
:before
=>
:bootstrap_load_path
do
|
app
|
ActiveSupport
::
Dependencies
.
load_paths
.
unshift
(
*
config
.
load_paths
)
ActiveSupport
::
Dependencies
.
load_paths
.
unshift
(
*
config
.
load_paths
)
if
reloadable?
(
app
)
if
reloadable?
(
app
)
...
...
railties/test/plugins/vendored_test.rb
浏览文件 @
02908e11
...
@@ -48,6 +48,7 @@ def app
...
@@ -48,6 +48,7 @@ def app
RUBY
RUBY
boot_rails
boot_rails
assert
$foo
end
end
test
"plugin paths get added to the AS::Dependency list"
do
test
"plugin paths get added to the AS::Dependency list"
do
...
@@ -252,26 +253,6 @@ def self.call(env)
...
@@ -252,26 +253,6 @@ def self.call(env)
assert_equal
"FooMetal"
,
last_response
.
body
assert_equal
"FooMetal"
,
last_response
.
body
end
end
test
"use plugin middleware in application config"
do
plugin
"foo"
do
|
plugin
|
plugin
.
write
"lib/foo.rb"
,
<<-
RUBY
class Foo
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
end
end
RUBY
end
add_to_config
"config.middleware.use :Foo"
boot_rails
end
test
"namespaced controllers with namespaced routes"
do
test
"namespaced controllers with namespaced routes"
do
@plugin
.
write
"config/routes.rb"
,
<<-
RUBY
@plugin
.
write
"config/routes.rb"
,
<<-
RUBY
ActionController::Routing::Routes.draw do
ActionController::Routing::Routes.draw do
...
@@ -332,6 +313,23 @@ class Engine < Rails::Engine
...
@@ -332,6 +313,23 @@ class Engine < Rails::Engine
assert
rescued
,
"Expected boot rails to fail"
assert
rescued
,
"Expected boot rails to fail"
end
end
test
"use plugin middleware in application config"
do
@plugin
.
write
"lib/bukkits.rb"
,
<<-
RUBY
class Bukkits
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
end
end
RUBY
add_to_config
"config.middleware.use
\"
Bukkits
\"
"
boot_rails
end
end
end
class
VendoredOrderingTest
<
Test
::
Unit
::
TestCase
class
VendoredOrderingTest
<
Test
::
Unit
::
TestCase
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录