Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d2bd71a1
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,发现更多精彩内容 >>
提交
d2bd71a1
编写于
12月 23, 2009
作者:
C
Carlhuda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish moving config.frameworks-dependent code to the framework plugin
上级
61af34b0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
110 addition
and
126 deletion
+110
-126
actionmailer/lib/action_mailer/rails.rb
actionmailer/lib/action_mailer/rails.rb
+24
-0
actionpack/lib/action_controller/notifications.rb
actionpack/lib/action_controller/notifications.rb
+0
-10
actionpack/lib/action_controller/rails.rb
actionpack/lib/action_controller/rails.rb
+75
-0
activerecord/lib/active_record/notifications.rb
activerecord/lib/active_record/notifications.rb
+0
-5
activerecord/lib/active_record/rails.rb
activerecord/lib/active_record/rails.rb
+8
-0
railties/lib/rails/application.rb
railties/lib/rails/application.rb
+1
-111
railties/test/application/routing_test.rb
railties/test/application/routing_test.rb
+2
-0
未找到文件。
actionmailer/lib/action_mailer/rails.rb
0 → 100644
浏览文件 @
d2bd71a1
require
"action_mailer"
module
ActionMailer
class
Plugin
<
Rails
::
Plugin
plugin_name
:action_mailer
initializer
"action_mailer.set_configs"
do
|
app
|
app
.
config
.
action_mailer
.
each
do
|
k
,
v
|
ActionMailer
::
Base
.
send
"
#{
k
}
="
,
v
end
end
# TODO: ActionController::Base.logger should delegate to its own config.logger
initializer
"action_mailer.logger"
do
ActionMailer
::
Base
.
logger
||=
Rails
.
logger
end
initializer
"action_mailer.view_paths"
do
|
app
|
# TODO: this should be combined with the logic for default config.action_mailer.view_paths
view_path
=
ActionView
::
PathSet
.
type_cast
(
app
.
config
.
view_path
,
app
.
config
.
cache_classes
)
ActionMailer
::
Base
.
template_root
=
view_path
if
ActionMailer
::
Base
.
view_paths
.
blank?
end
end
end
\ No newline at end of file
actionpack/lib/action_controller/notifications.rb
已删除
100644 → 0
浏览文件 @
61af34b0
require
'active_support/notifications'
ActiveSupport
::
Notifications
.
subscribe
(
/(read|write|cache|expire|exist)_(fragment|page)\??/
)
do
|*
args
|
event
=
ActiveSupport
::
Notifications
::
Event
.
new
(
*
args
)
if
logger
=
ActionController
::
Base
.
logger
human_name
=
event
.
name
.
to_s
.
humanize
logger
.
info
(
"
#{
human_name
}
(%.1fms)"
%
event
.
duration
)
end
end
actionpack/lib/action_controller/rails.rb
浏览文件 @
d2bd71a1
...
...
@@ -23,5 +23,80 @@ class Plugin < Rails::Plugin
app
.
route_configuration_files
<<
app
.
config
.
builtin_routes_configuration_file
app
.
reload_routes!
end
# Include middleware to serve up static assets
initializer
"action_controller.initialize_static_server"
do
|
app
|
if
app
.
config
.
serve_static_assets
app
.
config
.
middleware
.
use
(
ActionDispatch
::
Static
,
Rails
.
public_path
)
end
end
initializer
"action_controller.initialize_middleware_stack"
do
|
app
|
middleware
=
app
.
config
.
middleware
middleware
.
use
(
::
Rack
::
Lock
,
:if
=>
lambda
{
ActionController
::
Base
.
allow_concurrency
})
middleware
.
use
(
::
Rack
::
Runtime
)
middleware
.
use
(
ActionDispatch
::
ShowExceptions
,
lambda
{
ActionController
::
Base
.
consider_all_requests_local
})
middleware
.
use
(
ActionDispatch
::
Callbacks
,
lambda
{
ActionController
::
Dispatcher
.
prepare_each_request
})
middleware
.
use
(
lambda
{
ActionController
::
Base
.
session_store
},
lambda
{
ActionController
::
Base
.
session_options
})
middleware
.
use
(
ActionDispatch
::
ParamsParser
)
middleware
.
use
(
::
Rack
::
MethodOverride
)
middleware
.
use
(
::
Rack
::
Head
)
middleware
.
use
(
ActionDispatch
::
StringCoercion
)
end
initializer
"action_controller.initialize_framework_caches"
do
ActionController
::
Base
.
cache_store
||=
RAILS_CACHE
end
# Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+
# (but only for those frameworks that are to be loaded). If the framework's
# paths have already been set, it is not changed, otherwise it is
# set to use Configuration#view_path.
initializer
"action_controller.initialize_framework_views"
do
|
app
|
# TODO: this should be combined with the logic for default config.action_controller.view_paths
view_path
=
ActionView
::
PathSet
.
type_cast
(
app
.
config
.
view_path
,
app
.
config
.
cache_classes
)
ActionController
::
Base
.
view_paths
=
view_path
if
ActionController
::
Base
.
view_paths
.
blank?
end
initializer
"action_controller.initialize_metal"
do
|
app
|
Rails
::
Rack
::
Metal
.
requested_metals
=
app
.
config
.
metals
app
.
config
.
middleware
.
insert_before
(
:"ActionDispatch::ParamsParser"
,
Rails
::
Rack
::
Metal
,
:if
=>
Rails
::
Rack
::
Metal
.
metals
.
any?
)
end
# # Prepare dispatcher callbacks and run 'prepare' callbacks
initializer
"action_controller.prepare_dispatcher"
do
|
app
|
# TODO: This used to say unless defined?(Dispatcher). Find out why and fix.
require
'rails/dispatcher'
Dispatcher
.
define_dispatcher_callbacks
(
app
.
config
.
cache_classes
)
unless
app
.
config
.
cache_classes
# Setup dev mode route reloading
routes_last_modified
=
app
.
routes_changed_at
reload_routes
=
lambda
do
unless
app
.
routes_changed_at
==
routes_last_modified
routes_last_modified
=
app
.
routes_changed_at
app
.
reload_routes!
end
end
ActionDispatch
::
Callbacks
.
before_dispatch
{
|
callbacks
|
reload_routes
.
call
}
end
end
initializer
"action_controller.notifications"
do
|
app
|
require
'active_support/notifications'
ActiveSupport
::
Notifications
.
subscribe
(
/(read|write|cache|expire|exist)_(fragment|page)\??/
)
do
|*
args
|
event
=
ActiveSupport
::
Notifications
::
Event
.
new
(
*
args
)
if
logger
=
ActionController
::
Base
.
logger
human_name
=
event
.
name
.
to_s
.
humanize
logger
.
info
(
"
#{
human_name
}
(%.1fms)"
%
event
.
duration
)
end
end
end
end
end
\ No newline at end of file
activerecord/lib/active_record/notifications.rb
已删除
100644 → 0
浏览文件 @
61af34b0
require
'active_support/notifications'
ActiveSupport
::
Notifications
.
subscribe
(
"sql"
)
do
|
name
,
before
,
after
,
result
,
instrumenter_id
,
payload
|
ActiveRecord
::
Base
.
connection
.
log_info
(
payload
[
:sql
],
name
,
after
-
before
)
end
activerecord/lib/active_record/rails.rb
浏览文件 @
d2bd71a1
...
...
@@ -47,5 +47,13 @@ class Plugin < Rails::Plugin
ActiveRecord
::
Base
.
logger
||=
Rails
.
logger
end
initializer
"active_record.notifications"
do
require
'active_support/notifications'
ActiveSupport
::
Notifications
.
subscribe
(
"sql"
)
do
|
name
,
before
,
after
,
result
,
instrumenter_id
,
payload
|
ActiveRecord
::
Base
.
connection
.
log_info
(
payload
[
:sql
],
name
,
after
-
before
)
end
end
end
end
\ No newline at end of file
railties/lib/rails/application.rb
浏览文件 @
d2bd71a1
...
...
@@ -139,14 +139,6 @@ def call(env)
$LOAD_PATH
.
uniq!
end
# # Requires all frameworks specified by the Configuration#frameworks
# # list. By default, all frameworks (Active Record, Active Support,
# # Action Pack, Action Mailer, and Active Resource) are loaded.
# initializer :require_frameworks do
# require 'active_support/all' unless config.active_support.bare
# config.frameworks.each { |framework| require(framework.to_s) }
# end
# Set the paths from which Rails will automatically load source files, and
# the load_once paths.
initializer
:set_autoload_paths
do
...
...
@@ -177,34 +169,7 @@ def call(env)
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
initializer
:preload_frameworks
do
if
config
.
preload_frameworks
config
.
frameworks
.
each
do
|
framework
|
# String#classify and #constantize aren't available yet.
toplevel
=
Object
.
const_get
(
framework
.
to_s
.
gsub
(
/(?:^|_)(.)/
)
{
$1
.
upcase
})
toplevel
.
load_all!
if
toplevel
.
respond_to?
(
:load_all!
)
end
end
end
# Include middleware to serve up static assets
initializer
:initialize_static_server
do
if
defined?
(
ActionController
)
&&
config
.
serve_static_assets
config
.
middleware
.
use
(
ActionDispatch
::
Static
,
Rails
.
public_path
)
end
end
initializer
:initialize_middleware_stack
do
if
defined?
(
ActionController
)
config
.
middleware
.
use
(
::
Rack
::
Lock
,
:if
=>
lambda
{
ActionController
::
Base
.
allow_concurrency
})
config
.
middleware
.
use
(
::
Rack
::
Runtime
)
config
.
middleware
.
use
(
ActionDispatch
::
ShowExceptions
,
lambda
{
ActionController
::
Base
.
consider_all_requests_local
})
config
.
middleware
.
use
(
ActionDispatch
::
Callbacks
,
lambda
{
ActionController
::
Dispatcher
.
prepare_each_request
})
config
.
middleware
.
use
(
lambda
{
ActionController
::
Base
.
session_store
},
lambda
{
ActionController
::
Base
.
session_options
})
config
.
middleware
.
use
(
ActionDispatch
::
ParamsParser
)
config
.
middleware
.
use
(
::
Rack
::
MethodOverride
)
config
.
middleware
.
use
(
::
Rack
::
Head
)
config
.
middleware
.
use
(
ActionDispatch
::
StringCoercion
)
end
ActiveSupport
::
Autoload
.
eager_load!
if
config
.
preload_frameworks
end
initializer
:initialize_cache
do
...
...
@@ -218,12 +183,6 @@ def call(env)
end
end
initializer
:initialize_framework_caches
do
if
defined?
(
ActionController
)
ActionController
::
Base
.
cache_store
||=
RAILS_CACHE
end
end
initializer
:initialize_logger
do
# if the environment has explicitly defined a logger, use it
next
if
Rails
.
logger
...
...
@@ -254,14 +213,6 @@ def call(env)
# logger is already set, it is not changed, otherwise it is set to use
# RAILS_DEFAULT_LOGGER.
initializer
:initialize_framework_logging
do
for
framework
in
[
:action_controller
,
:action_mailer
]
# TODO BEFORE PUSHING: REMOVEZ
begin
framework
.
to_s
.
camelize
.
constantize
.
const_get
(
"Base"
).
logger
||=
Rails
.
logger
rescue
Exception
end
end
ActiveSupport
::
Dependencies
.
logger
||=
Rails
.
logger
Rails
.
cache
.
logger
||=
Rails
.
logger
end
...
...
@@ -308,46 +259,6 @@ def call(env)
end
end
# Initializes framework-specific settings for each of the loaded frameworks
# (Configuration#frameworks). The available settings map to the accessors
# on each of the corresponding Base classes.
initializer
:initialize_framework_settings
do
(
config
.
frameworks
-
[
:active_record
,
:action_controller
]).
each
do
|
framework
|
# TODO BEFORE PUSHING: This needs to work differently
begin
base_class
=
framework
.
to_s
.
camelize
.
constantize
.
const_get
(
"Base"
)
config
.
send
(
framework
).
each
do
|
setting
,
value
|
base_class
.
send
(
"
#{
setting
}
="
,
value
)
end
rescue
Exception
end
end
end
# Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+
# (but only for those frameworks that are to be loaded). If the framework's
# paths have already been set, it is not changed, otherwise it is
# set to use Configuration#view_path.
initializer
:initialize_framework_views
do
if
defined?
(
ActionView
)
view_path
=
ActionView
::
PathSet
.
type_cast
(
config
.
view_path
,
config
.
cache_classes
)
ActionMailer
::
Base
.
template_root
=
view_path
if
defined?
(
ActionMailer
)
&&
ActionMailer
::
Base
.
view_paths
.
blank?
ActionController
::
Base
.
view_paths
=
view_path
if
defined?
(
ActionController
)
&&
ActionController
::
Base
.
view_paths
.
blank?
end
end
initializer
:initialize_metal
do
if
defined?
(
ActionController
)
Rails
::
Rack
::
Metal
.
requested_metals
=
config
.
metals
config
.
middleware
.
insert_before
(
:"ActionDispatch::ParamsParser"
,
Rails
::
Rack
::
Metal
,
:if
=>
Rails
::
Rack
::
Metal
.
metals
.
any?
)
end
end
# # bail out if gems are missing - note that check_gem_dependencies will have
# # already called abort() unless $gems_rake_task is set
# return unless gems_dependencies_loaded
...
...
@@ -364,27 +275,6 @@ def call(env)
end
end
# TODO: Make a DSL way to limit an initializer to a particular framework
# # Prepare dispatcher callbacks and run 'prepare' callbacks
initializer
:prepare_dispatcher
do
next
unless
configuration
.
frameworks
.
include?
(
:action_controller
)
require
'rails/dispatcher'
unless
defined?
(
::
Dispatcher
)
Dispatcher
.
define_dispatcher_callbacks
(
configuration
.
cache_classes
)
unless
configuration
.
cache_classes
# Setup dev mode route reloading
routes_last_modified
=
routes_changed_at
reload_routes
=
lambda
do
unless
routes_changed_at
==
routes_last_modified
routes_last_modified
=
routes_changed_at
reload_routes!
end
end
ActionDispatch
::
Callbacks
.
before_dispatch
{
|
callbacks
|
reload_routes
.
call
}
end
end
# Eager load application classes
initializer
:load_application_classes
do
next
if
$rails_rake_task
...
...
railties/test/application/routing_test.rb
浏览文件 @
d2bd71a1
...
...
@@ -171,6 +171,8 @@ def baz
end
RUBY
sleep
0.1
get
'/foo'
assert_equal
'baz'
,
last_response
.
body
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录